Jump to content
Sign in to follow this  
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)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

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:


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

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:


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...