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.

2D All the way! / big sorting AHHHHRRGG

Author
Message
sprites r us
21
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 16th Mar 2004 16:04
ok, so before i go into this sorting loop all the finishtimes are ok but not sorted, then i sort them using the little result type (wich also holds an id for the competitor so the program still knows what result is whos) and behold, all the finishtimes end up being 0...

i have written a sorting routine like this a million times and it always worked. I'm sure i've just made some silly misstake, can someone spot it for me?



Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 16th Mar 2004 18:14
It works! Try this test. Something else must be wrong.

Dim result(7)

for n = 1 to 7
r = rnd(50)+1
result(n) = r
next n

repeat
changes=0
for i=1 to 6
if result(i+1) < result(i)
xr=result(i)
result(i)=result(i+1)
result(i+1)=xr
changes = 1
endif
next i
until changes=0


for n = 1 to 7

print result(n)

next n

suspend for key

sprites r us
21
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 16th Mar 2004 18:56
that's strange... is it that you cannot copy a type object like

type results
...
endtype

dim result(x) as results
xr as results

the error must appear when i do xr = result(x) coz i check the values just before and they are fine.. pulling my hair out now... if it turns out you cannot copy typed objects like that my whole game idea pretty much fgoes down the drain ;o)
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 16th Mar 2004 22:05
Have you tried this?

xr=result(i).finishtime#

sprites r us
21
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 17th Mar 2004 09:52
well problem is i need to copy the whole object not just a field from it... although soon i'll give up trying and do a really crappy solution!

Login to post a reply

Server time is: 2025-08-09 02:12:21
Your offset time is: 2025-08-09 02:12:21