Source code
A model is essentially based on source code and information about interfaces. Advanced users may use source code to develop their models. All the panels, such as ‘Actions’ and ‘Graph’, are representations of the source. All the actions you do in those windows are put into the source. The exception is the information about interfaces. In the code, an interface is just a line: interface <name>
. No information is stored there.
The easiest way to learn how the source works is to investigate how the source changes when you make changes to the model. Eventually, you will type code, and see the Graph and Action windows react to your changes.
Note: you need the professional license of the Berkeley Studio to be able to edit the source code.
The following is meant as a brief overview of the language, to get you started.
Graph and node
A graph has at least 1 node. The syntax for a graph is as follows:
graph <graphname>;
begin
node <nodename>;
<declarations>
begin
<node body>
end;
end.
Data
All the variables and datasets have to be declared before being used. This is done in the implicit head of a node, that is, between node <nodename>
and the begin ... end;
part that signifies the body of a node.
Variables
Variables follow the var
keyword and are comma-separated:
node <nodename>;
var
mydata,
myotherdata;
begin
end;
end;
Datasets are declared following the dataset
keyword. They declare their type (the graph
that defines its structure) after a colon (:
).
Datasets
NOTE this list is semicolon (;
) separated:
node <nodename>;
dataset
<datasetname>: <graphname>;
<datasetname2>: <graphname>;
<datasetname3>: <graphname3>;
begin
end;
end;
Syntax of formulas and conditions
All Actions, Formulas, Connections and Questions translate to statements in the source code and are put in the ‘node body’ block demarcated with the begin ... end;
pair. All statements end in with a semicolon (;
):
node <nodename>;
var
mydata,
myotherdata;
dataset
mydataset: <graphname>;
begin
if <var> = 1 then
mydata := 'value';
end;
end;
A ‘formula’ is always assigned to a variable (the ‘name’ field in the formula dialog). The assignment operator is written as :=
(a colon followed by an equals sign):
greeting := 'hello';
Comparing values is done with a single equals sign (=
).
A condition (of a formula, action or connection) is written as an if-statement. If the condition is true
, will execute the next line of code. If the condition is false
, the next line will not be executed.
if <var> = 1 then
mydata := 'value';
Flow
A graph has many nodes, which are connected. A connection is made by the statement goto <nodename>
. A call to a graph is usually done
by callnext
:
node <nodename>;
begin
callnext <anothergraph>;
goto <anothernode>;
end;
end;
Once a goto
statement has executed, the node is exited. The following code thus will never callnext <anothergraph>
:
node <nodename>;
begin
goto <anothernode>;
callnext <anothergraph>;
end;
end;
Interface
Interfaces are usually something showed on the screen of the end user, such as a text or a question. In the example below, birthdate
could represent the question ‘When were you born?’, and text1
could contain some explanatory output.
node ask_age;
var
birthdate,
text1;
begin
interface birthdate;
interface text1;
end;
end.
Aside from these ‘on-screen’ interfaces, just about anything that has to do with input or output is represented as an interface
in the source code. The nature of these inputs and outputs can vary widely:
- SOAP and REST calls
- Database calls (at time of writing Interbase, MySQL, MSSQL and Oracle)
- Email interfaces
- Calls to identity providers
- Read/write XML interfaces
- Read/write Connections to Excel spreadsheet documents