Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / two arrays and a loop

Author
Message
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 2nd Mar 2008 14:54
Hi

Im trying to do like a lookup type thing for an inventory im making.

So far i've got:

dim got_items() as string

type UnitType
itemName$ as string
endtype

dim global_items(5) as UnitType

`this works but i want to loop it

item1 = val(got_items(0))
print global_items(item1).itemName$


-I have no problems putting items into either array, for ex:
global_items(0).itemName$ = "Zero item"
global_items(1).itemName$ = "Blunt Sword"


and: I am filling my array of got_items from a file ok.

But now i want to run through the outputs in a loop:
item1 = val(got_items(0))
print global_items(item1).itemName$

i've tried putting that in a loop and changing the values to the value of the for-next loop but it always errors out.

Does anyone know what im getting at?

Paul
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 2nd Mar 2008 15:02


ok so that works but thats in a nice clean project but not in my cluttered one.
great.

sorry i've answered myself again.
Gah.
!

Paul
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Mar 2008 19:17
Paul08 if you are going to use zero in your for next loop you will end up with three items in your list not two like you are after.

eg
item = got_items(0)
item = got_items(1)
item = got_items(2)

hope that helps for later on in your coding.

cheers.

Dark Physics makes any hot drink go cold.
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 9th Mar 2008 19:35
Yeah im quite good with arrays (if nothing else) but cheers for that!

Paul

Login to post a reply

Server time is: 2024-11-25 08:00:56
Your offset time is: 2024-11-25 08:00:56