Others Commands


Syntax

Goto <label>
Description
This command is used to transfer the program directly to the labels position. Be cautious when using this function, as incorrect use could cause a program to crash...

Note: To exit a loop savely, you always should use Break instead of Goto.

Syntax

End [ExitCode]
Description
Ends the program execution correctly. The 'ExitCode' optional parameter can be specified if the program need to returns an error code (widely used in console programs).

Syntax

Size = SizeOf(Type)
Description
The SizeOf command can be used to find out the size of any complex Structure (it does not work on the simple built-in types such as word and float), Interface or even variables. This can be useful in many areas such as calculating memory requirements for operations, using API commands, etc.

Example:

  Structure Person
    Name.s
    ForName.s 
    Age.w 
  EndStructure
  
  Debug "The size of my friend is "+Str(Sizeof(Person))+" bytes" ; will be 10 (4+4+2)
  
  John.Person\Name = "John"
  
  Debug SizeOf(John) ; will be also 10 
Note: if a variable and a structure have the same name, the structure will have the priority over the variable.

Syntax

Index = OffsetOf(Structure\Field)
Index = OffsetOf(Interface\Function())
Description
The OffsetOf command can be used to find out the index of a Structure field or the index of an Interface function. When used with an Interface, the function index is the memory offset, so it will be IndexOfTheFunction*4.

Example:

  Structure Person
    Name.s
    ForName.s 
    Age.w 
  EndStructure
  
  Debug OffsetOf(Person\Age) ; will be 8 as a string is 4 byte in memory
  
  
  Interface ITest
    Create()
    Destroy(Flags) 
  EndInterface
  
  Debug OffsetOf(ITest\Destroy()) ; will be 4