green text is being edited and should not be considered
relevant to the tutorial. for a while, it will make up
the bulk of this section.
black text has been edited to be more accurate with
regards to puppybasic.
........................................................................
arrays
1 of 7
an intro to puppybasic
chapter 16: arrays
........................................................................
........................................................................
arrays
2 of 7
arrays make variables more useful and offer a powerful way to handle
data. for instance: instead of the following code:
READ a
READ b
READ c
READ d
READ e: PRINT a;b;c;d;e;
DATA 52,21,19,45,73
........................................................................
........................................................................
arrays
3 of 7
you could replace it with this:
FOR q=1 TO 5
READ ab(q)
NEXT q
FOR q=1 TO 5
? ab(q);
NEXT q
...which seems unspectacular until you have a bit more than five
variables to name.
........................................................................
........................................................................
arrays
4 of 7
another advantage of arrays is that you don't need to know exactly how
many items you will be storing. for instance:
DIM q$(1 to 100)
OPEN "file" FOR INPUT AS #1
DO: c=c+1
LINE INPUT #1, q$(c)
LOOP UNTIL EOF(1) or c => 99
q$(c+1) = CHR$(26): c=0: close
........................................................................
........................................................................
arrays
5 of 7
will open "file" and store each line in q$(c), c standing for which line
is stored there. this example limits the possible number of lines to 99,
and sets the last line to ascii 26 to mark it as the last.
note the use of DIM(1 to 100) which is required for arrays more than 10
units in size. it is also necessary to use dim for multidimensional
arrays:
........................................................................
........................................................................
arrays
6 of 7
DIM twod(1 to 5, 1 to 5) AS INTEGER 'integers let you use wider arrays
will allocate an array of 5 units, and each unit will also have 5
subunits:
twod(1,1) twod(2,1) twod(3,1) twod(4,1) twod(5,1)
twod(1,2) twod(2,2) twod(3,2) twod(4,2) twod(5,2)
twod(1,3) twod(2,3) twod(3,3) twod(4,3) twod(5,3)
twod(1,4) twod(2,4) twod(3,4) twod(4,4) twod(5,4)
twod(1,5) twod(2,5) twod(3,5) twod(4,5) twod(5,5)
........................................................................
........................................................................
arrays
7 of 7
you may find that although 3-dimensional arrays are possible, but that
the limitations won't allow a 3d array large enough to be useful all
that often. (i do know someone who used one for a card game, and you may
be able to use one for a program to solve rubik's cube... although such
a program already exists.)
incidently, puppybasic tends to demand that most DIM statements come at
the beginning of a program, but you can change the limits of some arrays
using REDIM.
-= end of chapter 16 =-
........................................................................
an intro to puppybasic (chapter 16)
this content is public domain.
........................................................................
click here to go back to the contents page
Before You Post, Please Note...
-> Please Note: By Posting, you agree to submit the contents of your post to the Public Domain <- SEE: howto post to this blog
Friday, February 2, 2007
puppybasic intro ch. 16 - arrays
Subscribe to:
Post Comments (Atom)
34 comments:
buy tramadol online buy tramadol us pharmacy - tramadol 100mg get you high
xanax online how long for xanax to show up in drug test - xanax drug history
buy tramadol online buy tramadol usa next day delivery - ultram tramadol withdrawal symptoms
buy tramadol online buy tramadol online overnight - buy tramadol online overnight delivery
cheap xanax xanax withdrawal impotence - generic xanax vs brand name xanax
generic xanax xanax generic pink - white round pill generic xanax
buy tramadol online tramadol to get high - can order tramadol online
generic xanax xanax generic cost walmart - can buy xanax online yahoo
buy tramadol online tramadol vs percocet - 150 mg tramadol high
xanax online buy xanax online us - 8 bars of xanax
carisoprodol 350 mg carisoprodol buy online no prescription - soma carisoprodol ingredients
xanax online xanax high feel like - where to buy cheap xanax online
buy tramadol online tramadol addiction time - tramadol hcl amneal
buy tramadol online tramadol for dogs cough - taking 3 50mg tramadol
cialis online buy cialis viagra levitra - online pharmacy viagra cialis
buy cialis from canada cialis online ricetta - cialis price at target
xanax online xanax muscle relaxer - generic xanax vs. name brand
buy cialis online generic cialis online us - cialis men
where to buy cialis online no prescription generic cialis bangkok - cheap kamagra cialis
xanax online cheap 2mg xanax bars - viagra xanax drug interactions
cialis online buy cialis drugstore - reputable online pharmacy cialis
http://buytramadolonlinecool.com/#51726 tramadol online in usa - tramadol overdose damage
buy tramadol tramadol 50 mg vs hydrocodone - overdose from tramadol
buy tramadol in florida buy tramadol online nz - tramadol hcl 50 mg 319
buy tramadol online tramadol addiction studies - tramadol for dogs after surgery
buy tramadol tramadol for dogs and people the same - tramadol 50 mg dosing
buy tramadol for dogs buy tramadol online no prescription usa - tramadol bargain discount code
http://landvoicelearning.com/#51438 tramadol withdrawal symptoms usa - order+tramadol+online+in+florida
http://ranchodelastortugas.com/#72895 drug interaction zofran xanax - xanax snorting
buy tramadol online cod overnight buy tramadol er - buy tramadol from usa
buy tramadol online legal buy tramadol online - tramadol 50mg tablets info
http://ranchodelastortugas.com/#50238 xanax overdose brain damage - signs drug abuse xanax
http://bayshorechryslerjeep.com/#rx xanax side effects weight gain - xanax effects kidneys
order tramadol online cod tramadol 100 er - buy tramadol overnight delivery
Post a Comment