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.

DarkBASIC Professional Discussion / Constructing a Variable Name in a FOR and checking it's value

Author
Message
JamesWalker101
16
Years of Service
User Offline
Joined: 14th Apr 2010
Location: England
Posted: 6th Oct 2013 17:45
I tried searching the forums, but I don't know what this is called. I will give an example of what I am trying to do.
I have set a variable called p10state, and p11state, all the way up to p1000state. The p stands for platform by the way, it dictates the type of platform.
I want to check every one of these states, and if it has a value of 1, to do something different to 2 or 0, they all have different collision and firing behaviours.
I construct the variable in the FOR like this:

This doesn't work. It constructs the variable name, but how to I check for a variable of that name?

I hope you understand.
Please help!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 6th Oct 2013 18:06 Edited at: 6th Oct 2013 18:06
You need arrays. You can't create variables the way you're doing in DBPro.



Arrays are your friend.

JamesWalker101
16
Years of Service
User Offline
Joined: 14th Apr 2010
Location: England
Posted: 6th Oct 2013 18:19
Thank You! Arrays are one area I have not covered yet, and your example makes sense.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 6th Oct 2013 20:39
No worries.

Login to post a reply

Server time is: 2026-07-07 11:21:40
Your offset time is: 2026-07-07 11:21:40