It looks like you're new here. If you want to get involved, click one of these buttons!
[Map]
Scenario_graphic1 = Graphic
Scenario_graphic1_code = 1
Begin = Graphic
Begin_code = 2
End = Graphic
End_code = 3
Map_line1 = 1113111
Map_line2 = 1111111
Map_line3 = 1111111
Map_line4 = 1112111
int i = 1;
orxSTRING scenario;
orxConfig_SelectSection("Map");
do{
snprintf(constantName, sizeof(constantName), "%s%d", MAP_CONSTANT_NAME, i);
scenario = orxConfig_GetString(constantName);
orxLOG("%s - %s
", constantName, scenario);
if (*scenario == ''){
orxLOG("Nothing more to print.
");
}
else{
orxLOG("Read the string: '%s'.
", scenario);
}
i++;
}while(i < 5);
Comments
Totally out of topic but I'd suggest to use a list for your map instead, for more convenience:
Mmh, I'm actually surprised this compiles without complaining. Which compiler / version of orx do you use?
orxConfig_GetString() returns a const orxSTRING.
Beside that, assuming your constantName buffer is big enough and that your MAP_CONSTANT_NAME contains the right case-sensitive prefix, I don't see anything wrong with your code.
Also you should use the PushSection/PopSection instead of SelectSection, otherwise some other code might not end up using the section they were expecting.
Lastly, if you use a list, no need to printf-ing the key anymore and you can query the number of elements in the list with orxConfig_GetListCounter, and orxConfig_GetListString to get the desired element.
Let us know if the const solved the issue or if you still have some troubles there!
Well, being static wouldn't really make a difference, I can change the content of a static variable, as long as its address is returned to me by a function where its context is declared.
@ iarwain:
I am using Code::blocks for windows 7 64 bits.
It compiles and works with char*, it gives me a warning though. I changed it to const orxSTRING and it works too, with no warnings.
About the list, well, a bit too late now, got it working already yesterday, had to used a few void* tough
Thanks a lot for the replies guys.
Did you compile orx in 64bit or are you using a 32bit version? I know the 64bit linux version works just fine but I don't think anybody used a 64bit windows version yet, so just curious.
Heh no worries, I forgot to write an example in my last post anyway, here it is, maybe it'll be helpful for someone else!
You're welcome! Don't hesitate if you have any other questions.
I'm probably wrong about that anyway...
@Knolan: Yep, that would be a 32bit version. Really outdated if you ask me, the current SVN one is much more advanced.