Jargon Software
Getting Started with Jargon Writer
Using the Script Editor Window


Contents:

Overview of the Script Editor Window

Script Toolbar

App Combobox

Target Tree

Method List

Text Editor Panel

Edit Tools Panel

Status Panel



Overview of the Script Editor Window

Script Editor Window


The Script Editor Window is where all script functions and variables are defined, modified or removed. These functions contain the client-side logic that is executed when certain user actions occur or when they are invoked by other client or host procedures. To open this window, select "View-->Script Editor" from the menu bar in the Design Window. You can also select a function in the "Available Functions" listbox in the design window and click the Edit button to both open the Script Editor and position the selected function in the text editor for editing in one step.

A Function is a name assigned to a group of one or more script statements that include Client or Host methods. A function can contain any number of statements, of any type, in any desired order. You can think of a function as being similar to a subprocedure or subroutine. A function can be executed as a result of any of the following actions:

  • The user performs a mouse, stylus or keyboard action that generates ("fires") an event that is linked to a specified function.
  • Input is received when an external data source such as an http response, barcode scan or mag card swipe is read, via a function registered with a "callback" method.
  • A host method "invokes" a function in a client app.
  • A client procedure "invokes" a function from within another function in the same app or from another app.
Client Methods are run entirely on the client, without any host interaction. These methods are can be used to do calculations and comparisons of data values, access a local database or text file, send or receive data via serial or IR ports, change the state of an object (such as viewing a frame or enabling a button) or to obtain the current value of an object (such as getting the current text value in a textfield).

The objects referenced in a Client Method may be script variables, script objects, or special Jargon objects in the same app or in any other app that is open in the Script Editor Target Tree. This latter feature allows "myapp1" to get a value from a textfield in "myapp2" when a button is clicked in "myapp1", for example.

