I was puzzling over how to manage treasure chests in the Roguesoft RPG Engine when I came to the regrettable conclusion that I'd have to use arrays. This bothered me, as the only method I could think up involved FILEIO and I didn't want players tampering with saves.
I suddenly remembered an article Al wrote some time ago and hurried online to read it. Sure enough, Al solved the puzzle ages ago, and the only limitation is consistent value length.
I've rewritten his marvelous routines in my own syntax and swapped the value length from 2 to 1. Here they are should anyone find them useful:
Create an array:Copy the value of an item to the "itemValue$" variable:'--- Get an item's value.
USERASK Which item do you want to get the value of?
item = val userask$
itemValue$ = mid$ array$ item 1
Change an item's value:'--- Select an item in the array.
USERASK Which item will you assign a new value to?
item = val userask$
itemToLeft = item - 1
itemToRight = item + 1
'--- Designate a new value for the item.
newItemValue$ = USERASK Set the item's new value:
'--- Reconstruct the array with the item's new value.
itemsToLeft$ = left$ array$ itemToLeft
IF item =< 1 THEN itemsToLeft$ = ""
itemsToLeft$ = itemsToLeft$ + newItemValue$
itemsToRight$ = mid$ array$ itemToRight
newArrayValue$ = itemsToLeft$ + itemsToRight$
array$ = newArrayValue$
And check out Al's original article for 2 char length item values:
http://gamemakersgarage.com/index.php?cat=articles&id=9EDIT:I've updated the above code to fix an incorrect operator. Also, here's a source example:
http://www.mediafire.com/?imtn2nz22u4