Defines
Defines are a way of setting code to be included or not at compile-time
For example, you might want a bit of code to be compiled if something has been defined, however if the define does not exist then the piece of code will not be included in the compiling.
you define something like so:
You can then use it to testif it is defined
Simba Code:
{$IFDEF SOMETHING}
//Some Code Here
{$ENDIF}
now the code between the two tags above will only be compiled if it has been defined
This is particularly useful if you have several files and you want to make sure the person has all the files or if you want to debug some code
This is what is used in order for smart to work easily in your scripts, If SMART has been defined then SRL will automatically include everything you need.
There are also built in defines which allow you to include certain code if the end user is running a certain version of simba
Simba Code:
{$IFDEF SIMBA980}
//Some stuff
{$ENDIF}
The above will only be run if the user is running Simba rev. 980, this is particularly useful if you there is a bug that can be fixed by some code
There is also one for checking whether something has not been defined
Simba Code:
{$IFNDEF SIMBA980}
//Some stuff
{$ENDIF}
The above will only be run if the user is not running Simba rev. 980
And finally there is one more directive, else
Simba Code:
{$IFDEF SIMBA980}
//Some stuff
{$ELSE}
//Some other stuff
{$ENDIF}
This way if you want one piece of code to be used if something is defined but another piece if it is not then this can be used
They can also be used to make scripts ready for future updates
for example, SRL4 uses the.scar extension, but SRL5 uses the.simba extension, by using defines we can change which file it uses
Simba Code:
{$IFDEF SRL5}
{$i SRL/SRL.simba}
{$i SRL/SRL/MISC/Debug.simba}
{$ELSE}
{$i SRL/SRL.scar}
{$i SRL/SRL/MISC/Debug.scar}
{$ENDIF}
Here, if we define SRL5 then it will include the SRL5 files, however if we do not then it will define the SRL4 files
This can be used in other parts of the code, allowing the script to be used by both SRL4 and SRL5
This is only a rough guide and i will polish it off a bit more later on
~shut