GLBasic forum

Main forum => Bug Reports => Topic started by: ampos on 2012-Feb-17

Title: SORTARRAY on WebOS fails
Post by: ampos on 2012-Feb-17
Code (glbasic) Select
TYPE pun
   dist;id
ENDTYPE

LOCAL pu[] AS pun

SORTARRAY pu[],0


PU[] has the following values:

Code (glbasic) Select
LENGH:19
0=0,0
1=303,1
2=695,2
3=872,3
4=907,4
5=971,5
6=929,6
7=903,7
8=884,8
9=713,9
10=709,10
11=609,11
12=417,12
13=435,13
14=385,14
15=323,15
16=253,16
17=78,17
18=0,18


Most of the times, SORTARRAY fails, closing the app.

It seems to be a random fail, as it does not fail always.

It is happening in TouchPad. Not tested yet in Pre2.

Meanwhile, I need a alternative sort function...
Title: Re: SORTARRAY on WebOS fails
Post by: Wampus on 2012-Feb-17
Try this (assuming you are sorting dist and not id):-

SORTARRAY pu[], ADDRESSOF(compare)

FUNCTION compare: a AS pun, b AS pun

IF a.dist<b.dist THEN RETURN -1
IF a.dist>b.dist THEN RETURN 1

ENDFUNCTION
Title: Re: SORTARRAY on WebOS fails
Post by: Ian Price on 2012-Feb-17
SORTARRAY definitely works on WEBOS as my TP WordSearch game uses it, without problem.
Title: Re: SORTARRAY on WebOS fails
Post by: Kitty Hello on 2012-Feb-17
ampos - make a standalone example that crashes, please.
Title: Re: SORTARRAY on WebOS fails
Post by: ampos on 2012-Feb-17
I was yesterday testing for along 3 hours.

First, it was crashing 100% of the times. I was placing "log ()" every place here and there. Still I had not the crashing line.

Then, suddenly it worked. Did a few more tries and was working. No code was changed, just logs() everywhere. Compiled and sent to HP catalog. While I was uploading, I run it again. Crash.

More logs... I found the line. Placed log() before and after SORTARRAY. The "after" log were not ever written.

As you see in the post, it was almost 2:00 am (I wake up at 8:00!).

I can not create a "breaking" example as it was not consistent.
Title: Re: SORTARRAY on WebOS fails
Post by: Kitty Hello on 2012-Feb-17
oh dear! That sounds like it might have been something else. Somewhere it overwrites memory.

Can you try your own bubble sort, please?
Title: Re: SORTARRAY on WebOS fails
Post by: ampos on 2012-Feb-17
I am now using

Code (glbasic) Select
SORTARRAY pu[], ADDRESSOF(compare)

FUNCTION compare: BYREF a, BYREF b
   IF a<b THEN RETURN -1
   IF a>b THEN RETURN 1
   RETURN 0
ENDFUNCTION


and it is working, although the "standar" SORTARRAY was working for a time also...

Could it crash too?

Notice I had never a crash until someone pointed in the comments "if you disable rolling ball game, it crash after the first screen". Then I thought "it can not been, has never crash before for me on the TP or iPhone or Windows...".

Then I run it without rolling ball on the iphone and it worked. Run on the TP and crash!. But then I was not even able to run it without a crash, no mmatter the settings I use on the game!

Anyway, it is working now, and I am uploading to the HP catalog...
Title: Re: SORTARRAY on WebOS fails
Post by: MrTAToad on 2012-Feb-17
Can you try :

Code (glbasic) Select
FUNCTION compare: a, b
   IF a<b THEN RETURN -1
   IF a>b THEN RETURN 1
   RETURN 0
ENDFUNCTION


Instead