Click here to Skip to main content
15,395,877 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: re: missing mutex events Pin
Rajesh R Subramanian21-Dec-09 20:45
professionalRajesh R Subramanian21-Dec-09 20:45 
GeneralRe: re: missing mutex events Pin
Alan Kurlansky22-Dec-09 2:59
MemberAlan Kurlansky22-Dec-09 2:59 
QuestionDebugging a C++ program in Visual Studio 2005 Pin
loyal ginger21-Dec-09 5:33
Memberloyal ginger21-Dec-09 5:33 
AnswerRe: Debugging a C++ program in Visual Studio 2005 Pin
Abhi Lahare21-Dec-09 5:44
MemberAbhi Lahare21-Dec-09 5:44 
GeneralRe: Debugging a C++ program in Visual Studio 2005 Pin
loyal ginger21-Dec-09 6:03
Memberloyal ginger21-Dec-09 6:03 
GeneralRe: Debugging a C++ program in Visual Studio 2005 Pin
Abhi Lahare21-Dec-09 6:19
MemberAbhi Lahare21-Dec-09 6:19 
GeneralRe: Debugging a C++ program in Visual Studio 2005 Pin
loyal ginger21-Dec-09 6:27
Memberloyal ginger21-Dec-09 6:27 
Questioncan you simplify the function by #define? [modified] Pin
includeh1021-Dec-09 0:16
Memberincludeh1021-Dec-09 0:16 
Can you simplify the function by #define or something else?

I want to simplify code bellow, both dll and dynamically reading file are not suitable because of 2 reasons:
1. those files are created by others, if in my way, I only need to re-compile, and do not need to copy the 150 files (will be more soon) into code.
2. there are around 3K of words and sentences in different languages, which can not be used by index. i.e. for string "Apply now", we can not use
CString cs=data[1743]+data[725] - no one can remember which index is which word.
there is a definition class (generated from Data file), looks like:
class Data
{
WORD
*Time,
....,
*Now,
....,
*Apply,
....
};

use is one of #include bellow, then
CString cs=data.Apply+data.Now;
is OK.

void LangData::P_InitLangFull()
{
	char*p0[]=
	{
		#include "Language\english\language_full.h"		
	};	//do some thing

	char*p1[]=
	{
		#include "Language\french\language_full.h"
	};	//do some thing

        //more
	char*p9[]=
	{
		#include "Language\german\language_full.h"
	};	//do some thing
}


Function code above is quite repeat: only language directory name, english, french, ..., german are changed - totally repeated for 10 times.

It is ok if so, but each language directory has 15 file, so I have to "repeat" the function for 15 times, so second to 15th function look like (only file name is different from first function):

every included h file is plain text as:

"good",
"bad",
"next",



void LangData::P_InitWeather()
{
	char*p0[]=
	{
		#include "Language\english\Weather.h"		
	};	//do some thing

	char*p1[]=
	{
		#include "Language\french\Weather.h"
	};	//do some thing

        //more
	char*p9[]=
	{
		#include "Language\german\Weather.h"
	};	//do some thing
}


You can imagine how ugly the file is at last - I haven't completed it.

I think we may simplify code by #define or some idea, but the #include causes trouble to #define.

any ideas or suggestions?

thanks

modified on Monday, December 21, 2009 9:32 AM

AnswerRe: can you simplify the function by #define? Pin
Richard MacCutchan21-Dec-09 0:36
mveRichard MacCutchan21-Dec-09 0:36 
GeneralRe: can you simplify the function by #define? Pin
includeh1021-Dec-09 1:30
Memberincludeh1021-Dec-09 1:30 
GeneralRe: can you simplify the function by #define? Pin
Richard MacCutchan21-Dec-09 1:50
mveRichard MacCutchan21-Dec-09 1:50 
GeneralRe: can you simplify the function by #define? Pin
includeh1021-Dec-09 3:21
Memberincludeh1021-Dec-09 3:21 
GeneralRe: can you simplify the function by #define? Pin
Richard MacCutchan21-Dec-09 5:54
mveRichard MacCutchan21-Dec-09 5:54 
QuestionRe: can you simplify the function by #define? Pin
CPallini21-Dec-09 1:55
mveCPallini21-Dec-09 1:55 
AnswerRe: can you simplify the function by #define? Pin
Maximilien21-Dec-09 2:38
MemberMaximilien21-Dec-09 2:38 
GeneralRe: can you simplify the function by #define? Pin
Nelek21-Dec-09 3:09
protectorNelek21-Dec-09 3:09 
GeneralRe: can you simplify the function by #define? Pin
Abhi Lahare21-Dec-09 5:41
MemberAbhi Lahare21-Dec-09 5:41 
GeneralRe: can you simplify the function by #define? Pin
Nelek21-Dec-09 7:04
protectorNelek21-Dec-09 7:04 
Questionfread() for file system Pin
hrishiS20-Dec-09 23:26
MemberhrishiS20-Dec-09 23:26 
AnswerRe: fread() for file system Pin
CPallini21-Dec-09 0:25
mveCPallini21-Dec-09 0:25 
QuestionHow to save Images in none compression images Pin
Game-point20-Dec-09 23:15
MemberGame-point20-Dec-09 23:15 
AnswerRe: How to save Images in none compression images Pin
CPallini21-Dec-09 0:58
mveCPallini21-Dec-09 0:58 
AnswerRe: How to save Images in none compression images Pin
Code-o-mat21-Dec-09 10:19
MemberCode-o-mat21-Dec-09 10:19 
QuestionOver Writing in File System... Pin
hrishiS20-Dec-09 20:54
MemberhrishiS20-Dec-09 20:54 
QuestionRe: Over Writing in File System... Pin
CPallini20-Dec-09 21:25
mveCPallini20-Dec-09 21:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.