Resource Strings

From Appmethod Topics
Jump to: navigation, search

Go Up to Language Support for the Appmethod Libraries (C++)

If you have code in a Object Pascal unit that uses resource strings, the Object Pascal compiler generates a global variable and a corresponding preprocessor macro for each resource string when it generates the header file. The macros are used to automatically load the resource strings, and are intended to be used in your C++ code in all places where the resource string is referenced. For example, the resourcestring section in the Object Pascal code could contain:

unit MyUnit;


    Warning = 'Be careful when accessing string resources.';


The corresponding code generated by the Object Pascal compiler for Appmethod C++ would be

extern PACKAGE System::Resource ResourceString _Warning;
#define Myunit_Warning System::LoadResourceString(&Myunit::_Warning)
  • Unit names are normalized in C++, as C++ is a case-sensitive language. That is why the unit name, "MyUnit", becomes "Myunit" in C++.
  • "_Warning", as any other instance of ResourceString generated by the Object Pascal compiler, is declared within the "Myunit" namespace, so you must access it as Myunit::_Warning.
  • The define line lets you use the exported Object Pascal resource string as "Myunit_Warning" without having to explicitly call LoadResourceString.

See Also