PDA

View Full Version : Adding to an array without specificying the index?



KeepBotting
07-04-2014, 11:54 PM
Say I've got a function that loops through my backpack slots (1 to 28) looking for a DTM.

I want the function to add the backpack box slot number to a TIntegerArray every time it finds a slot which contains my DTM.

Problem is, I only know how to add an index to an array whilst specifying the index to which I want to add, like so: theArray[0] := value;

Obviously this will always add 'value' to the 0th index of theArray.

How can I append a value directly onto the end of an array, without having to specify an index?

Also, does a non-dynamic array begin with the 0th or the 1st index?

The Mayor
07-05-2014, 12:03 AM
Something like:


if tabBackPack.isItemInSlot(slot) then
myInterArray.append(slot);

KeepBotting
07-05-2014, 12:05 AM
Something like:


if tabBackPack.isItemInSlot(slot) then
myInterArray.append(slot);

PERFECT, thank you! That worked :)

Brandon
07-05-2014, 12:33 AM
PERFECT, thank you! That worked :)


All arrays have 0 base indices. Only array that doesn't is a 'string' (aka an array of char under the hood), and has a base index of 1.