Code: Select all
;-TOP
Global Dim Fruit.s(0) ; <- Read Only
Procedure InitFruit()
Protected items, *c.Character, *s , *arr.integer
*c = ?FruitList
*s = *c
Repeat
If *c\c = #ETX
Break
EndIf
If *c\c = 0
ReDim Fruit(items)
*arr = @Fruit() + items * SizeOf(integer)
*arr\i = *s
*s = *c + SizeOf(character)
items + 1
EndIf
*c + SizeOf(Character)
ForEver
ProcedureReturn items
EndProcedure
Procedure ReleaseFruit()
Protected *arr.integer = @Fruit()
Protected items = ArraySize(Fruit())
Protected index
For index = 0 To items
*arr\i = 0
*arr + SizeOf(integer)
Next
EndProcedure
i = InitFruit()
Debug "Count: " + i
For index = 0 To ArraySize(Fruit())
Debug "Index " + index + ": " + Fruit(index)
Next
ReleaseFruit()
DataSection
FruitList:
Data.s "Apple", "Orange"
Data.s "Mango", "Apricot"
Data.s "Banana", "Pear"
Data.s "Peach", "Tangerine"
Data.s #ETX$
EndDataSection