Scripts Plugin version 3.1 has been out and comes with added another thread-safe class to sequentially run a thread with the mainThread in “synchronous” fashion. It is called the “ThreadedTimer” of which its workings are derived from the ThreadsafeGUIProcessor. It services the thread and the mainThread and has four events: “ServiceThread”, “ServiceMainThread”, “ServiceEnding” and “ServiceEnd”. Several related projects to this class have been developed and provided with this download.
About the Scripts plugin:
This is a multifunctional plugin. It encapsulates XojoScript and stringifies Xojo framework methods and properties. Stringified methods are defined in the ContextProcessor class, which can be presented as
- a XojoScript context allowing a script to have access to the whole Xojo framework.
a helper class to allow creation of GUI elements and handlers on the fly.
Basic is another class defined in this plugin. It has a different syntax than Xojo/XojoScript, it has helper classes to provide a context. Thus it has similar capabilities. Currently, it only recognizes the methods in your context class.
Threadsafe is the goto class if you need to make your thread to access the GUI. It is very simple to use.
If you have a call like StartButton.enabled = false, you can replace it with myThreadSafe.BooleanProperty(StartButton, “Enabled”) = false. The call will block the thread until the button is updated. Note that the BooleanProperty method is both a setter as a getter.
Interactive scripting with XojoScript and BasicScript in a Desktop application requires them to run in a thread that needs to be suspended once user input is required. Threadsafe is your friend.
Make sure you have the Lexing plugin installed when you use the sample projects. Note that this plugin is not dependent on the Lexing plugin.
Documentation: In the Xojo IDE (provided the plugin is installed in the Plugins Folder) navigate to the Help menu > Plugin References > Scripts.