Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/resources/contents/code/extensions/sample.cal
- This file was added.
// Data types | |||||
BigIntegerVar := -9223372036854775807L; | |||||
BigIntegerVar := BigIntegerVar - 1; | |||||
Date1 := 0D; | |||||
Date1 := 112710D; | |||||
MESSAGE(FORMAT(Date1)); | |||||
MESSAGE(FORMAT(Date1)); | |||||
Date1 := 11271810D; | |||||
Q = DIV(5, 7); | |||||
R = MOD(5, 7); | |||||
// Compound Statments | |||||
// ------------------ | |||||
// BEGIN-END | |||||
IF (x = y) AND (a = b) THEN BEGIN | |||||
x := a; | |||||
y := b; | |||||
END; | |||||
// Conditional Statments | |||||
// --------------------- | |||||
// IF-THEN-ELSE | |||||
IF x < y THEN | |||||
EXIT(TRUE) | |||||
ELSE BEGIN | |||||
x := x * 2L; | |||||
y := y - 1L; | |||||
END; | |||||
// CASE-OF | |||||
CASE Field OF | |||||
Field::A: | |||||
BEGIN | |||||
x := x + 1; | |||||
y := -y - 1; | |||||
END; | |||||
Field::B: | |||||
x := y; | |||||
Field::C,Field::D: | |||||
y := x; | |||||
ELSE BEGIN | |||||
y := x; | |||||
a := b; | |||||
END; | |||||
END; | |||||
// Repetitive Statements | |||||
// --------------------- | |||||
// FOR-TO-DO | |||||
FOR I := 1 TO 5 DO | |||||
FOR J := 1 TO 7 DO | |||||
A[I,J] := 23; | |||||
// FOR-DOWNTO-DO | |||||
FOR I := 5 DOWNTO 1 DO | |||||
FOR J := 7 DOWNTO 1 DO | |||||
A[I,J] := 23; | |||||
// FOREACH-IN-DO | |||||
strarray := Dir.GetFileSystemEntries('C:\myfiles\'); | |||||
FOREACH txt IN strarray DO | |||||
BEGIN | |||||
MESSAGE(txt); | |||||
END; | |||||
// WHILE-DO | |||||
WHILE I < 1000 DO | |||||
I := I + 1; | |||||
Message(format(I)); | |||||
// REPEAT-UNTIL | |||||
Count := 0; | |||||
IF Customer.FIND('-') THEN | |||||
REPEAT | |||||
Count := Count + 1; | |||||
UNTIL Customer.NEXT <= 0; | |||||
Message(’The Customer table contains %1 records.’,Count); | |||||
// EXIT | |||||
FOR I := 1 TO 1000 DO BEGIN | |||||
IF Amount[I] < Total[I] THEN | |||||
EXIT(1); | |||||
A[I] := Amount[I] + Total[I]; | |||||
END; | |||||
// BREAK Statement | |||||
// --------------- | |||||
// BREAK | |||||
FOREACH element IN mylist DO | |||||
BEGIN | |||||
MESSAGE(FORMAT(element)); | |||||
IF FORMAT(element) = 'Item 2' THEN | |||||
BREAK; | |||||
END; | |||||
// WITH Statment | |||||
// ------------- | |||||
// WITH | |||||
WITH CustomerRec DO BEGIN | |||||
"No." := '1234'; | |||||
Name := 'Windy City Solutions'; | |||||
"Phone No." := '555-444-333'; | |||||
Address := '1241 Druid Avenue'; | |||||
City := 'Windy City'; | |||||
MESSAGE('A variable has been created for this customer.'); | |||||
END; | |||||
// ASSERTERROR Statement | |||||
// --------------------- | |||||
// ASSERTERROR | |||||
InvalidDate := 010184D; | |||||
InvalidDateErrorMessage := Text001; | |||||
ASSERTERROR CheckDate(InvalidDate); | |||||
IF GETLASTERRORTEXT <> InvalidDateErrorMessage THEN | |||||
ERROR('Unexpected error: %1', GETLASTERRORTEXT); | |||||
// STRINGS WITH BACK SLASH | |||||
IF FilePath[STRLEN(FilePath)] <> '\' THEN | |||||
FilePath = FilePath + '\' |