Sign in to follow this  
FGFS

get string value from x-plane

Recommended Posts

Hi

how to get the string value of a x-plane dataref?

 

fms1 = XPLMFindDataRef ("sim/cockpit2/radios/indicators/gps_nav_id");

It says here that's a string:

http://www.xsquawkbox.net/xpsdk/docs/DataRefs.html

 

but here I cannot see how to get/display a string value:

http://www.xsquawkbox.net/xpsdk/docs/XPLMDataAccess.html

 

with this obviously I get errors:

    string Nfms1 = XPLMGetDataf (fms1);
    char    buff[256];
    sprintf(buff,"Current: %i\n", Nfms1);
    XPLMDrawString(color, PanelLeft1 + 70, PanelTop1 - 40, buff, NULL, xplmFont_Proportional);

 

Many thanks

 

Share this post


Link to post
Share on other sites

It would have been easier to help if you specify what "errors" you get, and if you try to understand them, you might be able to fix the problem yourself.

 

In this case, I'm guessing this line is your problem:

 

string Nfms1 = XPLMGetDataf (fms1);

 

since the manual says that GetDataf returns a float, not a string.

 

I think you need to use XPLMGetDatab to get bytes, since the manual says "sim/cockpit2/radios/indicators/gps_nav_id" is an array of bytes.

 

Maybe this will work?

 

char buff[256];

XPLMGetDatab(fms1,buff,0,256);

XPLMDrawString(color, PanelLeft1 + 70, PanelTop1 - 40, buff, NULL, xplmFont_Proportional);

Edited by Olof Hedman

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