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.

Newcomers DBPro Corner / Using variables for dim

Author
Message
Enclosed
20
Years of Service
User Offline
Joined: 8th Jun 2004
Location: Colorado
Posted: 25th Feb 2006 06:33
I am using DB Pro. I am having trouble figuring out how to do this and somebody probably has a quick answer that will save me tons of time.
This is sorta hard to explain, but I would like to use a for statement to create dims. Lots of dims to be exact. For example I would like to do this.

where the x in dim would do something to the effect of doing

I cant just use integers as strings either so how can I mass produce these dim things?

I am doing this to create storage of a sprites settings, so z is the number of sprites. This way each sprite number has a corresponding dim with the same number.

So sprite 1 is a picture and 1(3)=a,b,c, where a b and c are values corresponding to sprite one.

Even if this were to work how would I then alter the dim of a sprite when the sprite number is all that is known?

If anybody has the slightest clue as to what I am trying to explain or ask, please take the time to answer. I possibly jsut have a bad system worked out here. thanks for your time.
SirFire
19
Years of Service
User Offline
Joined: 4th Apr 2005
Location: North America
Posted: 25th Feb 2006 08:58 Edited at: 25th Feb 2006 09:04
I think what you want is a multidimensioned array:

dim a(20,20)

[edit]
looking over your post again, I think you are trying to store coordinates for sprites or something? Here is how I would do it:

TYPE mytype
posx as integer
posy as integer
posz as integer
END TYPE
DIM msprite(20) AS mytype

Now you have an array of 20 elements, with each element holding 3 different values:

for x=1 to 5
msprite(x).posx=25
msprite(x).posy=93
msprite(x).poyz=543
next x
print msprite(3).posx
print msprite(3).posy
print msprite(3).posz
wait key

Is this what you are talking about?

Enclosed
20
Years of Service
User Offline
Joined: 8th Jun 2004
Location: Colorado
Posted: 26th Feb 2006 05:40
Wow, that will definently work! I'm actually not storing the positions of sprites, but whether they are collideable and such. Either way this will work awesomely. So DIM msprite(20) AS mytype makes 20 elements in the array and each element now stores posx posy and posz. Thanks a billion for this answer. I was thinking I was too incomprehensible for anyone to answer.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 27th Feb 2006 01:04
Enclosed, just remember that if you find yourself trying to generate static code, keywords, or in-code variable names -- from code, then most likely youre doing something wrong. It's a common mistake I have seen alot of people make when they begin to progress in their coding, and their ideas and logic start to flow, but the coding rules lag off for a sec.

Anyway thats been my experience in seeing other coders coming up, and I did it myself too, back in the day

FREE Automatic file updates for your distributed Games and Apps - see Program Announcements Forum - DBP Demo

Login to post a reply

Server time is: 2024-11-27 03:43:22
Your offset time is: 2024-11-27 03:43:22