Archived

This topic is now archived and is closed to further replies.

n4gix

C Syntax Help Needed...

Recommended Posts

I have an urgent need to update my sound module to allow for increased flexibility by the users.

 

I have been using a predefined path to the sim's ..\Sound folder such as the following:

 

(GaugePlaySound)("sound\\LHC_X\\SND1.wav","",0)

 

I already know how to use the "fifth parameter" of the gauge entry to include a relative path, such as the following:

 

gauge00=LHC_X_Sound!SoundModule, 0,0,1,1,SimObjects\\Airplanes\\MyAirplane\\panel\\sound

CHAR sound_Path[MAX_PATH] = "";
int params_read = 0;
 
case PANEL_SERVICE_POST_INSTALL:
if (pgauge->parameters && params_read == 0)
{
if ( strlen(pgauge->parameters) > 0 )
{
strcpy(sound_Path,(PCHAR)(pgauge->parameters)); params_read = 1;
}
 
else if ( strlen(pgauge->parameters) == 0 )
{
params_read = 1;
}

What I don't know however is the correct syntax for concantenating the char variable sound_Path so that it will replace the characters highlighted in red:

 

(GaugePlaySound)("sound\\LHC_X\\SND1.wav","",0)

 

Could it possibly be as simple as this:

(GaugePlaySound)(strcat(sound_Path,\\SND1.wav),"",0)

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

strcat(sound_Path,"\\Snd1.wav")

 

Hugo

So, maybe I did guess correctly:

(GaugePlaySound)(strcat(sound_Path,"\\Snd1.wav"),"",0)

I have 200 such entries, so I want to be certain before I do any Search/Replace operation... :Drooling:

Share this post


Link to post
Share on other sites

NO,NO,NO,

 

strcat(Sound_path,\\SND1.wav)  

 

is NOT the same as  

 

strcat(Sound_path,"\\SND1.wav")  .

 

Sound_path is a variable containing a string, but  \\SND1.wav in the first statement is meaningless and the compiler will generate an error for it.

 

In the  second statement "\\Snd1.wav" creates locally a new string  and the address of this string will be the second parameter for the strcat routine with the wanted result.

Share this post


Link to post
Share on other sites

Actually, I did have it correct, but this bloody POS forum editor kept stripping out the quote marks!

 

It took three tries, but I finally coaxed the "code box" to behave itself and (re)edited my previous post...

  :sorry:

Share this post


Link to post
Share on other sites