Assign variable

Blitz3D Forums/Blitz3D Beginners Area/Assign variable

cermit(Posted 2004) [#1]
Hi, is there any way to assign a variable that has the name of a strings letters?

str$ = "variable_one"

Global variable_one

Its hard for me to explain but i hope you understand what i mean :)


soja(Posted 2004) [#2]
No, it's just the way the compiler works. By the time you run the program to get the string variable, the actual variable name is no more. It's only valid until compile time.


cermit(Posted 2004) [#3]
ok.. then nevermind :)


puki(Posted 2004) [#4]
Out of interest "Cermit", what are you trying to do?


cermit(Posted 2004) [#5]
Ok, say i load a txt file into Blitz, the txt file contains a filename ex- "model.b3d" and a name ex- "house".
So i want to assign the name "house" as the variable to load the model like this:

house = LoadMesh("model.b3d")

Its sort of for an application.


puki(Posted 2004) [#6]
I haven't fully grasped what you are doing, but I think it's possible to do what you want on a pre-calculated basis.

How many base variables are you planning on using? You mention 'house' but are there more of them ('car', 'tree', 'garden', etc.)?

Are you trying to match data to the type of thing it is - ie, I assume model.b3d is a model of a house? Is there more than one house, or just the one?

Is the text file static or is it dynamically changing - will the content of the text file be change while your program is running?


cermit(Posted 2004) [#7]
This is for a 3d world editor, the text file is mostly needed when loading a world into a game.
So in the world editor you can name the objects(models) that you want in the world.
Once the world is loaded into a game i want to acces the objects with their names, like
moveentity house, 0, 0, 1 ;etc..

This isnt very necesary but it would be nice to have this feature.


puki(Posted 2004) [#8]
Yeh, but with some objects of a particluar type (ie house, car, tree) are there going to be more than one of them?

Originally, I was thinking the text file could containe a flag for each object which denotes the object type (1=house, 2=car, 3=tree, etc.).

However, my brain is a bit slow due to birthday excitment so I may be going nowhere with this.


cermit(Posted 2004) [#9]
Yes, its suppose to be more then one type of object.
Ok, thanks anyway :) that stuff with flags is a good idea.

And happy birthday again :)


eBusiness(Posted 2004) [#10]
Ok, skip the vars called house, car etc. Make two arrays, one integer for storing the handles, and one with strings for storing the names, this way you will neither have to predefine what names are valid. If you want to acces an entity using it's name, do a search for the name in the string array. You can probably do something similar using types, but that's not my area.


cermit(Posted 2004) [#11]
Yeah :) thats a good idea too, thanks!


_PJ_(Posted 2004) [#12]
I wanted to be able to do something similar I think, I wanted to be able to Read a line ($ variable) from a text file,then read from a specific other file based on this text - however, the compiler didnt like it because of the order in which it compiles, it did not know the $ to open the correct file. The use of specially ordered Include "xxx.bb" Commands bypassed this, but made for somewhat messy structure.


Rob Farley(Posted 2004) [#13]
I would suggest loading all of your objects into a type and have a string within that type identifying what kind of object it is.