concating (sp?) help
Blitz3D Forums/Blitz3D Beginners Area/concating (sp?) help
| ||
Hi I am trying to get the following loop to work, but I cant seem to find documentation or the proper way to concate the string, help please :)for i = 1 to 13 light+i = CreateLight() next the light+i is not working! |
| ||
You can't concatenate a number onto a variable name to make a new variable. (That's what it looks like you're trying to do.) Instead, use an array: Dim light(13) For i = 1 To 13 light(i) = CreateLight() Next FYI, concatenation is really only a string operation - not for variable names, operators, int, floats, etc. (Though Blitz does automatically convert -- or cast -- ints and floats to strings when you use the + operator on them with another string.) |
| ||
Can an integer array object be an entity handle? I tried it once, but it didn't work for me. Maybe I messed something up.... |
| ||
I was just going to whip up a MMORPG for my first project, but then I decided to think BIG! What's that then, a well lit black screen? :P |
| ||
Keep in mind, that when you see an equals sign (=), it is normally either being used to assign something to a variable, or it is being used to compare two items. variable = expression if variable=expression then ... In the first case, there can only be one target to receive the result. In the first example above, light+i is not a target, it is an expression in its own right. So light+1 cannot be used in the first form, but might be used in the second form. You might occasionally see another varfiation, such as variable=expression=expression. This form invites a comparison of expression to expression, then assigns the True or False result to the variable. And of course, another special case exists when = is used with < or > to indicate less than or equal to, or > than or equal to, and finally, you can assign values to constants, which appear to be variables, but actually cause the compiler to use the assigned value when and where the constant appears in the program. |