====== Define ======
When it comes to defines, unfortunately Vulcan.NET is not compatible to VO, and X# has returned to VO compatibility.
In VO, you can define
define my_define := 255
in any of your libraries and this define is like a global variable that is available in all depending code.
When Vulcan was developed, the development team opted for a more C like syntax:
#define my_define 255
and this define is visible only in the prg files that has this definition inside, either directly or with an include. But includes can have the problem that you can redefine them or have different defines with the same name and different content.
The X# team instead adopted the VO syntax, using the define again as a sort of global variable. This will let you compile VO code without warnings, but can give some warnings on Vulcan code.
In X#, these to are different even if they are similar:
#define my_define 255
define my_define := 255
The first is a define like Vulcan or C/C++/C#, the second one instead is like in VO.
When migrating code from Vulcan.NET to X#, it is a good idea to change all ''#define'' statements to ''define'' statements and put them in some library instead of include files, and remove the includes.
If you are using the VO compatible class libraries and therefore need the defines from the VO SDK, you should include the library ''SDK_DEFINES.dll'' to your application. You can find this in your VO Xporter folder, probably in the C:\Program Files (x86)\XSharp\VOXPorter folder.
In a discussion about this Robert wrote the following:
For me the most important reason to switch back from #define to DEFINE is the way it was implemented and the consequences of this implementation.
In Vulcan the preprocessor (and the X# preprocessor a well) do a "dumb" Search and Replace for defines and this has unwanted side effects.
Consider the following code:
#define DELETE 1
Function Delete(nRec as LONG) AS LOGIC
If the preprocessor compatibility command line option (/vo8) is switched on, then this will be preprocessor to:
FUNCTION 1(nRec as LONG) AS LOGIC
Please note how the name of the function was replaced by the value of the define.
This causes many cryptic error messages, making it very difficult for new users to get started.
Without /vo8 this would only happen if the function name was written in ALL CAPITAL letters.
The way VO does it (and the way the DEFINE In X# is implemented) this is not handled by te preprocessor. In a later compiler phase the "binder" will lookup names and will find the value and substitute the name in the parse tree with the values.
The DEFINE itself is stored as a global const value inside the same class where GLOBALs and FUNCTIONs are stored.
This does not have this side effect.