Jump to content
  • Advertisement
Sign in to follow this  
FGFS

get string value from x-plane

This topic is 1258 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!