tgibson
Resource contributor
- Messages
- 11,757
- Country

The whole idea of efficient coding is to have code run as little as possible, thus saving computer time for other things (like frame rate). So if code does not need to be running all the time and there is an alternative to that, why not use it? That said, setting the value of L: variables over and over again takes VERY little computing power and you would need an awful lot of them to affect things by even a little. BTW, this is NOT true with K: commands, which DO use a lot of FS resources and should be run as little as possible.
You have said that when the FLD State variable goes to 0, then you want the load action to occur. For this to happen properly we need to set our flag variable (TankSub) to 1 at the same time. You can do this two ways:
1. The way you do it now, is:
a. Somewhere in a Click statement you change the value of the FLD State variable to 0.
b. The code above then senses this and changes the TankSub variable to 1. You run this code over and over and over again, slowing down your panel.
2. The more efficient way:
a. Somewhere in a Click statement you change the value of the FLD State variable to 0.
b. In that same Click statement you can ALSO change the value of the TankSub variable to 1. Now that code is only run once, when you click. Yes, it would be run more often if you clicked more, but not 18 times per second like in #1!
As for going into negative values, just check that the result of the subtraction is less than 0, and then reset it to 0.
Hope this helps,
You have said that when the FLD State variable goes to 0, then you want the load action to occur. For this to happen properly we need to set our flag variable (TankSub) to 1 at the same time. You can do this two ways:
1. The way you do it now, is:
a. Somewhere in a Click statement you change the value of the FLD State variable to 0.
b. The code above then senses this and changes the TankSub variable to 1. You run this code over and over and over again, slowing down your panel.
2. The more efficient way:
a. Somewhere in a Click statement you change the value of the FLD State variable to 0.
b. In that same Click statement you can ALSO change the value of the TankSub variable to 1. Now that code is only run once, when you click. Yes, it would be run more often if you clicked more, but not 18 times per second like in #1!
As for going into negative values, just check that the result of the subtraction is less than 0, and then reset it to 0.
XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 0 == (L:TankSub, number) 2 == && if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) - (>L:EAFS, enum) 0 (>L:TankSub, number) (L:EAFS, enum) 0 < if{ 0 (>L:EAFS, enum) } } </Value>
</Select>
</Element>
Hope this helps,


