COM: Script Caching
NET4: Script Caching
NET5: Script Caching
All thre sample applications (COM, NET4 and NET5) implement that same functionality.
When the application first starts a TreeView is populated with the scripts
in the Nodes directory/sub-directory.
Selecting a node reads the script text and shows it in the WinWrap® Basic IDE.
Clicking on the design mode button takes the WinWrap® Basic IDE from design mode to execution mode.
Clicking on the Run Script(s) button loads the script into the WinWrap® Basic NoUI object
The results are shown in the Immediate window.
The WinWrap® Basic WWB-COM language is extended with the LoadScript function. LoadScript uses a dictionary of currently loaded ScriptNodes to determine if the script requested is already in memory as an instance of a ScriptNode. If not, LoadScript reads the script, parses it and creates an instance of the ScriptNode class. The ScriptNode holds a reference to the WinWrap® Basic Module that has been loaded into memory after parsing. The ScriptNode class also holds a reference to a WinWrap® Basic Handler object and optionally a WinWrap® Basic FastEvaluate0 object. Specific code snippets are shown in each respective solution (COM, NET4 and NET5).
Switching back to design mode.
Allows the Fast checkbox to be checked.
While in design mode the Fast checkbox allows selection of either "normal" or "fast" evaluation. Normal evaluation uses the WinWrap® Basic Handler.Evaluate method to evaluate the script's function. Fast evaluation uses the WinWrap® Basic FastEvaluate0.Evaluate method to evaluate the script's function. Fast evaluation is quicker and does not allow the user to single step or set break points in the script's function.
Switching out of design mode.
Now the timing script can be run.
Syntax and run-time errors caused by a script are reported to the WinWrap® Basic BasicIdeCtl using the ReportError method.
These samples all use SynchronizedEdit=True to coordinate editing/debugging/execution between a WinWrap® BasicIdeCtl and BasicNoUIObj. The sample applications could have used just a BasicIdeCtl or BasicNoUIObj to acheive the script caching functionality. SynchronizedEdit is not a requirement for script caching.
Copyright Polar Engineering, Inc.