Shortcut Script Syntax

Shortcut script uses Enhanced BASIC as a language since it is very easy to learn and understand. All commands and functions are not case-sensitive.

Tabs / Indentations

You can include as many tabs or indentations as you like in front of a line. In fact, we recommend that you add some indentations when a group of codes belong to a loop (FOR..ENDFOR) or a logical condition (IF THEN / ELSE / ENDIF). Indentation helps make the codes more readable, thus, reducing the chance of coding errors.

Example:

'-- Simple counting code
Count = 0
FOR i = 1 TO LENGTH(DATE(4))
Count = Count + 1
PRINT Count
ENDFOR

'-- Retrieve the year
Year = MID(DATE(4), 7, 4)
IF Year > 2000 THEN
PRINT "We have survived year 2000."
ELSE
PRINT "Year 2000 is approaching."
ENDIF

Comments

To make a line a comment, simply place ' in front of that line. Shortcut ignores any line that begins with '. Therefore, you can put as many comment lines as needed to clarify your codes.

Example:

'-- Ask for customer name
INPUT "Customer Name ?", CustName
'-- Display it to the user
PRINT "The current customer name is " + CustName + "."

Variables

Variables can be declared anywhere. The name of a variable can be as long as you like. Each variable can store different type of data such as text or number. Once a variable is declared with a value, you can then make a reference to it any often as you like within the script.

Example:

'-- Let's say that I am 25
MyAge = 25

'-- Ask for name
INPUT "What is your name?", YourName
'-- Ask for age
INPUT "What is your age?", YourAge

'-- Find out if you are older, younger or the same.
'-- and display the appropriate message.
IF YourAge > MyAge THEN
PRINT "Your are Older than me, " + YourName
ELSE
IF YourAge < MyAge THEN
PRINT "Your are Younger than me, " + YourName
ELSE
PRINT "We are in the same age, " + YourName
ENDIF
ENDIF

Array Variable

Array Variable can be instantiate anywhere without having to declare them first. Array variable begins with the variable name followed by [n1, n2, .. ]. n1, n2, .. are indexes of the array elements. Multi-dimension array is created by cascading the array element indexes with , separation, for instance, Names[1, 1, 1]. You can have as many dimensions as you want.

Example:

n = "John"
x = 1

'-- Ask for student name and age
WHILE n <> ""
INPUT "Enter student #" + Trim(x) + " Name (leave blank to end)", n
IF n = "" THEN
EXIT WHILE
ENDIF
INPUT "Enter his/her age", age
Students[x, 1] = n
Students[x, 2] = age
x = x + 1
ENDWHILE

'-- Display them back
x = 1
WHILE TRIM((Students[x, 1]) <> ""
PRINT "Student #1: Name=" + Students[x, 1] + ", Age=" + Students[x, 2]
x = x + 1
ENDWHILE

Commands

Shortcut provides many commands that you can be used to automate almost anything. A command is placed at the beginning of a line and it's often followed by some parameters.

Example:

'-- Display Hello, World Message
PRINT "Hello, World."

'-- Call another script
CALL "c:\shortcut\scripts\test.fbs"

'--
PAUSE for 5 seconds
PAUSE 5

Functions

Functions are similar to Commands, however, it does not have to be placed at the beginning of line and it can return value. You can assign a variable to it for later retrieval. Functions are always followed by ( ).

Example:

'-- Display todays date in 4-digit year format
PRINT "Today's date is: " + DATE(4)

'-- Assign todays date to a variable
TodayDate = DATE(4)
'-- Display the date using variable
PRINT "Today's date is: " + TodayDate

User-Define Subroutines

SUB getname()
.......
ENDSUB
and
FUNC getname()
.......
ENDFUNC

Subroutine and functions allows script to be broken down to customizable modules. This provide a greater manageability and portability. (See
FUNC and FUNC..ENDFUNC).

Labels

<Label Name>:
Labels are used for controlling the flow of the scripts. Label name must not begin with a numerical character(0..9). It must not contain any spaces. After the label name there must be :.
Once the label is defined, you can then use GOTO or GOSUB command to jump to that label. This provide s you with a way to conditionally jump to a different part of the script. Note that when you want to reference a label, you don't need to put : at the end of the label name (see example below).

Example:

'-- Loop 10 times then exit
x = 1
Loop1:
x = x + 1
IF x >= 10 THEN
GOTO EndOfLoop
ENDIF
GOTO Loop1

EndOfLoop:
PRINT "Finish with the loop."

See Also

Commands and Functions