| Home News Product Order Forum Feedback Partner Profile | © Neatware 2000 |
| Neatware | Snaml |
|
Control |
|
|
Last Update: Wed Apr 12 20:00:18 2000 |
|
Snaml Basic
Introduction Syntax Control Types Modules Status Snaml HTML HTML Structure Link Objects Text Font Snaml CSS CSS Script Snaml CGI CGI Variables Output Form Application Snaml XML XML Document EBNF |
set command assigns a value to a variable. Its first argument is a variable and its second argument is an expression. You can use a variable anywhere without declare its type. A variable with dollar sign $ returns its value
The first argument of incr command is a variable name. The second optional argument is increment integer. incr command increases (decreases) variable value by increment. The default value of increment is 1.
expr command evaluates a math expression with C expression syntax. It concatenates all the arguments to form a input string. The expression may be integer, floating point, and boolean. The return value is a numeric string. Many basic math functions in the standard C math library have been built in.
comment in the Snaml starts with # in the start of a line. You'd better use comment # as a command. There are some quirks prohibited you from writing comment anywhere. (i.e. no inside the switch command.
_quote command outputs its argument string to a IO channel. The IO channel is defined by __output command. It maybe a file or stdout. It is a special start command with only one argument and no tags.
if command will execute truebody when the expression is true, otherwise it will execute elsebody. Its body is a group of commands. The else and elseif keyword are optional for if command. Following codes are several forms of if command
The syntax of switch command is:
switch command compares a value with patterns. If one of them is matched then program executes the related body. The first argument of the switch command is an option. The '-exact' attribute will match the value to the pattern exactly; '-glob' attribute will use glob pattern matching; and '-regexp' will match with regular expression pattern. '--' represents the end of the option. The last pattern 'default' will execute its body if no patterns are matched before.
In the following example, since pattern and body pairs are grouped into an argument, there is no substitution inside the pattern/body pairs.
following example can substitute its patterns
foreach command repeatly executes its body until all the elements in a list have been traversed. Its form is,
The var is the current loop variable that is assigned an element from the alist one after another. foreach will traverse all the elements in the alist. This command is a compact expression of iteration.
You can declare two or more loop variables. The variables will orderly sample the elements in the list until all of them are traversed. Following example shows that varaiable (v1 v2) pair is assigned the value (a b) respectively, and then the value (c d), and so on.
To loop over multiple lists, you may organize arguments in var/list pair order. The variable var may also be multiple variables. A loop variable will be set to empty {} when its list has finished traverse but the entire loop did not terminated.
while command evaluates the expression, if it is true then executes the body, and then evaluates the expression again until the expression is not true. Its syntax is like while statement of C language.
An example of while command is,
The for command syntax is,
At first it evaluates the initail argument and then evaluates the expression. If the expression is true it executes the body and increment. Repeatlly, it evaluates the expression again and continues the loop until expression returns a false value.
return command comes back from a procedure with a value; break command exits from a loop; and continue command will goto the start of a loop to execute the next iteration.
catch command caught the exceptions of a command during its execution. Its syntax is,
catch command sets trap to the command in the curly braces. When there is an exception during the command execution, the exception message is assigned to the variable 'result', otherwise the 'result' gets the return value of the command. catch command returns zero when no exception is raised, otherwise returns non-zero.
error command generates an error code. Its first argument is a string that indicates the reason of an error
|
|
|
|
Last Update: Wed Apr 12 20:00:18 2000 |
|
Control |
| Neatware | Snaml |
| Home News Product Order Forum Feedback Partner Profile | © Neatware 2000 |