Sign in to follow this  
ddawson

Magic or science - do we really need that code?

Recommended Posts

I read Dai Griffiths' excellent summary on gauge programmingand I found something I could not believe. He states that thetwo lines in element callback functions are obligatory:FLOAT64 FSAPI active_units_update( PELEMENT_STRING pelement ){ FLOAT64 val=pelement->source_var[0].var_value.n; val = !val; ...}He also explains:"The first line in the body of the structure is an FS2K+ requirement even if you are not actually reading a Token Variable. It seems to be needed to trigger FS to check if the string needs updating. The next line does the dirty deed and forces FS to run an update; each time it runs through this line it simply inverts the previous value of val thus creating the change necessary to trigger the update function."Well, these were the first lines had I deleted from the code I inherited and it still works. On the other hand I can not theoretically imagine how a simple read (first line) and update (second line) instruction would trigger FS at all. These are not FS API calls but are direct memory manipulations and only the CPU knows about them, the FS core application will not. The memory area "belongs" to FS application, but I know no mechanisms throught which FS would have been informed about any reads or updates there.Gabor

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Never used such code. You are right, there is should be no difference

Share this post


Link to post
Share on other sites

Where can I find this summary on gauge programming?

Share this post


Link to post
Share on other sites

Martin,Look for sd2gau17.zip on flightsim.com. I'm not sure if the file is available here or not.Doug Dawson

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