The following chapters contain an alphabetical listing of all Empress GUI Builder script statements and functions. Each entry contains:
call |
|||||
| Description | Call an action or an Empress GUI Builder function | ||||
| Syntax |
call funcname ([expr {, expr}]);
where:
|
||||
| Notes |
|
||||
| Example | To call a script action named menu which does not take any
parameters, use the command:
call menu ();To call the GUI function which displays a message: call empgui_dialog_info ("message", "Hello world!");
|
||||
call application |
|||||
| Description | Call an Empress GUI Builder application. | ||||
| Syntax |
call application appl_name ([expr {, expr}]);
where:
|
||||
| Notes |
|
||||
| Returns | None. | ||||
| Example | To call an application name test, use the command:
call application "test"();If application test2 has two parameters, and the arguments passed to it are strings containing spaces: call application "test2" ("'first arg'", "'second arg'");
This would be equivalent to executing the following command from the UNIX
shell:
empgui mydb test2 'first arg' 'second arg' |
||||
check |
|||||
| Description | Check whether the result of an expression is a valid value for the attribute. | ||||
| Syntax |
check expr for attr;where:
|
||||
| Notes |
|
||||
| Returns | None. | ||||
| Example | To verify that the data keyed into the field name in window
names is a valid entry for the attribute name in nametable,
use:
check "names"@"name" for "nametable"."name"; |
||||
close |
|||
| Description | Remove the given cursor. | ||
| Syntax |
close cursor_name;where:
|
||
| Notes |
|
||
| Returns | None. | ||
| See Also | open, declare, undeclare | ||
| Example | To close the cursor namesakes, use:
close "namesakes"; |
||
close table |
|||
| Description | Close one or more table instances. | ||
| Syntax |
close table tabinst {, tabinst};
where:
|
||
| Notes |
|
||
| Returns | None. | ||
| See Also | open table | ||
| Example | To close the table nametable, use:
close table "nametable"; |
||
commit |
|
| Description | Commit the current transaction. |
| Syntax |
commit [transaction]; |
| Notes |
|
| Returns | None. |
| See Also | start transaction, rollback, savepoint |
| Example | To commit the current transaction, use:
commit transaction; |
declare |
|||||
| Description | Declare a cursor, associating it with a select statement | ||||
| Syntax |
declare cursor_name cursor for query [ with count ];where:
| all | | * | from tab_inst [[alias] aliasname] {, tab_inst [[alias] aliasname]} [where_clause] [group_clause [having_clause]] [sort_clause] |
||||
| Notes |
|
||||
| See Also | undeclare, open, close | ||||
| Example | declare "c1" cursor for
select name, dept, salary, avg(salary) print "average" from staff where "staff"."name" match "win"@"name" group by "staff"."dept" with count; The cursor c1 defines a query to retrieve records from table instance staff. Only records where attribute name matches the pattern in field name will be selected, but if field name is NULL, all records will be selected. The value of the aggregate expression can later be accessed using one of these forms: "c1"."expression_1" "c1"."average" "c1".iwhere i is an integer with the value 4. |
||||
delete |
|||
| Description | Delete a record. | ||
| Syntax |
delete from tabinst;where:
|
||
| Notes |
|
||
| Returns | None. | ||
| Example | To delete a record in nametable, use:
delete from "nametable"; |
||
disable |
|||
| Description | Disable access to the current record within a given cursor. | ||
| Syntax |
disable cursor;where:
|
||
| Notes |
|
||
| Returns | None. | ||
| See Also | enable | ||
| Example | To disable any update or delete operations on namesakes, use:
disable "namesakes"; |
||
enable |
|||
| Description | Enable access to the current record of a cursor. | ||
| Syntax |
enable cursor;where:
|
||
| Notes |
|
||
| Returns | None. | ||
| See Also | disable, fetch | ||
| Example | To enable the cursor namesakes, use:
enable "namesakes"; |
||
exit |
|
| Description | Stop execution of a script or a module. |
| Syntax | exit[ | confirm | ];
| script | |
| Notes |
|
| Returns | None. |
| Example | To exit the current module, use:
exit;To stop execution in the current script action but not exit the current application, use: exit script; |
fetch |
|||||
| Description | Retrieve a row in a cursor | ||||
| Syntax | fetch [ [| next | ] from ] cursor_name;
| prior | | first | | last | |relative n| where:
|
||||
| Notes |
|
||||
| See Also | open, fetch group, disable | ||||
| Example | Fetching the next row in the cursor. If the row was locked, attempt
to retrieve it again. If the previous row was the last row, display a message.
fetch next from "c1";
|
||||
fetch group |
|||||
| Description | Retrieve a group of rows in a cursor | ||||
| Syntax | fetch group [ [| next | ] from ] cursor_name;
| prior | | first | | last | |relative n| where:
|
||||
| Notes |
|
||||
| See Also | declare, open, fetch | ||||
| Example | Fetching the next group in the cursor. If the previous group was the
last group, display a message, otherwise update the display.
fetch group next from "c1";
|
||||
global |
|||||
| Description | Declare variable to be global in scope. | ||||
| Syntax |
global type variable {; type variable} ; end;
where:
|
||||
| Notes |
|
||||
| Returns | None. | ||||
| See Also | parameters, local | ||||
| Example | To define variables name and age array and variable
children so that they will be known throughout the application,
do the following in the global script:
global
|
||||
if |
|||||||||||||||||||||||||||||||||||||||||||||||
| Description | Choose one of two branches of statements based on the evaluation of a condition. | ||||||||||||||||||||||||||||||||||||||||||||||
| Syntax | if condition [then]
{statement;} [|else{statement;}|] |elseif_clause | end; where elseif_clause has the format: elseif condition [then]
and condition may be one of the following: TRUE
exprrange value[|exclusive|]to value[|exclusive|]
expr |= | expr
where:
|
||||||||||||||||||||||||||||||||||||||||||||||
| Notes |
|
||||||||||||||||||||||||||||||||||||||||||||||
| Returns | None. | ||||||||||||||||||||||||||||||||||||||||||||||
| Example 1 | Suppose you are writing an exit action for the field name
in the window names. If you want to be able to leave the application
by typing stop in the name field, you could use this
statement:
if "names"@"name" = "stop" then
|
||||||||||||||||||||||||||||||||||||||||||||||
| Example 2 | Extending the above example, suppose you wish to take the following
actions in the exit action for the name field:
if "names"@"name" = null then
|
||||||||||||||||||||||||||||||||||||||||||||||
insert |
|||
| Description | Insert a record into a table | ||
| Syntax |
insert into tab_inst;where:
|
||
| Notes |
|
||
| See Also | open table, fetch, disable | ||
| Example | The attributes in table instance staff are assigned values
from objects in window n, and a new record is inserted into the
table:
let "staff"."name" = "win"@"name_field";
|
||
let |
|||
| Description | Assign a value to a variable. | ||
| Syntax | let variable =|expr |;
|NULL | |TRUE | |FALSE| where:
|
||
| Notes |
|
||
| Returns | None. | ||
| Example | To assign the value of the attribute nametable.address to
the field names@address, use:
let "names"@"address" = "nametable"."address";To place the values of attribute nametable.name for several records into an array names. let i = 0;
|
||
local |
|||||
| Description | Declare a variable to be local in scope. | ||||
| Syntax |
local type variable {; type variable} ; end;
where:
|
||||
| Notes |
|
||||
| Returns | None. | ||||
| See Also | parameter, global | ||||
| Example | To declare variables name and age and array children
so that they will be known only in the script where they are declared,
use:
local
|
||||
lock |
|||
| Description | Apply locking to the specified table. | ||
| Syntax | lock table [in]|exclusive| [mode];
|share | where:
|
||
| Notes |
|
||
| Returns | None. | ||
| Example | To lock the table nametable in exclusive mode during a transaction,
type:
lock "nametable" in exclusive mode; |
||
on |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description | Trap exception conditions and determine how the system responds to them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Syntax | on || event | [num
{, num }] | | call function(..) |;
|| warning | | | display | || database error| | | ignore | | error | where:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Note |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
open |
|||
| Description | Open a cursor to select records. | ||
| Syntax |
open cursor_name;where:
|
||
| Notes |
|
||
| Returns | None. | ||
| See Also | declare, cursor, undeclare | ||
| Example | Given the declare command:
declare "namesakes" cursor for select from "nametable" where "nametable"."name" = "names"@"name";You can initialize the cursor with records using: open "namesakes"; |
||
open table |
|||||
| Description | Open database tables for access. | ||||
| Syntax | open table tablename |read | [as tabinst
{, tabinst}]
|update | |deferred| where:
|
||||
| Notes |
|
||||
| Returns | None. | ||||
| See Also | close table | ||||
| Example | To open the table nametable in update mode, use:
open table "nametable" update;The table instance name becomes nametable by default since no tabinst was specified. On the other hand: open table "nametable" update as "exampletable";opens the table to the name exampletable. Any references to this table will then be to exampletable. For instance, the attribute name of the Empress table nametable would be known in the application as "exampletable"."name". |
||||
parameters |
|||||
| Description | Declare variables to receive values passed to a script. | ||||
| Syntax |
parameters type variable {; type variable} ; end;
where:
|
||||
| Notes |
|
||||
| Returns | None. | ||||
| Example | Suppose you have an action family which begins by defining
parameters name, age, and children:
parameters
You could then execute the statements: let offsprings[1] = "Jimmy";
The family script action would be invoked, the name parameter would have the value John, the age parameter the value 30, and children would be an array of three elements containing values Jimmy, Betsy and Lilian. |
||||
return |
|||
| Description | Cause an immediate return from a script action. | ||
| Syntax |
return [expr];where:
|
||
| Notes |
|
||
| Returns | None. | ||
| Example | A script that computes a value called result could return
the result with the statement:
return result;If the action is named calculation, and accepts two arguments, then it would be invoked as in: let store_result = calculation (argument1, argument2);Here, the arguments are the contents of argument1 and argument2, and the returned result is stored in the variable store_result. |
||
rollback |
|
| Description | Roll back a transaction. |
| Syntax | |rollback|[transaction] [to savepoint];
|cancel | |
| Notes |
|
| Returns | None. |
| See Also | commit, savepoint, start transaction |
| Example | The following group of statements rolls back the transaction to the
save point t1.
start transaction; ... savepoint t1; ... rollback transaction to t1;This returns the database(s) to the state immediately following the setting of the save point. |
savepoint |
|||
| Description | Set a save point in a transaction. | ||
| Syntax |
savepoint savepoint;where:
|
||
| Notes |
|
||
| Returns | None. | ||
| See Also | start transaction, commit, rollback | ||
| Example | The following sequence starts a transaction, sets a save point, then
rolls back. The operations up to the save point are then committed.
start transaction; ... savepoint t1; ... rollback transaction to t1; commit transaction; |
||
start transaction |
|
| Description | Start a transaction. |
| Syntax | start transaction; |
| Notes |
|
| Returns | None. |
| See Also | commit, rollback, savepoint |
| Example | The following sequence starts a transaction, then sets a savepoint
which is later rolled back. The operations up to the save point are then
committed.
start transaction; ... savepoint t1; ... rollback transaction to t1; commit transaction; |
switch |
|||||||
| Description | Test whether an expression matches one of a number of constants and branch accordingly. | ||||||
| Syntax | switch expr
{ case constant {, constant}: {statement;} } [ default: {statement;} ] end; where:
|
||||||
| Notes |
|
||||||
| Returns | None. | ||||||
| Example | In this example, the variable name is set to the selected
toggle button in a radio box. After printing the message, control leaves
the case statement.
let name = "window1"@"radiobox";
|
||||||
undeclare |
|||
| Description | Remove a cursor created by declare. | ||
| Syntax |
undeclare cursor_name;where:
|
||
| Notes |
|
||
| Returns | None. | ||
| See Also | declare, open, close | ||
| Example | To disable the cursor namesakes, use:
undeclare "namesakes"; |
||
update |
|||
| Description | Update the current record in a table. | ||
| Syntax |
update tab_inst;where:
|
||
| Notes |
|
||
| See Also | open table | ||
| Example | The attribute salary in table instance staff is assigned
a value and the current record in the table is updated:
let "staff"."salary" = "win"@"salary_scale";
|
||
while |
|||||
| Description | Repeatedly execute one or more statements while a condition is true. | ||||
| Syntax |
while condition {statement;} end;
where:
|
||||
| Notes |
|
||||
| Returns | None. | ||||
| Example | A script that counts from one to a hundred is:
let number = 1;
|
||||