About    Download    Order    Support


InnPlanner Reservation Software Videos

About
Download
Order/Prices
Support/Contact
Partner Program
Press Room
Online Help


Recent News

InnPlanner 2010 Released
New faster database engine, more customization features, weekly tariffs, full multi-user work support and much more...

2010 Feb 10

InnPlanner 2010 RC1
InnPlanner 2010 Release Candidate 1 is ready for downloading and testing. You can download it from the "Downloads" section.

2010 Jan 14


Hotel Software Documentation

Scripting Basics

Scripting Basics

Introduction

Using Script you can create a small program that will be executed in response to certain actions (pressing a button, changing field value, etc.).

This chapter describes the basics of scripting and script creation.

To learn more abut the actual script editor, please see the chapter Script Designer

Script Elements

As an example we'll take the following script:

Each script has one or several instruction lines (in our example it has 12 lines). The program executes the commands downwards (starting from the first line to the last one). The program can skip lines if the condition of the If statement (lines 4, 10) is not fulfilled. It also can go to the specified line if it executes the Go To statement (line 6).

Thus, you can use the following lines in any script:

Actions

An action defines one action, such as creating a new record or changing a field value. To add an action to the script, use the Add Action button. Actions can contain different parameters specified in brackets after the name of the action. Beside standard actions you can also execute User Functions - a script you create beforehand. Learn more about User Functions...

Some actions can record their result to a selected variable. For example, the "Import From a Database" action returns the number of imported records.

In the illustration above they are represented by the following lines:

  • 5 - show message. The message text and message box title are specified as parameters.
  • 8 - increase the value of the [Order Total] field of current record.
  • 11 - print a record. The parameters specify whether the preview window should be opened, what records should be printed and what report style should be used.

The action is specified by means of the Action Editor, that contains a description of parameters and convenient tools you can use to enter them. View list of actions

Variables

Variables are used to store information. They have the following structure: [$VarName] For example, in this script the program:

  • first initializes the [$quantity] variable by means of the "User Input" field (line 3);
  • checks the value of this variable (line 4);
  • uses the value of this variable in the formula to change the value of the record field (line 8).

Some actions can also record their result to specified variables. For example, the Add Record action records 1 to the variable if the record was added and 0 (null) if the record wasn't added:

For more details about variables see the Using Variables section.

If Statements

Conditional statements are used for carrying out actions only when some condition is true. For example, in the illustration above there are two conditional statements: one checks the variable quantity (line 4), the other one asks for the user's confirmation (line 10) and carries out action (line 11)only if the reply is affirmative. The following statements are available in the current version:

  • If Rule... then - the statement checks whether the ruleset is true. If a record type is specified it also allows to check fields of the current record. Know more about rules.
  • If Confirm(...) then - the statement displays the message with the specified text and Yes and No buttons, and proceeds to carrying out the action if option Yes has been selected. See line 8 in the illustration.
  • Else - this statement can be used only together with the if statement and displays a list of actions to be carried out if the condition of the if statement is false. See line 7 in the illustration.
  • Else If Rule... then - in contrast to else, the list of actions following the statement will be carried out only if the rule specified for this record and all the preceding if statements are satisfied.
  • End If - this statement closes the action of the If statement. See lines 9, 12 in the illustration.

    Double-click the End If line to fold the If...End IF section to a single line. This feature is convenient when you work with large scripts:

Note. Conditional statements can have several nesting levels. Statements Else, Else If and End If are used only together with the if statement on the same nesting level. In the designer nesting levels are marked by the left margin.

In the designer conditional statements are highlighted blue.

To add a conditional statement, click the button Add If/Else...

Cycles (For Each ... Next)

Cycles (loops) allow performing the same actions (cycle body) over different objects or under different conditions. For example, you can calculate the total of numbers 1 through 100, perform operations over several records stored in the recordset variable at once or print individual lines from a text.

For example, the following script will increase the value of [Field A] by one for all records received from the "All Records" query:

Learn more about cycles...

Go To Label

Use the Go To statement to execute a specific part of the script marked with a label.

In our example, if the condition in line 4 is not satisfied the program will go to the specified begin line (line 2) according to the Go To statement (line 6).

To add a Go To or Label, click the button Add Go To...

In the designer Go To and Labels are highlighted green with icons , .

Comments

Comments do not affect script operation in any way. Their purpose is to provide the script with additional information, such as a brief description of the script operation or the last modification date.

To add a comment line, press the button Add Comments.

In the text comments are highlighted green on a grey background. See line 1 in the illustration.

See Also:

Script Designer

Using Variables

User Functions

Action Editor

List of actions




Today"s Poll

What software do use for your inn/b&b/hotel/etc?

Do not use
Inn Planner
Access, Excel
ASSD
Auberge
Digitalrez
Easy Inn Keeping
EnSuite HR
GuestMaster
iMagic HR
Smart FX
Other