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 / DBP : Finding MAX VALUE in an ARRAY

Author
Message
Intruder
20
Years of Service
User Offline
Joined: 13th Apr 2004
Location: UK
Posted: 17th Apr 2004 03:57
I have an array that holds x,y and health Values etc (amongst other things)

How do i find out which item in the array has the highest value in the 'health' slot ?


** If GOD would have wanted us to walk around NAKED, he would have made us be born that way **
Intruder
20
Years of Service
User Offline
Joined: 13th Apr 2004
Location: UK
Posted: 17th Apr 2004 04:15 Edited at: 17th Apr 2004 18:04
Thought i'd sorted it but i havn't..

Still need help peeps..

Thanks


** If GOD would have wanted us to walk around NAKED, he would have made us be born that way **
Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 18th Apr 2004 18:15
Use a for-next loop:



As you can see, it's quite easy.

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th Apr 2004 18:30 Edited at: 18th Apr 2004 18:33
Ok while I am struggling with my current programing black out, I have had a look at your problem, which I think is very similar to what I need to do, I just can't quite sort my issue out yet. Here is a bit of code I wrote which sorts through an array and finds the highest number in it. I think it is what you are after.

dim test(10,1)

for n=1 to 10
test(n,1)=rnd(30)
next n

for n= 1 to 10
print test(n,1)
next n

for n=1 to 10
oldvalue=test(n,1)
if oldvalue>oldvalue2
oldvalue2=oldvalue
endif
next n

do
set cursor 200,0
print oldvalue2
sync
loop

Ahh I see someone beat me to it
Intruder
20
Years of Service
User Offline
Joined: 13th Apr 2004
Location: UK
Posted: 18th Apr 2004 18:39
thanks peeps...


** If GOD would have wanted us to walk around NAKED, he would have made us be born that way **

Login to post a reply

Server time is: 2024-11-26 14:52:08
Your offset time is: 2024-11-26 14:52:08