トピック
Kalvin Noctise

arrays

how do arrays work?
1そうだね
プレイ済み
返信[1]
親投稿
12Me21 12Me21
-create an array: DIM arrayname[size] -example: DIM EXAMPLE[7] -access an array element: arrayname[index] -example: EXAMPLE[3]=12 PRINT EXAMPLE[3] (arrays start counting at 0, and the maximum value is 1 less than the size)
0そうだね
プレイ済み
返信[2]
親投稿
V360 TheV360
12Me21 told how to make arrays, so I'll explain them. Arrays are special variables that can hold more than one value. There are 3 types of arrays that can each hold things in up to four dimensions. (you'll mostly use the first 2) The integer array holds numbers but can't store decimals, the real array holds numbers that can have decimals, and the string array that can hold text.
0そうだね
プレイ済み
返信[3]
親投稿
Kalvin Noctise
can you use string with arrays?
0そうだね
プレイ済み
返信[4]
親投稿
12Me21 12Me21
yes, just add a $ to the end of the array name
0そうだね
プレイ済み
返信[5]
親投稿
Hanzo rzsense
We can treat a string variable itself as an array as follows. S$="ONE" ... S$[0]=="O", S$[1]=="N", S$[2]=="E" Multiple dimension arrays are also available as follows. DIM S$[3]:S$[0]="ZERO":S$[1]="ONE":S$[2]="TWO" ... S$[1][0]=="O", S$[1][1]=="N", S$[2][1]=="W" ... Could you confirm them yourself?
0そうだね
未プレイ
返信[6]
親投稿
Kalvin Noctise
how do you use 2d arrays?
0そうだね
プレイ済み
返信[7]
親投稿
12Me21 12Me21
DIM ARRAY[size1,size2] ARRAY[index1,index2]=value
0そうだね
プレイ済み
返信[8]
親投稿
Kalvin Noctise
so these work like rows and columns?
1そうだね
プレイ済み
返信[9]
親投稿
V360 TheV360
Pretty much. They're useful for storing maps.
0そうだね
プレイ済み
返信[10]
親投稿
Kalvin Noctise
ok then, thanks guys!
0そうだね
プレイ済み
返信[11]
親投稿
Worm anthonyvillan210
gdhs
0そうだね
未プレイ