News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Using Restore To Search For String Labels

Started by kevin, January 02, 2006, 07:31:28 AM

Previous topic - Next topic

kevin

This example demos how you can embed strings within data statements, then use Restore to locate them dynamically.  A lot easier than hard coding "Labels" manually like you would in other languages ..


PlayBASIC Code: [Select]
; set PB auto counter to 1
AcSet=1

; Level Id
Data "Level"+str$(ac(1))
Data 1,2,3,4


; Level Id
Data "Level"+str$(ac(1))
Data 5,6,7,8

; Level Id
Data "Level"+str$(ac(1))
Data 9,10,11,12

; Level Id
Data "Level"+str$(ac(1))
Data 13,14,15,16



Constant Max_number_of_levels = ac(1)




do

Cls 0

Level=rndRange(1,Max_number_of_levels-1)
; Random Pick the Level you wish to read from
Restore "Level"+str$(level)


Print "Reading data from"+ReadData$()
For lp=1 to 4
Print ReadData()
next
print ""


sync
waitkey

loop