String format ?

Previous topic - Next topic

Glint

Which is the best way to format/combine a string and a value in GLbasic ?
For example DrawSprite "Alien."
  • where "Alien" is the sprite name and x is the index of an enemy you want to use, in this example 2, resulting in DrawSprite Alien.2.
    Hope that makes sense.

Kitty Hello

Code (glbasic) Select

number = 1
string$ = "Alien." + number + ".png"
PRINT string$, 0,0
SHOWSCREEN
MOUSEWAIT


Like this?

Moru

My guess is this is what he wants: Can't remember sprite/object numbers

Since he wants to draw a sprite with the name Alien.2 and so on, this code makes it easier :-)

Glint

Thanks guys. The first two answers were what I was looking for, although Moru's link will be handy for me too. Too many numbers give me brain freeze, it's like my brain has a small 1k memory cache.    ;/

Glint

>for tight loops, a 1K cache is more than you need....

In that case...time to defrag my brain  :S