Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/JavaScript/JavaScript
Function:
Required plugins for this example: MBS MacFrameworks Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/JavaScript/JavaScript
This example is the version from Sat, 6th Nov 2015.
Project "JavaScript.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control ListLog Inherits Listbox
ControlInstance ListLog Inherits Listbox
End Control
Control InputField Inherits TextArea
ControlInstance InputField Inherits TextArea
End Control
Control ExecuteButton Inherits PushButton
ControlInstance ExecuteButton Inherits PushButton
EventHandler Sub Action() dim s as string = InputField.Text log ">" + s dim e as JSValueMBS dim j as JSValueMBS = context.EvaluateScript(s, "", nil, 1, e) if e <> nil then log e.stringValue end if if j <> nil then log j.stringValue end if End EventHandler
End Control
Control PropertiesButton Inherits PushButton
ControlInstance PropertiesButton Inherits PushButton
EventHandler Sub Action() dim g as JSObjectMBS = context.globalObject dim names() as string = g.PropertyNames for each name as string in names dim e as JSValueMBS dim v as string dim j as JSValueMBS = g.GetProperty(name, e) if e <> nil then v = e.stringValue end if if j <> nil then if j.Type = j.kJSTypeObject then v = j.JSONString else v = j.StringValue end if end if log name+": "+v next End EventHandler
End Control
Control ExecuteButton1 Inherits PushButton
ControlInstance ExecuteButton1 Inherits PushButton
EventHandler Sub Action() dim s as string = InputField.Text log ">" + s dim e as JSValueMBS dim r as Boolean = context.CheckScriptSyntax(s, "", e) if e <> nil then log e.stringValue else log "Syntax Okay" end if End EventHandler
End Control
EventHandler Sub Open() context = new JSContextMBS End EventHandler
Sub log(s as string) ListLog.AddRow s ListLog.ScrollPosition = ListLog.ListIndex End Sub
Property context As JSContextMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacFrameworks Plugin.





Links
MBS FileMaker Plugins