But i stopped at error 177. ?? What does this means:
RETURN mixed with 'FUNCTION =' or EXIT FUNCTION (using both styles together is unsupported when returning objects with constructors), found 'ObjectData' in 'return ObjectData(id)'
Thanks for help. :)
Code: Select all
'Inventory Engine
type InventoryObjectData
Objectname as string
ObjAmount as integer
end type
type Inventory
ObjectData(any) as InventoryObjectData
declare sub addObj (ObjName as string, amount as integer)
declare sub setObj (ObjName as string, amount as integer)
declare function search_id (ObjName as string) as integer
declare function getObj (ObjName as string) as InventoryObjectData
end type
function Inventory.search_id (Objname as string) as integer
for i as integer = lbound(ObjectData) to ubound(ObjectData)
if ObjectData(i).Objectname = Objname then return i
next
return -1
end function
sub Inventory.setObj (Objname as string,amount as integer)
dim as integer id = search_id(Objname)
if id = -1 then
print "Object not found"
exit sub
else
ObjectData(id).Objamount = amount
end if
end sub
function Inventory.getObj(ObjName as string) as InventoryObjectData
dim as integer id = search_id(ObjName)
if id = -1 then
print "Object not found"
exit function
else
return ObjectData(id)
end if
end function
sub Inventory.addObj (ObjName as string,amount as integer)
if search_id(ObjName) > -1 then
Print "Object allready exists"
exit sub
end if
redim ObjectData(ubound(ObjectData)+1)
with ObjectData(ubound(ObjectData))
.Objectname = ObjName
.ObjAmount = amount
end with
Print "Object added"
end sub