Posts: 189
Threads: 22
Joined: Mar 2023
Reputation:
12
10-20-2024, 06:08 PM
(This post was last modified: 10-20-2024, 06:21 PM by NakedApe.)
I've been trying to clean up IF statements in the game I'm working on. Would it be hard to have SELECT CASE work not just with variables but also with arrays and UDTs?
Imagine:
SELECT CASE flag ' (booleans)
CASE .drawShip: .........
CASE .explode: .........
CASE .endRound: .........
END SELECT
Or:
SELECT CASE fatArray()
CASE 0 TO 50: ..............
CASE 51 TO UBOUND(fatArray): ..........
END SELECT
Would this be cool / useful?
Posts: 189
Threads: 22
Joined: Mar 2023
Reputation:
12
Yeh, I wasn't very clear. Let's say you're using a boatload of true/false flags to turn on and off various events, timers and subs (as I am). Instead of separately naming _byte variables for each flag (FLIP_ON_SHIP = TRUE, START_GAME_TIMER = TRUE), let's say for organizing purposes you stick them all in UDTs (like I did), like
Type FLAG
FLIP_ON_SHIP As _BYTE
START_GAME_TIMER As _BYTE
ETC.
End Type
It would be nice now to be able to use a SELECT EVERYCASE structure to tick through the booleans (in an array or UDT) and act on them instead of using a big bunch of IF statements. Or is there simply a better way to organize event flags for complicated programs?
Posts: 734
Threads: 30
Joined: Apr 2022
Reputation:
43
Why not just put them in an array and then enumerate through them?
Tread on those who tread on you
Posts: 189
Threads: 22
Joined: Mar 2023
Reputation:
12
Thanks, Sprigssy. I did use an array for sound flags just to mark them as played, but I guess I need an example. How would I structure a Boolean flag in an array to then cause an action in the program? Use On x Gosub? Or what are you thinking. Thnx.
Posts: 189
Threads: 22
Joined: Mar 2023
Reputation:
12
Oh, I see. Duh. Something like this?
For c = 0 to Ubound(flag)
If flag(c) then
Select case c
-
End Select
End If
Next c
Loop u
Do
C= C + 1
If flag(c) then
Select Case
-
End Select
End if
Loop until c = Ubound(flag)