You declare the array as the type. For instance:
type words_t
icon as string
word as string
endType
words as words_t[]
The type is not affected by where and how it is used, and by itself do not store anything. It is just a template to hold and access data in variables and arrays of that type.
So say you want to use the type above and populate it with data stored in a file, you'd do as so:
type words_t
icon as string
word as string
endType
words as words_t[]
words = populateArray()
for i = 0 to words.length
print(words[i].icon + " : " + words[i].word)
next i
print("space to quit")
sync()
repeat
until GetRawKeyPressed(32)
function populateArray()
tempWords as words_t
outWords as words_t[]
stringBuffer as string
file as string = "wordList.csv"
if GetFileExists(file)
openToRead(1, file)
repeat
stringBuffer = readLine(1)
tempWords.icon = GetStringToken(stringBuffer, ",", 1)
tempWords.word = GetStringToken(stringBuffer, ",", 2)
outWords.insert(tempWords)
until FileEOF(1)
CloseFile(1)
else
print("File not found")
endif
endFunction outWords
The file it reads looks like so:
file1.png,word1
file2.png,word2
file3.png,word3
file4.png,word4
...and is named "wordList.csv" and stored in the "media" folder of the AppGameKit project.
If wanting to remove a word later on, just do it with words.remove(index) and that element is removed for good. Just be careful using hard values in combination with dynamic arrays. An out of bounds will crash your program.
If wanting to zero out the array, use words.length = -1
That will delete all entries of the array, so you can load it up with values from say another file or whatever.