I have a problem with type arrays atm and i cant see it any suggestions would be great thanks
EDITED Fixed it
main.c
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
#include "inventorySystem.agc"
myInventory as _Inventory
do
PushInventoryItem(myInventory,Random(1,10),1)
PopInventoryItem(myInventory,Random(1,10))
print("Inventory")
Print(myInventory.invItem.length)
for n=1 to myInventory.invItem.length
a=(lookupInventoryID(myInventory,n)) :a$=""
if a >0
c=lookupInventoryID(myInventory,n)
b=myInventory.invItem[c].number
//a$=GetInventoryItemString(myInventory,a)
endif
//print (str(a)+" " +a$+ " "+str(b))
print (str(a)+" " +str(b))
next
sync()
loop
inventorySystem.agc (would like to keep same types)
type _InvProperties
ID as integer
number as integer
group as integer
endtype
type _Inventory
invItem as _invProperties[]
endtype
//GetInventoryitem(), NewInventoryItem(), AddInventoryItem(), DeleteInventorItem()
function PushInventoryItem(invName ref as _Inventory,invItemID as integer,invGroup as integer)
inventoryProperties as _InvProperties
inventoryProperties.ID=invItemID
inventoryProperties.group=invGroup
elementNumber=lookupInventoryID(invName,invItemID)
inventoryProperties.number=1
if elementNumber>-1
if invName.invItem[elementNumber].ID=invItemID
if invName.invItem[elementNumber].number < 1 then invName.invItem[elementNumber].number=0
invName.invItem[elementNumber].number=invName.invItem[elementNumber].number+1
exitfunction 1
endif
endif
invName.invItem.insert(inventoryProperties)
endfunction 1
function PopInventoryItem(invName ref as _Inventory,invItemID as integer)
elementNumber=lookupInventoryID(invName,invItemID)
if elementNumber>0
if invName.invItem[elementNumber].ID=invItemID
invName.invItem[elementNumber].number=invName.invItem[elementNumber].number-1
if invName.invItem[elementNumber].number < 1 then invName.invItem[elementNumber].number=0
exitfunction 1
endif
invName.invItem.remove(ElementNumber)
endif
exitfunction 1
endfunction 0 //failed
function lookupInventoryID(invName ref as _Inventory,invItemID as integer)
for num=0 to invName.invItem.Length
if invName.invItem[num].ID=invItemID
exitfunction num
endif
next num
endfunction -1