naming variables from strings

Blitz3D Forums/Blitz3D Beginners Area/naming variables from strings

B2(Posted 2010) [#1]
Hi, I am new to this forum just have a quick question about blitz. I have been working on a project for a little while now but I have stumbled across an issue. I am creating a loading sequence for all of the content that is required in my game. An I have been using a general type to be used to cycle through over and over. But I know latter on I want to use each type again the issue is each type is named the same. So what I wanted to see is if its possible to create a type or variable handle name based off a string previously defined?



In the Select Case loop where C is thats where I am looking to try to name the variable based off the string. Thank you it would be greatly appreciated. :)

PROBLEM RESOLVED

Last edited 2010


H&K(Posted 2010) [#2]
Dont

Learn about scope

Call the one you working on "temp" and store them all in a list, (or an array)

http://www.blitzbasic.com/b3ddocs/command.php?name=First&ref=2d_cat

Last edited 2010


B2(Posted 2010) [#3]
Hey H&K thanks for your response. I am having a little bit of trouble trying to grasp the concept. I was wondering if you could possibly demonstrate just a simple code example. I am a novice programmer at this point but I am trying to learn. So bare with me, I am pretty sure this is something simple and I am just over thinking it.

Thanks for your help,
B2


Serpent(Posted 2010) [#4]
You can't name Blitz variables from strings, but you can create an array where you assign strings to variables.

It looks like you only need to store integers right? (As handles to the images?)

If so, something like this should work:



It's heavily commented because I'm not sure of what (if any) experience you've had with Blitz types, and please post if you don't understand anything.


H&K(Posted 2010) [#5]
Re-link

http://www.blitzbasic.com/b3ddocs/command.php?name=First&ref=2d_cat

I know, I know, bit lazy of me.

Please read the code, which is exactly what you asked me to post ;) Pay attention to the line ; Create 100 crafts, with the unique name of alien


B2(Posted 2010) [#6]
Hey guys thanks for your help. I got it now and it works. I am sorry Serpent I forgot to mention that but that code with the explanations helped. The code loads now. I new this was going to be a thing to simple fix. And yea I haven't had much practice with blitz types. I am brand new to the coding world so I am just starting to learn everything. I Do feel though that I have a better understanding of Types now and feel more comfortable using them. Problem Resolved.

Thanks,
B2