SimTalk 2.0 and SimTalk 1.0 Compared
The following table provides an overview of the changed language constructs between SimTalk 2.0 and SimTalk 1.0.
Feature | New Syntax (SimTalk 2.0) | Old Syntax (SimTalk 1.0) |
---|---|---|
Parameter Declaration | param v1,v2: integer, name: string | (v1,v2:integer; name:string) |
Return Type Declaration | ->boolean or param v1,v2: integer, name: string -> boolean | :boolean or (v1,v2:integer; name:string): boolean |
Empty Method | — | is |
Variable Declaration between is and do | var v: integer | is |
Variable Declaration | var s: string | local s: string |
if condition | if a > 3 | if a > 3 then |
for loop | for var i := 1 to 10 | for local i := 1 to 10 loop |
while loop | while a 10 | while a 10 loop |
repeat loop | repeat | repeat |
switch-statement | switch a | inspect a |
waituntil-statement | waituntil name = "Test" or waituntil name = "Test" prio 1 | waituntil name = "Test" prio 1; |
DataList operator [ ] | Cardfile.remove(2) | Cardfile[2] |
The following table provides an overview of the changed operators between SimTalk 2.0 and SimTalk 1.0.
Feature | New Syntax (SimTalk 2.0) | Old Syntax (SimTalk 1.0) |
---|---|---|
About equal operator | ~= <~= >~= | == <== >== |
Add a value Subtract a value Multiply a value | x += y is short for x := x + y x -= y is short for x := x - y x *= y is short for x := x * y | — |
Modulo operator | mod | \\ |
Division operator | div | // |
Reference operator | & e.g. .Models.Frame.&Method | .ref() e.g. .ref(.Models.Frame.Method) |
Type check during assignment | Wrong unit causes an error. To prevent this, assign the correct unit or a value without a unit, for example: Conveyor.Speed := Conveyor.Length / 0:01 | Wrong unit causes an warning, for example: Conveyor.Speed := Conveyor.Length |
You can activate SimTalk 2.0 notation by clicking New Syntax on the Tools ribbon tab of the Method you are programming. If you want to use if for all new Methods which you are going to program, activate New Syntax in the Method class in the Class Library. Instead, you can also use the attribute UsingNewSyntax.
Clicking in an existing Method which you programmed in SimTalk 1.0 notation automatically converts the source code to the correct SimTalk 2.0 notation.