 |
Online Help System
|
 |
Back to Brilliant Database Web-Site |
Write to Support |
Help Index
Cycles
Introduction
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 database software records stored
in the database software recordset variable at once or print individual
lines from a text.
A cycle always begins with the For...
string. To identify the end of a cycle body, type Next Item:
Lines between the For (2)
and Next (4) lines make the cycle
body.
In this example, the cycle body contains only one line (3).
This program uses cycles of three types that differ by
the cycle subject:
For Interval (1,2,3...)
This cycle type changes the value of a specified
variable in a specified range with a specified step
and performs enclosed commands. Example:
In this example, the [$i] variable
changes its value from 2 to 20
with step 2.
For each of these values, the program will perform the
commands contained in line (3), and the user will see 10
messages with the following text:
- Variable Value: 2
- Variable Value: 4
- Variable Value: 6
- Variable Value: 8
- ...
- Variable Value: 20
For each line from text
This cycle type splits text to lines, and performs the
enclosed actions over each line.
Example:
In this example:
- Line 1: Write the list of three
cities in the [$cities] variable.
- Lines 2, 5: Define the cycle,
in which the [$line] variable will
consecutively contain a value from the list. In our
case, that's the list of cities contained in the [$cities]
variable.
- Lines 3, 4: Cycle body.
Line 3 creates a new database software record,
and line 4 writes the city name to
the Title field of the database software record.
Thus, upon completion of
this script, we will have 3
database software records with titles respectively London, Paris, and
Moscow.
Any data source can be used with this cycle -
data from file (see Read File),
field values from DB database software records, etc.
For Each database software record from database software recordset
This cycle type allows
performing operations over a set of database software records in a
database.
The database software records are defined in the database software recordset
variable that can be created with a query, relational field, etc.
Learn more about database software recordsets...
In this example:
- Line 1: Places the set of
database software records created by the All Records query to the [$rset]
variable.
- Lines 2, 4:
Define the cycle, in which all operations will apply to
database software records stored in the [$rset] variable instead
of the current database software record.
- Line 3:
Cycle body. Increments the value of [Field A]
by one.
See Also:
Scripts Basics
Script Designer
Using Variables
User Functions
Action Editor
List of actions
|