WDL code

Posted By: Anonymous

WDL code - 05/01/01 22:48

Ok, Im mostly a "Hands On" kind of programmer, I prefer step by step instructions on how to do something, which is why i've resorted to the forums, rather than the WDL manual on this one...
Im having trouble with variables.
Heres what i got.

Var test;

function do_this1
{
(do something here)
Var test = 1;
}

funtion do_this2
{
(do something else)
Var test = 0;
}

Action DOTHIS
{
MY.ENABLE_CLICK = ON;
If (test == 0)
{
MY.EVENT = do_this1;
}
If (test == 1)
{
MY.EVENT = do_this2;
}
}

What I want is to be able to click on something once and something happens...
Then when I click on it the second time for it to do something else, then reset the action so next time you click on it, it will do the first thing and so on....
I can get my first function do_this1 to work properly, but i dont think it sets the variable to =1 correctly, cause the second time i click on it, it does nothing. Both functions work properly as i've been playing around with the "If (do_this1 == 0)" changing it to a 1 and that works.

I could use a few tips on how to make a variable equale a specific number.


Posted By: Anonymous

Re: WDL code - 05/01/01 23:36

one way to do this is simply turn off the first button and turn on a second and attach your new function to it.
Posted By: James Snydstrup

Re: WDL code - 05/02/01 05:29

Shovei51:

Here is an easier way to toggle the 'test' variable.

test = ABS (test - 1);

This will toggle test between 0 and 1.

Posted By: Anonymous

Re: WDL code - 05/02/01 08:07

hehe you are right , that much easier
Posted By: Anonymous

Re: WDL code - 05/02/01 17:00

thanx for the tips guys,
I'll try that.
Posted By: WildCat

Re: WDL code - 05/02/01 21:51

James,

That was an elegant one-liner! To think all this time I'd been doing it the hard way...

-WildCat

© 2023 lite-C Forums