Results 1 to 3 of 3
Thread: Use more then 1 varaible
-
02-01-2011, 01:48 PM #1
- Join Date
- Jan 2009
- Location
- Belgium
- Posts
- 61
Use more then 1 varaible
Hi i've been using phidget cards and real studio for some time but
now that it was time for a expansion I thought let me use the Opencockpit card.
And I can use some help. I want to manage some leds. The leds on or of depend on
more than 1 function.
Var 2, Link FSUIPC_IN Offset $3340, Length 4
var 3, Link FSUIPC_IN offset $092C, length 2
var 4, link FSUIPC_IN offset $3344, length 4 // need this one also
{
L0 = TESTBIT V2,14
if L0 = 0
{
&leds2 = 0
&leds3 = 0
}
else
L1 = TESTBIT V3,0
if L1 = 1
{
&Leds2 = 0
&leds3 = 0
}
else
{
&leds2 = 1
&leds3 = 1
&Leds4 = 1
}
}
var 5, name Leds2 link iocard_out, output 15
var 6, name Leds3 link iocard_out, output 13
I seem to miss something because it's not working. I hope some one can help
to show how to use more then 1 varaible to manage the led.
regards and thnx,
henri
-
02-02-2011, 05:03 AM #2
Re: Use more then 1 varaible
Hi henri,
It does not work because your program does nothing if Var 2 or Var 3 changes value.
You have to take an approach like this (call a subrutine if one of the related variables changes, and in that subroutine you set the leds according to the states of these variables):
Code:Var 2, Link FSUIPC_IN Offset $3340, Length 4 { CALL &CtrlLeds } var 3, Link FSUIPC_IN offset $092C, length 2 { CALL &CtrlLeds } var 4, link FSUIPC_IN offset $3344, length 4 // need this one also { CALL &CtrlLeds } Var 10 Link SUBRUTINE Name CtrlLeds { L0 = TESTBIT V2,14 if L0 = 0 { &leds2 = 0 &leds3 = 0 } else { L1 = TESTBIT V3,0 if L1 = 1 { &Leds2 = 0 &leds3 = 0 } else { &leds2 = 1 &leds3 = 1 // &leds4 = 1 not defined ? } } } var 5, name Leds2 link iocard_out, output 15 var 6, name Leds3 link iocard_out, output 13
regards,
Nico
-
02-02-2011, 07:05 AM #3
- Join Date
- Jan 2009
- Location
- Belgium
- Posts
- 61
Re: Use more then 1 varaible
OK so that's how it works. Great and thanks for pointing the right direction.
regards,
Henri
Candid connections: Platform for casual relationships Live Women Prime Сasual Dating
Super Сasual Dating - Genuine...