Root / Programming Questions / [.]
put a label before your DATAs, like this:
@LABELNAME DATA "B",10000,"etc." DATA ... ...then use RESTORE @labelName to start reading the DATA at that label: use READ variableName to read a single value from the DATA (you'll probably put it in some kind of loop) you can also READ multiple values at once, like: READ firstVariable, secondVariable, ...
You can set the definition number and the position on the data and the load it on other part of your code. Example:
'Array that hold the sprites instances. VAR sprites sprites=loadSprites() 'If you want to reload the sprites, then do the following clearSprites sprites sprites=loadSprites() '================================================ DEF loadSprites() VAR sprites VAR SP,DN,X,Y RESTORE @SPRITES WHILE 1 READ DN,X,Y IF DN==-1 THEN BREAK SP=SPSET(DN) SPOFS SP,X,Y PUSH sprites,SP WEND RETURN sprites END DEF clearSprites ARR VAR SP WHILE LEN(ARR)>0 SP=POP(ARR) SPCLEAR SP WEND END @SPRITES DATA 0,200,100 DATA 1,80,80 DATA -1,0,0
DEF without ENDI can't see your code but that means that you didn't close a DEF with an "END" sentence.
also, where do i put the DATA "B" for the sprite?I didn't. You can't set a sprite with a string. (However, you can make a static map data structure to store sprite definition number(value) asosiated with strings(key).)
? spriteMap("B") DEF spriteMap(S$) IF !CHKLABEL("@"+S$) THEN RETURN -1 'NO RESULT GOTO "@"+S$ @A RETURN 0 @B RETURN 1 END