Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / CASE Needs Literal

Author
Message
XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 18th Aug 2011 05:33
I was working on building the skeleton of my game. When I started working with the Select Case and End Case I noticed that it was requiring a Literal? Is there no way to use variables in place of Literals?
XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 18th Aug 2011 20:58
Just wanted to do double check on this.
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 19th Aug 2011 04:06
There is no way to use variables as parameters to CASE statements as they are traditionally designed as a very fast jump table to a piece of code without evaluating every possible condition. For example you could not use variables in the C++ switch statement for the same reason. Fortunately we added ELSEIF to AppGameKit so you can perform a slightly neater case style state engine such as:

IF A=1
REM CODE FOR A1
ELSEIF A=2
REM CODE FOR A2
ELSEIF A=YOURVAR
REM CODE FOR A3
ENDIF

As you can see, in the instance you can use A=YOURVAR as well as literals.

I drink tea, and in my spare time I write software.
XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 22nd Aug 2011 00:51
Constants work for states. This is what I was getting after.



Of course it flashes through the text prints, but the point is that it's going through the states.
You just have to set them up as constants and they work.

Login to post a reply

Server time is: 2024-04-16 17:54:50
Your offset time is: 2024-04-16 17:54:50