No, there is no way to define a constant.
You must use a variable, and declare it as GLOBAL.
What you need to do is decide on a naming convention which differentiates between constants and variables, so that you don't accidentally bash them in your code.
KiXtart is case insensitive (mostly), so you cannot rely on giving the variables all upper case names to protect them, although it does make them stand out in your code.
When I want to define constants I do this:
- If the constant is only going to be used by functions or script in a called library, then I prefix the variable name with an underscore then the scope (library name) then another underscore.
- If the constant is to be visible across all scopes, I define it in the start of the main script and prefix the variable name with two underscores. This is exactly the same as the previous example, but with a null (or global) scope.
For example, suppose I define a variable to be the name of the server which hosts all my printers. This is a general constant which may be used by all my routines, so I define it as:
Code:
Global $__PRINTSERVER
However, I have a library of network routines which I call into scripts as I need them. The constants are define at the head of the library file like this:
Code:
If Not IsDeclared($_Network_ISLOADED)
Global $_Network_ISLOADED
Global $_Network_NETMASK
Global $_Network_DOMAINNAME
$_Network_NETMASK="255.255.252.0"
...
EndIf
As the scope is "Network", there is no danger that I will accidentally clash with the global constants, or constants declared in any other file.
That's just the way I do it. You can make up your own variable naming convention, and as long as you stick to it your variables will be constant