Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
1.1.0:scripting [2023/08/02 15:36] – [TypeCasts] admin | 1.1.0:scripting [2023/08/03 11:29] (current) – [Exit] admin | ||
---|---|---|---|
Line 136: | Line 136: | ||
|shr|bitwise|operation to shift by a specific number of bits to the right| | |shr|bitwise|operation to shift by a specific number of bits to the right| | ||
|shl|bitwise|operation to shift by a specific number of bits to the left| | |shl|bitwise|operation to shift by a specific number of bits to the left| | ||
+ | |as|typecast|as operator for explicit type-casts, supported for classes or basic types (string, int, int64, boolean and floats)| | ||
+ | |in|check|checks if right side contains the left side. it's a multitype operator for enums or strings| | ||
==== Routines ==== | ==== Routines ==== | ||
Line 249: | Line 251: | ||
LArr1[4] := LArr1[0]; | LArr1[4] := LArr1[0]; | ||
System.WriteLn(LArr1.ToString() + #13#10); | System.WriteLn(LArr1.ToString() + #13#10); | ||
+ | end; | ||
+ | </ | ||
+ | * TypeCast Operator " | ||
+ | <file pascal> | ||
+ | var LStr : String; | ||
+ | LFlt : Single; | ||
+ | begin | ||
+ | // auto-string/ | ||
+ | LStr := ((' | ||
+ | System.WriteLn(LStr as String); | ||
+ | | ||
+ | // auto-rounding, | ||
+ | LFlt := ((123.56789 as Int32) as Double); | ||
+ | System.WriteLn(LFlt as String); | ||
end; | end; | ||
</ | </ | ||
Line 509: | Line 525: | ||
end; | end; | ||
</ | </ | ||
+ | ===== Syntax Elements ===== | ||
+ | |||
+ | Since Rev. 2730+ you're able to call EXIT or HALT like in Delphi syntax. | ||
+ | |||
+ | ==== Exit ==== | ||
+ | |||
+ | The exit statement will immediatly leave a function or program code. | ||
+ | |||
+ | __NOTICE__: Currently it's not possible to directly set the result value in brackets! | ||
+ | |||
+ | In the example below the function will return "A large value!" | ||
+ | Otherwise it will return the integer value as string. | ||
+ | |||
+ | <file pascal> | ||
+ | function MyTest(AValue : Integer) : String; | ||
+ | begin | ||
+ | if (AValue > 100) then | ||
+ | begin | ||
+ | Result := 'A large value!'; | ||
+ | Exit; | ||
+ | end; | ||
+ | | ||
+ | Result := IntToStr(AValue); | ||
+ | end; | ||
+ | </ | ||
+ | |||
+ | ==== Halt ==== | ||
+ | |||
+ | The HALT statement is useful to immediatly stop the program from execution. | ||
+ | It doesn' | ||
+ | |||
+ | In the example below we stop the program if the supplied argument is larger than 100. | ||
+ | Otherwise nothing will happen. | ||
+ | |||
+ | <file pascal> | ||
+ | procedure StopMyProgram(AValue : Integer); | ||
+ | begin | ||
+ | if (AValue > 100) then | ||
+ | Halt; | ||
+ | end; | ||
+ | </ | ||
+ | |||
+ | |||
===== Classes ===== | ===== Classes ===== | ||