The System unit is automatically included in every DWScript program. It defines the fundamental types, base classes, and global functions of the language.
The ultimate ancestor of all classes in DWScript.
| Member | Kind | Description |
|---|---|---|
Create |
Constructor | Standard constructor. |
Destroy |
Destructor | Virtual destructor. |
Free |
Procedure | Safely calls Destroy. |
ClassName |
Function | Returns the name of the object's class as a string. |
ClassType |
Function | Returns the metaclass (TClass) of the object. |
ClassParent |
Function | Returns the metaclass of the parent class. |
Base class for all error handling.
| Member | Description |
|---|---|
Create(msg) |
Constructor with error message. |
Message |
Property containing the error description. |
StackTrace |
Property containing the call stack at the point of failure. |
| Function | Description |
|---|---|
Print(v) |
Outputs a value to the current result stream. |
PrintLn(v) |
Outputs a value followed by a newline. |
Swap(var a, b) |
Swaps the values of two variables of the same type. |
SetLength(var v, len) |
Resizes a dynamic array or string. |
Inc(var x [, n]) |
Increments a variable (Integer or Float). |
Dec(var x [, n]) |
Decrements a variable. |
Assigned(v) |
Returns True if an object, interface, or procedure variable is not nil. |
ExceptObject |
Returns the current exception object in an except block. |
ParamCount |
Returns the number of command-line parameters. |
ParamStr(i) |
Returns a specific command-line parameter. |
var obj := new TObject;
PrintLn(obj.ClassName); // TObject
obj.Free; TObject
try
raise new Exception('An error occurred');
except
on E: Exception do
PrintLn(E.Message);
end; An error occurred
var a := 10;
var b := 20;
Swap(a, b);
PrintLn(Format('a=%d, b=%d', [a, b])); a=20, b=10