I want to use CodeSite message constants in my CodeSiteEx calls but I keep getting 'Undeclared Identifier' errors. What's wrong?
CodeSite's message constants are declared in an Include file. This include file is linked in with CodeSite's source code, which CodeSiteEx descends from. Since the constants are not properties of the CodeSite object, CSX does not natively "know" about them; the only solution would be to link the include file into CodeSiteEx as well. Unfortunately, Delphi does not allow this as the compiler recognizes the include file code as already being included (into CodeSite) and generates compile errors for duplicate identifiers.
The good news is there are at least two ways you CAN access the message constants.
Include CodeSite's Message Type file
You can simply include the message constant include file into your source code.
- For CodeSite 2, this file is named CSMsgTypes.INC and it is located in the SOURCE folder beneath the CodeSite install path (for example, "C:\Program Files\Raize\CS2\Source").
- For CodeSite 3, this file is named CodeSiteMsgTypes.INC and it is located in the SOURCE\VCL folder beneath the CodeSite install path (for example, "C:\Program Files\Raize\CS3\Source\VCL").
- For CodeSite 4, this file is named CodeSiteMsgTypes.INC and it is located in the SOURCE\VCL folder beneath the CodeSite install path (for example, "C:\Program Files\Raize\CS4\Source\VCL").
In your code, just add the statement {$INCLUDE CSMsgTypes.INC} or {$INCLUDE CodeSiteMsgTypes.INC} as appropriate to have access to the CodeSite message constants.
- OR -
Add CodeSite to your USES clause
Simply adding the CodeSite object unit (CSIntf in CodeSite 2, CodeSiteLogging in CodeSite 3/4) to your USES clause, gives you access to the constants as well. Please note, this is *in addition* to CodeSiteEx's CSIntfEx unit, NOT instead of. Also note, due to the way the Delphi compiler reads the units it links in, CodeSite's unit must appear BEFORE CodeSiteEx's in the USES clause. Placing CodeSite's unit AFTER CSIntfEx prohibits use of CSX's extended features, like the TraceMethod routines.