Programming guide to Unibase

11 : Statements

Variable declaration

var variable [as [static] type] Create a new variable with default type string.
 Static means that the contents of the variable will stay there till the next time that the routine is called.
 
A new variable will be available for the current routine. These statements should be places at the beginning of the routine.

Break instruction

break Stop the current statement.
 
This statement works for the following statements: for, case, loop, separate and search.

Case statement

case variable Normal case statement.
{ when value or value 
 ... code ...} Multiple values are allowed here.
[ otherwise 
 ... code ...] 
endcase 
 

For statement

for variable = expression to expression This is the normal for statement.
 ... code ... It create a loop for a fixed number of times.
next 
 

Loop statement

loop Start an unending loop.
  ... code ... 
  break The command to stop the loop again.
  ... code ... 
do 
 

If statement

if condition then Standard if statement.
  ... code ... 
{elsif condition then 
  ... code ...} 
[else 
  ... code ...] 
endif 
 

Output statement

output expression [to streamWrite a string to a stream. Or by default to the standard output.
 

Return statement

return [expressionReturns a value in a function definition. This also stops the current routine.
 In a normal routine the expression should be empty.
 

Separate statement

separate string as variable by value Loop through parts of the given 'string' separated by 'value'.
  ... code ... Inside the loop 'variable' has two fields:
  [variable.first] The field 'first' contains 'true' on the first part of the string.
  ... code  ... 
  [variable.recnr] Field 'recnr' contains the part number within the string.
  ... code ... 
next 
 
This statement is an addition to the standard string handling functions. It provides a functionality that normally would cost a lot of programming. It is fairly quick and it is used a lot in the database software.