Conditional

If

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:


=

First item is equal to second item.

<

First item is less than second item.

>

First item is greater than second item.

<>

First item is not equal to second item.

<=

First item is less than or equal to second item.

>=

First item is greater than or equal to second item.

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]" "=" ""
  AlertBox "Error!" "I don’t know your name."
Else
  GotoNextPage
EndIf


You can also use If to detect the correct entry of a password:


If "[Password]" "=" "Bravo172"
  GotoNextPage
Else
  AlertBox "Error!" "The password is incorrect."
EndIf


IfEx

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:


=

First item is equal to second item.

<

First item is less than second item.

>

First item is greater than second item.

<>

First item is not equal to second item.

<=

First item is less than or equal to second item.

>=

First item is greater than or equal to second item.


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 for Windows 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"
  GotoPage “Welcome”
Else
  AlertBox "Error!" "The account is incorrect."
EndIf


While

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:


=

First item is equal to second item.

<

First item is less than second item.

>

First item is greater than second item.

<>

First item is not equal to second item.

<=

First item is less than or equal to second item.

>=

First item is greater than or equal to second item.

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"
SetVar "[Freq]" "0"
While "[Count]" "<" "100"
  Math "[Count]+1" "0" "[Count]"
  Math "[Freq]+25" "0" "[Freq]"
  PlayTone "[Freq]"
EndWhile


WhileEx

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


ExitWhile

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]" ""
While "[Name]" "=" ""
  InputBox "Welcome" "Enter your name:" "[Name]"
  If "[Name]" "=" "Administrator"
    GotoPage "Setup"
    ExitWhile
  EndIf
EndWhile


Loop

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]"
  FileRead "Products.dat" "[Counter]" "[Data]"   
  AlertBox "Products" "[Data]"
EndLoop


ExitLoop

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]"
  Random "100" "[R]"
  If "[R]" ">" "75"
    ExitLoop
  EndIf
EndLoop


GotoLine

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

Call

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

GoSub

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"


Return

Purpose:

Exit the current Action script or subroutine and return control to the previous one.

Category:

Control

Syntax:

Return

Example:

:MySubroutine
  AlertBox "Hello" "This is a subroutine"
Return


Note: The Return Action is most often used with Subroutines.



Mouse Functions

SetMousePos

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"


GetMousePos

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]"


ClickMouse

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"
ClickMouse



Mathematical

Math

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 for Windows 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.


Random

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]"
  Random "[PubWidth]" "[X]"
  Random "[PubHeight]" "[Y]"
  PopUpImage "[X]" "[Y]" "c:\flower.bmp" "2000" "Dissolve" "3"
EndLoop


DateToNum

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:


m/d/y

Month/Day/Year

d/m/y

Day/Month/Year

y/m/d

Year/Month/Day

Default

Use the system’s default date format.

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]"
DateToNum "[DateShort]" "Default" "[Today]"
Math "[Today]-[StartDate]" "0" "[Result]"
AlertBox "Answer" "It has been [Result] days since 12/15/2004"


NumToDate

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:


d

Show the day as a number without a leading zero (1-31).

dd

Show the day as a number with a leading zero (01-31).

ddd

Display the day as an abbreviation (Sun-Sat).

dddd

Display the day as a full name (Sunday-Saturday).

ddddd

Display the date using the system short date format as defined in the Windows Control Panel.

dddddd

Display the date using the system long date format as defined in the Windows Control Panel.

m

Show the month as a number without a leading zero (1-12).

mm

Show the month as a number with a leading zero (01-12).

mmm

Display the month as an abbreviation (Jan-Dec).

mmmm

Display the month as a full name (January-December).

yy

Show the year as a two-digit number (00-99).

yyyy

Show the year as a four-digit number (0000-9999).

/

Display the date separator character as defined in the Windows Control Panel.

Default

Use the system’s default short date format. (Same as ddddd above.)


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

Delay

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"


SystemInfo

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]"
SystemInfo "PubColors" "[PubMode]"
If "[PubMode]" ">" "[ScreenMode]"
  AlertBox "Notice!" "This pub requires [PubMode] colors."
EndIf


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]"
  AlertBox "Notice!" "This pub requires [PubColors] colors."
EndIf


The SystemInfo Action is still available for use with environment variables and to provide backward compatibility with publications created with earlier versions of VisualNEO for Windows.


Suspend

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 for Windows 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 for Windows, 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"
ShowObject "Picture1" "Dissolve" "5"
ShowObject "Picture2" "Dissolve" "5"
ShowObject "PushButton1" "Dissolve" "5"
Suspend "False"


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.


ShowErrors

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"
FileRead "config.dat" "1" "[regkey]"
If "[LastError]" ">" ""
  AlertBox "Error" "Configuration invalid."
EndIf
ShowErrors "True"


LoadIcon

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:


MainIcon

Replace the publication’s main icon.

TrayIcon

Replace the publication’s system tray icon. This is only valid for System Tray Applications.


Example:

LoadIcon "C:\Samples\Busy.ico" "MainIcon"



Debug

DebugBreakPoint

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