Host Methods are run on both the client and the host.

  • First, the client executes a series of methods to specify the host procedure name and related values, and zero or more additional data parameters that it will send to the host. These are formatted as name/value pairs.
  • Second, the client sends an http request to the host, specifying the host's URL address, the script name that specifies the middleware to be invoked, and the data values from step one that will be passed to the host procedure as input parameters.
  • Third, the host receives the message via its web server and passes it to the middleware specified in the script. The middleware selects a process to run the host procedure (starting one if necessary) and sends it the additional parameters. The host procedure then executes the user-written business logic.
  • Finally, the host procedure returns a set of results containing one or more methods (also known as Component Instruction Objects, or CIO's) back to the client, which receives and executes them. These CIOs most often populate various textfields, textareas, textpanes and tables in the client app with data values calculated or retrieved from a database by the host procedure. However, CIOs may do many other actions as well, including invoking any pre-defined client function.
During this entire process, a "Stop sign" icon and "Contacting Host" message will be displayed in the status line at the bottom of the screen. When all responses sent by the host have been completely received by the client, the status area will be cleared. To cancel the host request (such as if you suspect the server is having problems), click the "Stop sign" icon.
User Tip: Note that one or more of the CIOs may be message or warning boxes, which are modal objects (the user cannot do anything else in the app while a modal dialog box is displayed). If a CIO containing a message box or warning box is received, the above status will continue to be displayed until the user dismisses this modal box by clicking the OK button, so that the processing of any other CIOs in the host method can be completed. After all CIOs received from the host have been processed, the host method ends and then the status line is cleared.
Control statements in the scripting language provide looping constructs, conditional statements ("If/Then/Else") and similar ways to control execution sequence, as in any true programming language. The Insert menubar choices provide a quick way to enter such control statements in a script.

Functions are executed when they are invoked within a client function or host procedure, or when any of the event(s) to which they are linked take place. Functions are linked to an event of an object by associating them in the Events Panel of the Properties Panel in the Design Window. For a more comprehensive discussion of methods, objects, methods and events, see the Overview of Functions, Methods and Events section.
 

Script Toolbar

The buttons in the Script Toolbar allow you to Open a new app in the Target Tree, Save the app whose script is currently being edited, Cut, Copy and Paste script statements in the editor textarea, and Return to the Design Window. The Cut, Copy and Paste buttons do the same actions as the corresponding Edit menubar choices. You can also use the standard Windows control key sequences in the script editor for Cut (CTRL-X), Copy (CTRL-C) and Paste (CTRL-V) operations. (However, note that these control keys cannot be used in the Design Window).

App Combobox

The Edit App: combobox allows selection of the xml app whose script is to be edited. It does not have to be the same app that is currently selected in the Target Tree, although this is the default behavior when first opening the Script Editor Window from the Design Window. Use the Open button in the Script Toolbar to open any app that is not currently displayed in the Target Tree.

Target Tree

The Target Tree is used to select an object in order to see its methods, and to find or insert those methods in the script. (The Target Tree is shared with the Design Window Component Tree; it is the same tree). The target object can be any object in the currently active app or in any other app that is open in the Target Tree, or any object in the Global Objects node.

To select a target object, select or open the desired app, then expand the app's root node in the tree until the desired object is visible, then click on that object in the tree so that it is highlighted. Its available methods will then be displayed in the Method List below the tree.

Method List

The list below the Target Tree (lower left) shows the available methods that are valid for the component that is currently highlighted in the Target Tree. This list has three columns.

The first column shows the correct spelling of the method name (note that upper/lower case is significant)

The second column shows the data type of the "Return Value" that is returned by the method when it is executed. Many methods return nothing ("void"), while others return one of the supported data types: String, int or boolean. A script method can return only one value.

The third column contains the data type and descriptive parameter name of any required parameters. Supported data types are String, int and boolean. You must scroll the Method List to the right to see this column. All three column values are displayed in the status line at the bottom when you select the method.

Finding component methods in the script.
If a method is selected by clicking on it in the list and then clicking the Find Method button, the first occurrence of that method and the selected component to which it applies will be highlighted in the Text Editor panel and the "component.method" portion will be put into the "Search for:" textfield.

Inserting component methods in the script.
If a method is selected by clicking on it in the list and then clicking the Insert Method button, it and the selected component to which it applies will be inserted into the Text Editor panel at the point where the insertion cursor was last positioned. Also, if there was no other text on the line where the insertion was done, a concluding semicolon (";") will be added. If the method has any parameters, their type will be inserted within parentheses, and these must be replaced by the desired parameter values, as constants or methods which return a value of the correct type.

Text Editor Panel

The Text Editor Panel is where script functions and methods are entered and changed, by typing them manually, copying and pasting, or using the Insert choices from the menubar. Each xml app will normally have at least one function that contains a method that initially sets a frame visible when the app is first run.

There may be any (reasonable) number of functions within an xml app, and each function may contain any number of methods and other statements such as variable definitions, looping and conditional statements, etc. A large app could easily have several thousand lines of script statements, grouped into hundreds of functions.

For details on these methods, functions, and other scripting language features, see the Writing Scripts and Client Methods documents.

For a more general introduction to objects, methods and functions, see the next section Functions, Methods and Events.

Edit Tools Panel

The Edit Tools Panel above the Text Editor Panel contains textfields and buttons for standard search and replace features, with options to ignore case in searches and to replace the selected text or all occurrences of the selected text.

It also allows a single undo level to revert the script to its state before the latest paste, replace or insert action (but not before manual changes to the script).

The << and >> buttons shift the selected line(s) or portions of a line left or right one character position. This is useful to quickly indent or outdent text to show statement nesting levels and to follow typical coding standards. (The next person who works on a script will be a lot happier if it is easy to read. Plus, it could be you!).

The "Go To Line" button positions the text editor window and insertion cursor at the script line specified in the Line# field.

The "Jump to Function" combobox contains a list of the function names in the current script. Pull it down and select one to position the text editor window and insertion cursor at the first line of that function.

Status Panel

The Status Panel at the bottom of the Script Editor Window contains a one-line message area at the lower left in which various Jargon Writer help messages are displayed during each step of working with methods.  No input fields are used in the Status Panel.


<-- Previous Section      Up to Top      Return to Help Index      Next Section -->