logo WinWrap®

Script Caching

Script Caching

  • Manage script lifetimes
  • BasicIdeCtl synchronized with a BasicNoUIObj in the same thread
  • Application evaluates a function defined by script
  • DesignMode controls script editing/evaluation for the application
  • COM Sample Implementation
  • NET 4 Sample Implementation
  • NET 5 Sample Implementation

Script Caching


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.
Startup

Selecting a node reads the script text and shows it in the WinWrap® Basic IDE.
View a script

Clicking on the design mode button takes the WinWrap® Basic IDE from design mode to execution mode.
Out of design mode

Clicking on the Run Script(s) button loads the script into the WinWrap® Basic NoUI object and evaluates. The results are shown in the Immediate window.
Run scripts
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.
Design mode
Allows the Fast checkbox to be checked.
Fast mode
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.
Out of design mode
Now the timing script can be run.
Timing test

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.