Control
Conditional
Purpose: |
Change the flow of script execution, based on the results of a simple comparison of two items. When the statement is True, execution continues until an “EndIf” or “Else” Action is encountered. Otherwise, execution begins with the first line following the next “Else” (optional) or “EndIf” command. |
||||||||||||
Category: |
Control |
||||||||||||
Syntax: |
If "first item" "operator" "second item" first item The first item to compare. Can contain text, numbers, math expression, variables, etc. operator One of the following:
second item The second item to compare. Can contain text, numbers, math expression, variables, etc. |
||||||||||||
Example: |
The following example examines the contents of the variable [Name]. If [Name] is empty an error message appears, otherwise, the next page is displayed: If "[Name]" "=" "" You can also use If to detect the correct entry of a password: If "[Password]" "=" "Bravo172" |
Purpose: |
Change the flow of script execution based on the result of a complex expression. This is an advanced version of the standard If Action. When the statement is True, execution continues until an “EndIf” or “Else” Action is encountered. Otherwise, execution begins with the first line following the next “Else” (optional) or “EndIf” command. |
||||||||||||
Category: |
Control |
||||||||||||
Syntax: |
IfEx "expression" expression A basic expression consists of three elements - two items to be compared separated by a special operator. For example: "item operator item" The two items can be text, numbers, math expressions, variables, etc. The operator must be one of the following:
For example, the following expression compares the variable [City] to “Pittsburgh”: "[City] = Pittsburgh" If a comparison item contains spaces, then it must be surrounded with quotes, which in VisualNEO Win are specified using the special code: [#34]. For example: "[City] = [#34]St. Louis[#34]" You can also construct more complex statements by combining multiple expressions with “and” and “or”. For example, to find out if [City] equals either “Pittsburgh” or “Washington”: "[City] = Pittsburgh OR [City] = Washington" To find out if [City] equals “Pittsburgh” and another variable [Name] also equals “Jones”: "[City] = Pittsburgh AND [Name] = Jones" For extremely complex statements you may want to use “(“ and “)” to make sure expressions are evaluated in the correct order. |
||||||||||||
Example: |
IfEx "[Account] = Guest OR [Account] = Admin" |
Purpose: |
Repeat a series of Actions until a specified condition is no longer valid. Any Actions between the While and its matching EndWhile statement will continue to execute until the specified condition is no longer true. |
||||||||||||
Category: |
Control |
||||||||||||
Syntax: |
While "first item" "operator" "second item" first item The first item to compare. Can contain text, numbers, math expression, variables, etc. operator One of the following:
second item The second item to compare. Can contain text, numbers, math expression, variables, etc. |
||||||||||||
Example: |
In the following example, 100 tones are played using the PlayTone Action. The sound begins at a frequency of 0 Hertz, and is incremented by 25 Hertz, until 100 tones have been played in sequence: SetVar "[Count]" "0" |
Purpose: |
Repeat a series of Actions until a specified condition is met. This is an advanced version of the standard While Action. |
Category: |
Control |
Syntax: |
WhileEx "expression" expression The expression to be evaluated. See IfEx for information about constructing expressions. |
Example: |
WhileEx "[X] > 0 AND [Y] > 0" SetVar "[X]" "[X]-1" SetVar "[Y]" "[Y]-1" EndWhile |
Purpose: |
Exit the current While/WhileEx/EndWhile block. Execution continues with the Action following the next EndWhile statement. |
Category: |
Control |
Syntax: |
ExitWhile |
Example: |
SetVar "[Name]" "" |
Purpose: |
Repeat a group of Actions a specified number of times. |
Category: |
Control |
Syntax: |
Loop "start value" "stop value" "variable counter" start value The starting value for the loop. stop value The ending value for the loop. variable counter The name of the variable to use as a counter. (Required) Actions between the Loop and EndLoop statements will execute the number of times it takes to increment the counter variable from start to stop. |
Example: |
The following example reads and displays the first five lines of a file: Loop "1" "5" "[Counter]" |
Purpose: |
Exit the current Loop/EndLoop block. Execution continues with the Action following the next EndLoop statement. |
Category: |
Control |
Syntax: |
ExitLoop |
Example: |
Loop "1" "100" "[Count]" |
Purpose: |
Jump to a specific line number or label in the current Action script and continue execution from that point. |
Category: |
Control |
Syntax: |
GotoLine "label or line number" label or line number A line number or label name. A label is a descriptive word preceded by a colon “:” used to mark the beginning of a block of code. |
Example: |
:StartHere InputBox "Stop" "Please enter your password:" "[PWord]" If "[PWord]" "<>" "Charlie227" GotoLine "StartHere" EndIf |
Function library
Purpose: |
Execute a predefined script from the Function Library. |
Category: |
Control |
Syntax: |
Call "function name" "function parameters (optional)" function name The name of the function to execute. If the desired function is located in a sub folder then the folder's name must also be included. For example: "Math\InterestRate" function parameters If the function you select requires parameters those must be added here surrounded by quotes. For functions without parameters, only the function name is required. |
Example: |
Call "Save Bookmark" |
Subroutine Access
Purpose: |
Execute a section of the publication’s Subroutine Action. |
Category: |
Control |
Syntax: |
GoSub "subroutine name" subroutine name The name of the subroutine section to execute. |
Example: |
GoSub "SaveCustomerInfo" |
Purpose: |
Exit the current Action script or subroutine and return control to the previous one. |
Category: |
Control |
Syntax: |
Return |
Example: |
:MySubroutine |
Note: The Return Action is most often used with Subroutines.
Purpose: |
Execute a script from a string variable or external text file. |
Category: |
Control |
Syntax: |
PlayAction "commands" commands VisualNEO Win valid commands (one per line) or complete path to an external text file with commands. |
Example: |
PlayAction "Alertbox [#34]Message[#34] [#34]Hello world![#34]" |
Mouse Functions
Purpose: |
Move the mouse pointer. |
Category: |
Control |
Syntax: |
SetMousePos "x pos" "y pos" x pos, y pos The mouse pointer’s new left, top position relative to the upper left corner of the publication window. |
Example: |
SetMousePos "100" "150" |
Purpose: |
Get the position of the mouse pointer relative to the upper left corner of the publication window. |
Category: |
Control |
Syntax: |
GetMousePos "x var" "y var" min var The name of the variable to store the cursor’s X position. max var The name of the variable to store the cursor’s Y position. |
Example: |
GetMousePos "[X]" "[Y]" |
Purpose: |
Simulate a mouse button click. |
Category: |
Control |
Syntax: |
ClickMouse |
Example: |
The example below moves the mouse pointer and simulates a press of the left mouse button: SetMousePos "100" "150" |
Mathematical
Purpose: |
Perform a mathematical calculation. |
Category: |
Control |
Syntax: |
Math "formula" "decimal places" "variable" formula A mathematical formula. The formula can include the following operators and functions: +, -, *, /, ^, Abs, Sin, Cos, Atan, Sqr, Sqrt, Round, Trunc. Parentheses and variables may also be used in formulas. decimal places The number of decimal places to include in the result. Use 0 (zero) to round the result to the nearest whole number or -1 to have VisualNEO Win automatically determine the optimal number of decimal places variable The name of the variable to store the result. |
Example: |
In the example below, a variable [MonthlyRent] is used to calculate the amount of rent paid per week. [MonthlyRent] could be set using the SetVar Action, or associated with a Text Entry object to allow the user to enter a number. The result contains two decimal places (the second parameter), and is stored in the variable [WeeklyRent]. Math "([MonthlyRent]*12)/52" "2" "[WeeklyRent]" When using Math functions, such as Sin and Cos, you must enclose the portion of the formula to be evaluated by the function within parentheses. For example: Math "Cos(180)" "2" "[Result]" |
Note: Actions that expect numeric values can also accept formulas as parameters like those used by the Math Action.
Purpose: |
Generate a random number. |
Category: |
Control |
Syntax: |
Random "maximum value" "variable" maximum value The maximum possible value for the generated number. The number returned will be somewhere between 0 (zero) and maximum value. variable The name of the variable to store the random number. |
Example: |
The example below, uses the publication’s screen width and height to generate a random set of coordinates to display an image: Loop "1" "5" "[Counter]" |
Purpose: |
Convert a formatted date to a number that can be used in mathematical calculations. The result, a numeric date, represents the number of days since December 30, 1899. A numeric date can be converted back into a formatted date with the NumToDate Action. |
||||||||
Category: |
Control |
||||||||
Syntax: |
DateToNum "date" "format" "variable" date A formatted date consisting of two or three numbers, separated by “\”, “/” or “-”. Year values between 0 and 99 are assumed to be in the current century. The date must match the format parameter below. format A string that identifies the format of the date. For example:
variable The name of the variable to store the converted date number. |
||||||||
Example: |
The following example calculates the number of days since December 15th, 2004: DateToNum "12/15/2004" "m/d/y" "[StartDate]" |
Purpose: |
Convert a numeric date to a formatted date. Use in conjunction with DateToNum. |
||||||||||||||||||||||||||||
Category: |
Control |
||||||||||||||||||||||||||||
Syntax: |
NumToDate "number" "format" "variable" number An numeric date. (A numeric date represents the number of days since December 30, 1899, and can be created using the DateToNum Action.) format The format for the converted date. You can compose your own custom date display formats using codes from the table below:
For example, entering "d/m/yyy" will result in a date formatted as Day/Month/Year or "3/15/2008". Entering "dddd, mmmm m, yyyy" will result in a date formatted as "Saturday, March 15, 2008". variable The name of the variable to store the formatted date. |
||||||||||||||||||||||||||||
Example: |
NumToDate "38426" "m/d/yyyy" "[FormattedDate]" |
Miscellaneous
Purpose: |
Pause for a specified number of milliseconds. |
Category: |
Control |
Syntax: |
Delay "milliseconds" milliseconds Number of milliseconds to pause. A millisecond is one thousandth of a second. For a one second interval enter 1000 milliseconds. For one minute interval enter 60000 milliseconds. |
Example: |
Delay "2000" |
Purpose: |
Obtain information about the publication and the reader’s computer, including environment variables. |
Category: |
Control |
Syntax: |
SystemInfo "information type" "variable" Information type One of the following: CDRomDrive, CommandLine, CurrentDir, NetworkDrive, PubAuthor, PubColors, PubDir, PubDrive, PubHeight, PubTitle, PubWidth, ScreenBits, ScreenColors, ScreenHeight, ScreenWidth, SystemDir, TempDir, UserName, WinHandle, WindowsDir, WindowsPlatform, WindowsVer or a system environment variable surround by % characters. variable The name of the variable to store the information. |
Example: |
The following example compares the color resolution of the reader’s computer with the publication’s color resolution. If the computer’s resolution is lower that the publication’s a message is displayed. SystemInfo "ScreenColors" "[ScreenMode]" To obtain the contents of a system environment variable, replace information type with the name of the variable surrounded by % characters. For example: SystemInfo "%PATH%" "[Result]" The SystemInfo Action is somewhat obsolete since the information types are also Global Variables an can be referenced directly. For example, the script above could be rewritten like this: If "[PubColors]" ">" "[ScreenColors]" The SystemInfo Action is still available for use with environment variables and to provide backward compatibility with publications created with earlier versions of VisualNEO Win. |
Purpose: |
Temporarily suspend processing of mouse and keyboard messages. This can be useful when you want a series of commands to finish executing before allowing the reader to click on another button. Also very useful for complex mouse enter/exit Actions. |
Category: |
Control |
Syntax: |
Suspend "state" state Use “True” to disable message processing or “False” to re-enable message processing. If you forget to re-enable the suspend state, it will be done automatically when the current script is completed. By default, VisualNEO Win will automatically remove mouse and keyboard events from the Windows buffer when Suspend is turned off. If you prefer to leave these events in the buffer for processing by VisualNEO Win, you can add the keyword NoBuffer when state is False. For example: "False+NoBuffer" |
Example: |
The following example disables message processing until a series of Actions have completed: Suspend "True" |
Note: Be careful when using Suspend with Loop or While Actions. If message processing is suspended prior to entering the Loop or While statement, readers may not be able to interact with your publication until message processing is re-enabled or the loop is complete.
Purpose: |
Turn the display of error messages on or off. |
Category: |
Control |
Syntax: |
ShowErrors "state" state Use “True” to turn the display of error messages on, or “False” to handle errors yourself. The most recent error will be stored in the [LastError] variable. |
Example: |
ShowErrors "False" |
Purpose: |
Load a new application or tray icon. Leave the icon file field blank to restore the publication's original icon (specified in App Properties). |
||||
Category: |
Control |
||||
Syntax: |
LoadIcon "file name" "which icon" file name A Windows format icon (ico) file. which icon One of the following:
|
||||
Example: |
LoadIcon "C:\Samples\Busy.ico" "MainIcon" |
Debug
Purpose: |
Pause execution of the current script and display an optional message. This Action only works in test mode and is ignored by compiled publications. |
Category: |
Control |
Syntax: |
DebugBreakPoint "message" message The dialog box message. Line breaks can be entered using the pipe character “|”. |
Example: |
DebugBreakPoint "Execution paused." |