p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

c_plus_plus_programming thread: Predefining Strings


Message #1 by "Cian Reynolds" <cianreynolds@h...> on Wed, 20 Feb 2002 13:21:41
Hi,



I am using a lot of strings throughout my program. Instead of hardcoding 

the string values what is the best way to predefine the strings?



I would preferably like to predefine them in a way such that if i change 

their values I will not have to recomplile the application.



Any ideas?



Cheers!
Message #2 by "Nitin Supekar" <supekar@p...> on Wed, 20 Feb 2002 18:53:34 +0530
Keep strings in XML with string ids and write one class which can get actual

string for you from that XML file.



Enjoy!!!



Nitin



 -----Original Message-----

From: 	Cian Reynolds [mailto:cianreynolds@h...]

Sent:	Wednesday, February 20, 2002 1:22 PM

To:	C++_Programming

Subject:	[c_plus_plus_programming] Predefining Strings



Hi,



I am using a lot of strings throughout my program. Instead of hardcoding

the string values what is the best way to predefine the strings?



I would preferably like to predefine them in a way such that if i change

their values I will not have to recomplile the application.



Any ideas?



Cheers!




$subst('Email.Unsub').



Message #3 by "Shyan Lam" <lam@s...> on Wed, 20 Feb 2002 08:59:12 -0600
If you're using Windows, put the string in an .ini file and use

GetPrivateProfileString() API (or implement your own class) to read the

string.



Store the string as follow:



[Section Name #1]

ID1 = String #1

ID2 = String #2



[Section Name #2]

ID1 = String #1a

ID2 = String #2a



This way, you can associate string with an ID value and grouped them under

different sections to be used by your application.



HTH



Shyan



> -----Original Message-----

> From: Cian Reynolds [mailto:cianreynolds@h...]

> Sent: Wednesday, February 20, 2002 1:22 PM

> To: C++_Programming

> Subject: [c_plus_plus_programming] Predefining Strings

>

>

> Hi,

>

> I am using a lot of strings throughout my program. Instead of hardcoding

> the string values what is the best way to predefine the strings?

>

> I would preferably like to predefine them in a way such that if i change

> their values I will not have to recomplile the application.

>

> Any ideas?

>

> Cheers!



Message #4 by Greg Norz <macrom75@y...> on Wed, 20 Feb 2002 18:17:19 -0800 (PST)
> I am using a lot of strings throughout my program. Instead of hardcoding 

> the string values what is the best way to predefine the strings?

> 

> I would preferably like to predefine them in a way such that if i change 

> their values I will not have to recomplile the application.



Or, as an alternative to the INI file and XML file mentioned, use a resource and build a String

Table. This keeps your strings hidden from casual users. The downside is that changes to your

resources force a recompile. Choose whichever is right for your project.



greg



__________________________________________________

Do You Yahoo!?

Yahoo! Sports - Coverage of the 2002 Olympic Games

http://sports.yahoo.com

Message #5 by "Tomas Palmer" <tomasp@g...> on Wed, 20 Feb 2002 22:05:26 -0800
In Windows you can use a resource dll. You will recompile the dll but

not the application.





Clear Skies....PLEASE!

Tom=E1s

www.littlebear-observatory.com

www.cosmiccontrols.com

www.i-codesmith.com





-----Original Message-----

From: Cian Reynolds [mailto:cianreynolds@h...]

Sent: Wednesday, February 20, 2002 1:22 PM

To: C++_Programming

Subject: [c_plus_plus_programming] Predefining Strings



Hi,



I am using a lot of strings throughout my program. Instead of hardcoding



the string values what is the best way to predefine the strings?



I would preferably like to predefine them in a way such that if i change



their values I will not have to recomplile the application.



Any ideas?



Cheers!




$subst('Email.Unsub').



Message #6 by Edward Guo <EGuo@c...> on Thu, 21 Feb 2002 10:07:33 -0500
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C1BAE9.7D760F40

Content-Type: text/plain;

	charset="iso-8859-1"





Putting those strings into registry might be another possible solution.



Edward



-----Original Message-----

From: Cian Reynolds [mailto:cianreynolds@h...]

Sent: February 20, 2002 8:22 AM

To: C++_Programming

Subject: [c_plus_plus_programming] Predefining Strings





Hi,



I am using a lot of strings throughout my program. Instead of hardcoding 

the string values what is the best way to predefine the strings?



I would preferably like to predefine them in a way such that if i change 

their values I will not have to recomplile the application.



Any ideas?



Cheers!




$subst('Email.Unsub').





  Return to Index