TGC Codebase Backup



Learning about arrays for beginers by Area 51

19th Sep 2006 20:49
Summary

Are you new to dark basic? learn about arrays here.



Description

Beginers, welcome! Do you know what an array is or how it works? use this short code to learn something new!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    mydata$(2,1)="You have chosen (table) 2, (box) 1."
mydata$(2,2)="You have chosen (table) 2, (box) 2."
mydata$(2,3)="You have chosen (table) 2, (box) 3."
mydata$(3,1)="You have chosen (table) 3, (box) 1."
mydata$(3,2)="You have chosen (table) 3, (box) 2."
mydata$(3,3)="You have chosen (table) 3, (box) 3."
mydata$(4,1)="You have chosen (table) 4, (box) 1."
mydata$(4,2)="You have chosen (table) 4, (box) 2."
mydata$(4,3)="You have chosen (table) 4, (box) 3."
mydata$(5,1)="You have chosen (table) 5, (box) 1."
mydata$(5,2)="You have chosen (table) 5, (box) 2."
mydata$(5,3)="You have chosen (table) 5, (box) 3."

print "This will show you how to understand arrays."
print
print "Think of an array like a big room."
print "In the "room" there are lots and lots of tables."
print "In this example, there are 5 "tables"."
print "Now, imagine that on each of these tables, there are lots of boxes."
print "In this example, there are 3 "boxes" on each table."
print "Each of these boxes can hold a number or a string."
print "These boxes can also hold smaller boxes, but we won't get into that."
print
print "So now we have 5 "tables" and 3 "boxes" on each "table"."
print
print "An array was made here to show you how it works."
print
print
print "( press a key to continue )"
wait key


choose:
cls
input "Choose a "table" >  ";x
input "Choose a "box" >  ";y
if x=0 then goto sorry
if x>5 then goto sorry
if y=0 then goto sorry
if y>3 then goto sorry

cls
wait 1000
print mydata$(x,y)
print
print "Dont believe me? Check the source code!"
print "( press a key )"
wait key
goto choose


sorry:
cls
print "Remember, there are 5 tables and 3 boxes in each tables"
print "in this example."
print
print "( press a key )"
wait key
goto choose