SQeeL program is basically consists of statements and is constructed with the combination of statements.
There are several types of statements.
Declaration defines variables, fixed values, and functions.
Since declaration only defines variables and functions, SQeeL ignores the declaration while executing a program.
* For more information about the scope of variables declared in the declaration, see [3. Syntax - Variable Scope] .

local
Defines local variable.
Local variable can be available in a function only.
Local variable should be defined in a row that comes after the local statements.
If you want to define multiple local variables, separate the variables by comma.
local variable [, variable 2, ...]
| local statement |
| local a |
Declares a variable a. |
| local a, b |
Declares multiple variables. |
You can set the initial value at declaration.
Literals, arrays, and fixed values defined in const statements are available.
Function calls, expressions, and variables are not available.
Four fundamental operators (+, -, *, /) are allowed as an exception.
local variable = initial value
| Initialization of local variable |
| local var = 'abcdefg' |
|
| local var = {1,2,3,4,5} |
|
| local var = 123 |
|
| local var = const1 |
Error if const1 is not a fixed value. |
| local var = a * 12 |
Error because a variable a is used. |

global
Declares a global variable.
If you want to define multiple variables, separate the variables by comma.
global variable [, variable 2, ...]
| global statement |
| global a |
Declares a variable a |
| global a, b |
Declares multiple variables. |
Global statement can be accessed from any location of a source file.
You can set the initial value at declaration.
Literals, arrays, and fixed values defined in const statement are available.
Function calls, expressions, and variables are not available.
Four fundamental operators (+, -, *, /) are allowed as an exception.
global variable = initial value
| Initialization of global variable |
| global var = 'abcdefg' |
|
| global var = {1,2,3,4,5} |
|
| global var = 123 |
|
| global var = const1 |
Error if const1 is not a fixed value. |
| global var = a * 12 |
Error because a variable a is used. |

const
Defines read-only global variable.
Initial value should always be set.
Literals, arrays, and fixed value defined in const statement are available as initial value.
Function calls, expressions, and variables are not available.
Four fundamental operators (+, -, *, /) are allowed as an exception.
const variable = initial value
| const statement |
| const const1 = 'abcdefg' |
|
| const const2 = {1,2,3,4,5} |
|
| const const3 = 123 |
|
| const const4 = const1 |
Error if const1 is not a fixed value. |
| const const5 = a * 12 |
Error because a variable a is used. |

function
Defines user function.
* For more information, see [5. Function - User-defined function] .

arguments
Declares global arguments.
Global arguments are dummy arguments so that the argument can be sent to a section that is not defined in SQeeL source file.
Global arguments are passed as functions to a process that is not described as function in a source file.
Global arguments can be accessed from any location of a source file.
Argument list can be enclosed in ( and ).
If you want to declare multiple global arguments, separate the arguments by comma.
arguments dummy argument [, dummy argument 2, ..]
arguments (dummy argument [, dummy argument2, ..])
| arguments statement |
| arguments a |
Declares a variable a |
| arguments (a, b) |
Declares multiple variables |

require
Specifies a system library to be read.
System library file extends SQeeL system functions and system variables and is provided in a format of dynamic link library. Default extension of system library is slb.
When require is used in some SQeeL program file, require is loaded in a specified system library. Thus, system functions and variables defined in this system library can be used in a source file where require statement is described.
require 'system library file name'
| require statement |
| require 'dboralib.slb' |
|
| connect('system/manager') |
Connect function is defined in dboralib.slb. |

exglobal
Declares global variable that can be referred to and assigned to among multiple files.
Same exglobal variable should be declared in each file using exglobal variable.
If you want to define multiple variables, separate the variables by comma.
exglobal variable [, variable 2, ..]
| exglobal statement |
| exglobal a |
Declares a variable a |
| exglobal a, b |
Declares multiple variables. |
Exglobal variable can be accessed from any location in a source file. If global variable and exglobal variable are declared under the same name, first exglobal variable becomes effective. Global variable declared after exglobal variable is ignored.
You can set the initial value at declaration.
If the value is initialized in multiple files, the value of the initially uploaded program will be allocated.
Literals, arrays, and fixed values defined in const statement are available.
Function calls, expressions, and variables are not available.
Four fundamental operators (+, -, *, /) are allowed as an exception.
exglobal variable = initial value
| Initialization of exglobal variable |
| exglobal var = 'abcdefg' |
|
| exglobal var ={1,2,3,4,5} |
|
| exglobal var = 123 |
|
| exglobal var = const1 |
Error if const1 is not a fixed value |
| exglobal var = a * 12 |
Error because a variable a is used. |
Control statement controls a flow of program operation.
If the statement does not contain any control statement, SQeeL program executes a program from the beginning.
Control statement enables executing a part of a program and executing a certain part of the program repeatedly.

