Mini-Editor

To Access: When there is an error in running a script, the Mini-Editor window displays.

The figure shows the Mini-Editor attached to a VBScript property defining a subroutine (event):

Figure 1. Example Mini-Editor

Description

In this case, a "TextVar1" object's "EventPumpData()" property is being edited. The mini-editor is described according to its three sections.

Upper Part - Selection. The controls are used as follows

Fields

Table 1. VBS Mini-Editor Contents

Field

Description

VBScript

Shows that the Mini-Editor is in VBS mode. There are other modes (covered below) which bypass VBS and just return a constant or a variable value. The other modes run much faster than running a VBS function.

OK

OK. Also causes “check syntax” to run.

Cancel

Cancel and disregard all changes.

Usage Notes

Lower Part- VBScript Code. The following show the script for the "EventPumpData" function:

Sub MyTextVar1_EventPumpData() 
:Dim This As Object : Set This = MyTextVar1 
tColor = RGB(0,255,0)' Green 
fColor = RGB(255,0,0)' Red 
b = Bool1 ' Variable 
If (b) Then 
	This.BackColor = tColor 
Else 
	This.BackColor = fColor 
End If 
End Sub

This subroutine is run whenever new data is available to the view. The mini-editor automatically generates the code in italics (the first two and last lines).

  • First two lines — The subroutine name is a combination of the object code ("MyTextVar1" is this case) and the given property ("EventPumpData"), stripped of characters illegal in function names. The name should be unique to the view. You can call other object/property functions (and subroutines) using the function name. The This variable is set to equal the object code of the object, and is serves as a convenient handle to the object (in this case you could also use "MyTextVar1" directly instead of This).

  • Last line(s) — "End Sub" terminates the subroutine's definition.

    Tip

    For functions you must set the Retn variable equal to the return value so that it can be assigned to the function return. The This and Retn variables serve certain purposes:

    • They are easy handles to more complex representations.
    • More importantly, using This and Retn allows you to change the object code without changing any VBScript code!
    • Notice that the "MyTextVar1" object code is not used outside of the automatically generated code (in this case).
  • Typed in code — This function is getting the value for variable "Bool1”. It also setting the background color of the object according to "Bool1": green for true and red for false. RGB() is a function pre-defined in DECLARE.BAS which must be in the boot directory. You can add your own function definitions into DECLARE.BAS (if available).

Here are the actions tied to the VBS Mini-Editor's shortcut menu:

Table 2. VBS Mini-Editor Context Menu

Field

Description

Cut / Copy / Paste

Clipboard functions for text in the buffer.

List Objects

Brings up a listbox of objects specified by All, Form, Variables, or Business.

List Properties/Methods

Brings up a listbox of properties/methods associated with the specified object.

List Functions

Brings up a listbox of functions associated with the specified object.

Quick Info

Brings up information about the variable specified.

Check Syntax…

Compile the buffer and check for syntax errors. Errors are flagged with a message box and the offending text is highlighted. This check does not catch run time errors (such a calling an undefined function). Run time errors are trapped causing the view to switch back into edit mode.

Revert to Saved

Will load the previously saved script

Toggle Breakpoint

Sets or removes a breakpoint.

Toggle Bookmark

Sets or removes a bookmark

Tip

Pressing '.' in the mini-editor also can be used to bring up a list of objects.