Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Expanding SELECT CASE
#2
(10-20-2024, 06:08 PM)NakedApe Wrote: 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?

I honestly don't see how either of these would work.   

CASE .drawship    <-- what does this represent?  

TYPE POINT
    x as long
    y as long
END TYPE

DIM User AS POINT, Enemy AS POINT

CASE .x    <-- by itself, this does nothing.   How could I tell the difference between User.x and Enemy.x?



And the second doesn't look like it's actually using the array either.  It looks more as if you're doing a select case with the index of the array:

SELECT CASE index
   CASE 0 TO 50
   CASE 51 TO UBOUND(Array)
END SELECT



I'm all for expanding things to make them more useful.  I just don't see how these would work in the cases you've provided.
Reply


Messages In This Thread
Expanding SELECT CASE - by NakedApe - 10-20-2024, 06:08 PM
RE: Expanding SELECT CASE - by SMcNeill - 10-20-2024, 06:40 PM
RE: Expanding SELECT CASE - by NakedApe - 10-20-2024, 08:22 PM
RE: Expanding SELECT CASE - by SpriggsySpriggs - 10-24-2024, 11:43 AM
RE: Expanding SELECT CASE - by NakedApe - 10-24-2024, 07:50 PM
RE: Expanding SELECT CASE - by NakedApe - 10-24-2024, 08:23 PM



Users browsing this thread: 3 Guest(s)