TGC Codebase Backup



Array Tutorial by MartinS

15th Jan 2006 2:30
Summary

This tutorial teaches you how to use an array.



Description

This tutorial is intended to teach begginer programmers how to use arrays, instead of writing cuontless extra lines of code. It may not make such a big pont here, but if you have 50, 100, 200 "prints", this might prove usefull!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `This tutorial is going to teach you how to use arrays.
`I hope you enjoy it and I hope it saves you many lines of code!
`
`Martin Simpson aka Games2live
`
`PS If you want help understanding something email me at
`martins94@gmail.com

`First we declare our array candy$. The 4 in perenthis
`shows how many variables there is.
dim candy$(4) as string

`We indicate what each of the variables are:
   candy$(1) = "Snikers"
   candy$(2) = "Smarties"
   candy$(3) = "Skittles"
   candy$(4) = "Mars Bars"

`Now we are making a simple for next, that will show
`the text
for kind = 1 to 4

`The kind variable in candy$ is telling the program
`show the first variable, the second, third, and fourth
   print "I like to eat " + candy$(kind)

next kind

`Now were simply telling the program to exit when the user
`presses escape
do

   if escapekey()=1 then end

loop