Sign in to follow this  
Guest Bram

MAKE_STRING troubles

Recommended Posts

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
Help AVSIM continue to serve you!
Please donate today!

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