What I'm using it for is loading a text file storing texture info such as scale, mitmap flags, and texture properties. This info is read into a variable of the texture type I made. However this variable could be Stone, Brick, Grass, Dirt, ect... of the texture type. So I'm using a function that opens the text file passed through the parameter, and reads the text file data into the variable of type Texture. So for example:
//if file was "Dirt.txt"
Function LoadTexture(file$)
Open to read 1,file$
Read float 1,Dirt.XScl
Read float 1,Dirt.YScl
Close file 1
Endfunction
But somehow it needs to know what variable to use. It needs to know that I want to store the Xscl in Dirt. I have no efficient way of doing this though. I would need to do:
//if file was "Dirt.txt"
Function LoadTexture(file$,Var$)
Open to read 1,file$
if Var$="Dirt"
Read float 1,Dirt.XScl
Read float 1,Dirt.YScl
endif
if Var$="Grass"
Read float 1,Grass.XScl
Read float 1,Grass.YScl
endif
if Var$="Rock"
Read float 1,Rock.XScl
Read float 1,Rock.YScl
endif
Close file 1
Endfunction
But if I have 500 textures, this is not really feasible unless I want to spend 8 hours copying, pasting and typing each variable.
In C++ the solution would be simple, have the function accept a parameter that points back to the variable passed.
This would be a short example of what I'm trying to acheive in C++.
#include <iostream>
#include <cstdio>
struct test
{
int num;
};
void Inc(test *var);
int main(int argc, const char* argv[])
{
test i;
i.num=5;
Inc(&i);
// Should print "6"
printf("%d\n",i.num);
}
void Inc(test *var)
{
var->num = var->num + 1;
}
However Dbpro is not c++...
My computer surpasses all the technologies of the day. What computer do I have?