Jump to content
Sign in to follow this  
Guest harry3

lookup_var() ->value is always zero

Recommended Posts

Guest harry3

Hi!I've the following problem: When I read a token variable via lookup_var, the returned value is always 0 in this case! It worked with other tokens, but the token GENERAL_PANEL_CIRCUIT_ON always returns 0 even if it is 1.When I read the token via a macro, I get the correct state.(of course , I could take the value from there, but why should I if it would be much better via lookup_var...?!)Also a simple XML gauge returns the correct value.In the Gauge Creation Tut. it says that you should read the token and save it into a local variable to get around the zero-value problem.But it doesnt work.Here the not working code:case PANEL_SERVICE_PRE_UPDATE: lookup_var(&general_panel);//defined as: MODULE_VAR general_panel={GENERAL_PANEL_CIRCUIT_ON };general_a=general_panel.var_value.b;//general_a of type BOOLif(general_a){ SHOW_LISTELEMENT(pgauge->elements_list[0],1); ...}else{ HIDE_LISTELEMENT(pgauge->elements_list[0],1); ...}break;Regards,HarryEDIT: It's now working!!!I don't take the value from the member b, which should hold bool values, I now take the value as FLOAT64 and cast it to BOOL.Very senseless of Microsoft to introduce a bool member which doesn't hold any value...or is there any?general_a=(BOOL)general_panel.var_value.n;

Share this post


Link to post
Share on other sites

MODULE_VAR GENERAL_PANEL_CIRCUIT_ONvar = {GENERAL_PANEL_CIRCUIT_ON};int general_panel = GENERAL_PANEL_CIRCUIT_ONvar.var_value.n ;case PANEL_SERVICE_PRE_UPDATE:lookup_var(&GENERAL_PANEL_CIRCUIT_ONvar);break;if (general_panel == 1) {.... ;}As far as I am aware, there are only two types available, .n and .d... ;)


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
Guest harry3

Hi Bill!In the SDK you can find all the types of UNIVERSAL_VAR:typedef union UNIVERSAL_VAR {FLOAT64 n;'You can use any number.BOOL b;// any booleanENUM e;// any enumerated valueFLAGS f;// any flags fieldPVOID p;// any pointerVAR32 d;// any binary coded decimalVAR32 o;// any binary coded octal} UNIVERSAL_VAR, *PUNIVERSAL_VAR, **PPUNIVERSAL_VAR;But maybe only the n and d are really working!? Didn't try around any more after the gauge finally worked;-)Regards,Harry

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