Procedure to Set Booleans
Author |
Message |
Prince Pwn
|
Posted: Tue Mar 27, 2007 8:34 pm Post subject: Procedure to Set Booleans |
|
|
What I would like is one procedure that will set all booleans but one I specify in the argument to false. Like this is what I want below:
Turing: |
procedure SetAllFalse (onlyTrue : boolean)
personalIconFade := false
userIconFade := false
documentsIconFade : false
end SetAllFalse
SetAllFalse (userIconFade := true)
|
I would like the above to turn all the booleans false within the procedure except for userIconFade.
Here is the actual part of my code and I have no procedure yet to do it, that's where I need the help.
Turing: |
if (startClicked) then
if mousex > 220 and mousex < 320 and mousey > 395 and mousey < 415 then %main picture
if ~personalIconFade and ~documentsIconFade then
Fade (personalIcon, fadePicDelay)
end if
personalIconFade := true
userIconFade := false
documentsIconFade := false
elsif mousex > 220 and mousex < 320 and mousey > 365 and mousey < 382 then %documents picture
if ~personalIconFade and ~userIconFade and ~documentsIconFade then
Fade (documentsIcon, fadePicDelay)
end if
personalIconFade := false
userIconFade := false
documentsIconFade := true
else
if ~userIconFade and ~documentsIconFade then %default user picture
Fade (userIcon, fadePicDelay)
end if
userIconFade := true
personalIconFade := false
documentsIconFade := false
end if
end if
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Clayton
|
Posted: Tue Mar 27, 2007 9:05 pm Post subject: RE:Procedure to Set Booleans |
|
|
Right now, the only thing I can think of is to have an array of booleans and keep track of them by integer reference. Less readability, but the best of the two ways I can think of doing this.
The other (worse) way of doing it would be to pass a variable argument to the procedure. Set all of your booleans to false, then set the variable argument to true. By far, this is a bad way to do it, and is not recommended. |
|
|
|
|
|
Cervantes
|
Posted: Tue Mar 27, 2007 9:48 pm Post subject: RE:Procedure to Set Booleans |
|
|
Prince Pwn wrote:
Turing: |
SetAllFalse (userIconFade := true)
|
Why not do something simpler?
Turing: |
SetAllFalse()
userIconFade := true
|
|
|
|
|
|
|
Prince Pwn
|
Posted: Wed Mar 28, 2007 9:01 am Post subject: RE:Procedure to Set Booleans |
|
|
Oh ya to above post, good idea =D
I tried it when I first started my program and it was buggy but now it works. |
|
|
|
|
|
|
|