if, else
Branches a process based on the condition.
if statement always requires endif statement at the end of the statement.
if statement needs an expression. else statement does not need the expression at all times.
Else statement does not necessary have any operation. You can describe multiple operations in else statement.
if expression
process
else [expression]
process
endif
First, determine the expression in if statement.
If the expression in if statement is true, a process after the if statement will be executed.
If the expression in if statement is false, jump to else statement or endif statement.
If else statement does not contain any expression, a process after the else statement will be executed.
Else statement without the expression is always considered as true.
If the else statement contains the expression, determine the expression.
If the expression in the else statement is true, a process after the else statement will be executed.
If the expression in the else statement is false, jump to next else statement or endif statement.
This process is repeated.
After all if statements and else statements are executed, a process is moved to the statement after endif statement.
| if, else program |
N = getopt('enter year (YYYY): ') // n represents year
if n % 4 ==0 and n % 100 !=0
print('leap year')
else n % 400 == 0
print('leap year')
else
print('not a leap year')
endif
|

loop, break, continue
Loops the same process.
Loop statement does not only loop for the number of times specified but also controls the loop process by using continue and break statements.
loop expression1; expression2; expression3
process
[continue]
[break [integer]]
endloop
After the expression1 is determined, the expression 2 is determined next.
If the result is true, execute the process up to the next endloop statement.
If the result is false, jump to the process after endloop statement.
In endloop statement, after the expression 3 in loop statement is determined, the expression 2 in loop statement is determined.
If the result is true, execute the block after loop statement again.
If the result is false, jump to the process after endloop statement.
When continue statement is executed while a process loops between loop and endloop statements, the process jumps to endloop, and then the expression 3 and the expression 2 are determined.
When break statement is executed while a process loops between loop and endloop statements, the process forcefully backs out of the loop, and moves to the statement after endloop statement.
If there are multiple loops between loop and endloop statements, it is possible to back out of the loop for current loop added to the specified integer by specifying 1 or larger integer in break statement.
| loop, endloop program |
loop i = 1; i <= 10; i++
if i == 4
print('continue')
continue
endif
print('Hello World!')
endloop
loop h = 1; h <= 10; h++ // loop a
print ('loop a:${h}')
loop i = 1; i <= 10; i++ // loop b
print ('loop b:${i}')
loop j = 1; j <= 10; j++ // loop c
if j == 4
break 1 // back out of loop a
endif
print('loop c:${j}')
endloop
endloop
endloop
|

foreach
Loops by using a value of array variable.
Number of loops is determined by the number of elements in an array.
Assign the elements of array specified by array name to variables declared by variable name to loop a process up to endfor statement.
This variable is only effective between foreach and endfor. Thus, the variable is not declared in global statement.
If you want to use multiple arrays, separate the arrays by comma.
Even the number of arrays and the number of elements of the array do not match, it does not cause an error.
In this case, loop is repeated for the largest number of elements owned by an array by default. You can also specify the end condition.
foreach variable in array [,variable2 in array2, ..] [; end condition]
process
endfor
You can specify following keywords in the end condition.
| End condition |
| formax |
Loop for the larger number of elements of the array (default) |
| formin |
Loop for the smaller number of elements of the array. |
| forfirst |
Loop for the number of elements of the array described in the beginning of foreach statement. |
| foreach, endfor program |
/* Assign the product of array arr1 and arr2 to arr3 in an array*/
global arr1 = { 10 : 2 }
global arr2 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
global arr3 = { 10 }
foreach n1 in arr1, n2 in arr2, n3 in arr3
n3 = n1 * n2 // Assign the value to arr3
print(n1&'x'& n2&'='&n3)
endfor
Result:
2x0=0
2x1=2
2x2=4
2x3=6
2x4=8
2x5=10
2x6=12
2x7=14
2x8=16
2x9=18
|

goto
Moves the control to the next row of the specified label.
goto label name
| Goto program |
global a = 1
abc:
goto abc // Jump to a label abd
print(a) // Not processed
def:
print(a + 1)
|

on error goto
Jumps to a specified label when an error occurs in system function.
A label can be specified outside of the user function, and the other can be specified in the user function.
on error goto label name
| on error goto program |
function my_open(filename)
local fno
on error goto my_error // Jump to my_error when an error occurs.
fno = open(filename, read)
return fno
my_error:
print(ERROR)
return -1
endfunction
print(my_open('data.txt'))
|

return
Ends the function and returns to call source.
You can specify the return value.
Result of the expression is the return value.
return [expression]
| Return program |
print(beki(2,4)) // Output forth power of two.
exit
function beki (a, b)
local ans = 1, i
loop i = 1; i <= b; i++
ans = ans * a
endloop
return ans // Returns the bth power of a as a return value.
endfunction
|

exit
Exits SQeeL program.
You can specify a return value.
exit [return value]
| Exit program |
dir = getopt('input dirname :')
rc = system('ls ${dir}')
if rc != 0
print('error : ${rc}')
exit rc // Returns rc.
else
print('success')
endif
exit 0
|

include
Executes an external program in the current function context.
exglobal variable defined in call source can be used by a called function.
include program file name
| Inclue program |
Program: caller.eel
// caller.eel
exglobal gv1 = 1
function pgv()
print(gv1)
endfunction
include callee.eel // Call callee.eel
Program: callee.eel
// callee.eel
exglobal gv1 // Refers to exglobal variable gv1 from caller.eel
print(gv1)
pgv() // Refers to a function pgv from caller.eel
|