Jump to content
Sign in to follow this  
Guest Bram

MAKE_STRING troubles

Recommended Posts

Guest Bram

Hi,I'm developing a new panel for the FS standard 777, but I can't get a callback function to write the current mach speed preceeded by a "M" to a string, using the MAKE_STRING macro.I'm quite new to programming gauges, earlier programmed in java, php, c++/MFC.This is the callback function:

MODULE_VAR	ap_mach_hold_var= { AUTOPILOT_MACH_HOLD_VAR };FLOAT64 FSAPI cb_string_speed( PELEMENT_STRING pelement ){		//update the module var	lookup_var(&ap_mach_hold_var);		//multiply the current mach speed to something we can use	UINT64 vmach = ap_mach_hold_var.var_value.n*100;	char x[20] = "M. ";	char n[4]  = "";		//format vmach and put the result in n	wsprintf(n, "%3d", (UINT64) vmach);				//concatenate x and n, result should be x="M. xxx"	strcat(x,n);		//put x to the macro this function was called by	pelement->string = x;	//and leave the callback	 	return ap_mach_hold.var_value.n;}

Using this code, the aircraft won't load or the string gives weird output like "

Share this post


Link to post
Share on other sites

Try this:sprintf(pelement->string, "M. %3.0f", (float)vmach );Doug

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...