Board index » cppbuilder » Delphi to C++Builder translation

Delphi to C++Builder translation


2005-04-23 05:39:45 AM
cppbuilder108
What do you C++Builder professionals do with a large number of strings
that you want to put in one place? In Delphi you have a resourcestring
unit so what do you have in C++?
I have some strings from a Delphi resourcestring unit that I want to use
in C++Builder but I don't want to convert the unit to a C++ header file
but I'd like to create a new C++ header file. The following is an
example of the strings in the Delphi resourcestring unit:
resourcestring
SError_FileNotFound = 'File not found';
SError_PathNotFound = 'Path not found'{'Invalid file name'};
SError_TooManyOpenFiles = 'Too many open files';
Corwin
 
 

Re:Delphi to C++Builder translation

"Corwin Burgess" < XXXX@XXXXX.COM >wrote in message
Quote
What do you C++Builder professionals do with a large number of
strings that you want to put in one place? In Delphi you have a
resourcestring unit so what do you have in C++?

I have some strings from a Delphi resourcestring unit that I want to
use in C++Builder but I don't want to convert the unit to a C++
header file but I'd like to create a new C++ header file. The
following is an example of the strings in the Delphi resourcestring
unit:

resourcestring
SError_FileNotFound = 'File not found';
SError_PathNotFound = 'Path not found'{'Invalid file name'};
SError_TooManyOpenFiles = 'Too many open files';


A resource file.
Create a text file with your string resources:
STRINGTABLE
{
SError_FileNotFound, "File not found"
SError_PathNotFound, "Path not found"
SError_TooManyOpenFiles, "Too many open files"
}
Save it with the .rc extension and add it to your project.
You can access the strings with AnsiString.LoadString()
 

Re:Delphi to C++Builder translation

"Corwin Burgess" < XXXX@XXXXX.COM >wrote in message
Quote
In Delphi you have a resourcestring unit so what do you have in C++?
In C++, to mimic the "resourcestring" keyword, you have to create a separate
.RC or .RES file that contains string table(s) with the desired string
values in it. Then at run-time, you can use the LoadStr() or
LoadResourceString() function (or the AnsiString::LoadStr() method) to load
the desired value from the executable's resources dynamically when needed.
That is what Delphi does as well, it just automates everything for you at
the language level whereas BCB does not automate it at all.
Quote
I have some strings from a Delphi resourcestring unit that I
want to use in C++Builder but I don't want to convert the unit
to a C++ header file
You can add Delphi Pascal units to a BCB project. BCB includes a Delphi
compiler for compiling such units.
Quote
but I'd like to create a new C++ header file.
Compiling a Delphi Pascal unit automatically generates a suitable C++ header
file that the rest of the project can use. In the case of resource strings,
the generated header file will have a macro for each string value, and that
macro will expand into a call to LoadResourceString(). Have a look at
Consts.hpp or RtlConsts.hpp for an example.
Gambit
 

{smallsort}

Re:Delphi to C++Builder translation

At 23:39:45, 22.04.2005, Corwin Burgess wrote:
Quote
What do you C++Builder professionals do with a large number of strings
that you want to put in one place? In Delphi you have a resourcestring
unit so what do you have in C++?
IN C++, you do what you did in Delphi before there were resourcestring
constants: you used a .rc file with a string table.
--
Rudy Velthuis [TeamB]
"Opportunities multiply as they are seized." -- Sun Tzu
 

Re:Delphi to C++Builder translation

Why don't you drop that stupid, nonsensical, incorrect Sun Tzu quote.
Or are you just too stupid to know it's not really Sun Tzu?
 

Re:Delphi to C++Builder translation

Rudy Velthuis [TeamB] wrote:
Quote
At 23:39:45, 22.04.2005, Corwin Burgess wrote:


>In Delphi you have a resourcestring
>unit so what do you have in C++?


IN C++, you do what you did in Delphi before there were resourcestring
constants: you used a .rc file with a string table.



Thanks to everybody for the information.
Corwin