N Code Statements
Home ] Up ] N Code Execution Model ] N Code Language ] N Code Data Types ] N Code Expressions ] [ N Code Statements ] N Code Variables and Scoping Rules ] N Code Filters ] N Code Function Definition ] N Code Tools ] N Code Triggers ]


N Code Statements

assignment

ident = expr ;

block

{ statement list }

break

break ;

The break exits a while or foreach iterator.

declare

declare ident inside expression ;

The expression must evaluate to a map type.

expression

expr ;

foreach

foreach $ident inside ( expression ) statement

Iteration only takes place when the expression's type is list. The local variable identified by 'ident' is set to the value of each list element in turn, and the statement is evaluated.

Example:

list = [ "a", 1, 2, 3, "bcd" ];
func test {
echo ( "list:", list, " includes members : " );
some = 0;
foreach $a inside (list) {
if (some) {
echo( " .and. " );
}
echo( $a );
some = 1;
}
echo( "\nanymore?\n" );
}
test();

Generates

list:[a,1,2,3,bcd] includes members : a .and. 1 .and. 2 .and. 3 . and. Bcd anymore?

if

if condition statement ; if condition statement else statement ;

on

Syntax: on `trigger' call name; When the trigger event occurs, call the function or filter that is named as the target identifier. Example: on udp() call gotAUdpPacket; The syntax of the trigger clause is the same as the trigger clause used in the filter declaration. Additionally, you can save the value of the trigger cookie by using:

on saveCookie = udp() call gotAUdpPacket;

The cookie associated with the created udp trigger is saved into the variable `saveCookie', which can be `off'd to delete that same trigger.

off

Syntax: off `cookie'; Remove the trigger described by the value of the cookie. Any further actions directed by the trigger will be disabled.

record

record expression_list to ident ;

while

The while iterator tests a condition before executing the statement. When the condition fails, the loop is exited.

Example:

func test {
$x = 1;
break;
while ( $x < 20 ) {
echo ( $x, "\n" );
$x = $x + 1;
}
echo ( "this test is now concluded. value of $x is ", $x, "\n" );
}
test();

Generates:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
this test is now concluded. value of $x is 20

Back ] Home ] Up ] Next ]