|
Post by Rod on Apr 1, 2022 3:09:55 GMT -5
Running LB 353 64bit on Win11
The program reports an error reaching the sort command
sort b(,1,b,8
and reports
Message Not Understood #aslfString
|
|
|
Post by Carl Gundel on Apr 5, 2022 19:35:14 GMT -5
Running LB 353 64bit on Win11 The program reports an error reaching the sort command sort b(,1,b,8 and reports Message Not Understood #aslfString The program? You have an example?
|
|
|
Post by Rod on Apr 6, 2022 3:26:18 GMT -5
Here is the program, it fails at the sort command, if you rem that out it will run unsorted but it will fail at some point with "This exponent character has not been adequately supported" mentioned in another thread at the spritexy command.
b=500 'number of boids c=25 'cohesion pixels a=.1 'amount of influence 1=100% s=3 'speed pixels ww=1200 wh=700 dim b(b,8) 'x,y,dx,dy,image,index x=1 : y=2 : dx=3 : dy=4 : im=5 : ix=6 : iy=7 :i=8 for n= 1 to b b(n,x)=int(rnd(0)*ww) b(n,y)=int(rnd(0)*wh) b(n,dx)=1-rnd(0)*2 b(n,dy)=1-rnd(0)*2 b(n,im)=n b(n,ix)=int(b(n,x)/c) b(n,iy)=int(b(n,y)/c) b(n,i)=100*b(n,ix)+b(n,iy) next
'nomainwin WindowWidth = ww+30 WindowHeight =wh+60 UpperLeftX = int((DisplayWidth-WindowWidth)/2) UpperLeftY = int((DisplayHeight-WindowHeight)/2) open "Boids" for graphics_nsb as #1 #1 "down : place 0 0 ; backcolor white ; color white ; boxfilled 10 10" #1 "place 0 10 ; backcolor black ; color black ; boxfilled 10 20" #1 "place 5 15 ; color cyan ; backcolor cyan ; circlefilled 4" #1 "place 5 5 ;color black ; backcolor black ; circlefilled 4 ; getbmp boid 0 0 10 20" #1 "down ; fill black ; color white ; trapclose [quit]" #1 "getbmp bac 0 0 ";ww;" ";wh;" ; background bac" for n = 1 to b #1 "addsprite b";n;" boid" #1 "spritexy b";n;" ";b(n,x);" ";b(n,y) next
'timer 33,[draw]
[draw] #1 "drawsprites"
'boid list is kept in y within x order sort b(,1,b,8
'work this ordered list finding near boids 'boids are grouped by a grid defined by ww/c and wh/c bn=1 xg=0 yg=0 while bn<b 'sum x,y for new centre of flock calculation xg=xg+b(bn,x) yg=yg+b(bn,y) xx=b(bn,ix) yy=b(bn,iy) ddx=b(bn,dx) ddy=b(bn,dy) nn=bn 'if the boid is in the same sector sum the vector while bn<b and yy=b(bn,iy) ddx=(ddx+b(bn,dx))/2 ddy=(ddy+b(bn,dy))/2 bn=bn+1 wend
'now run back through the same boids 'applying the changes while nn<b and yy=b(nn,iy)
'merge to average vector b(nn,dx)=ddx b(nn,dy)=ddy
'normalise the vector b(nn,dx)=b(nn,dx)/(abs(b(nn,dx))+abs(b(nn,dy))) b(nn,dy)=b(nn,dy)/(abs(b(nn,dx))+abs(b(nn,dy)))
'move boid b(nn,x)=b(nn,x)+b(nn,dx)*s b(nn,y)=b(nn,y)+b(nn,dy)*s
'update index for sorting b(nn,ix)=int(b(nn,x)/c) b(nn,iy)=int(b(nn,y)/c) b(nn,i)=100*b(nn,ix)+b(nn,iy)
'in and out if b(nn,x)>ww then b(nn,x)=b(nn,x)-ww if b(nn,x)<0 then b(nn,x)=b(nn,x)+ww if b(nn,y)>wh then b(nn,y)=b(nn,y)-wh if b(nn,y)<0 then b(nn,y)=b(nn,y)+wh
'if b(nn,x)>=ww then b(nn,dx)=b(nn,dx)*-1 'if b(nn,y)>=wh then b(nn,dy)=b(nn,dy)*-1 'if b(nn,x)<0 then b(nn,dx)=b(nn,dx)*-1 'if b(nn,y)<0 then b(nn,dy)=b(nn,dy)*-1 #1 "spritexy b";b(nn,im);" ";b(nn,x);" ";b(nn,y) nn=nn+1 wend wend 'calculate centre of entire flock keeping it mid screen xxg=(xg/b+ww/2)/2 yyg=(yg/b+wh/2)/2 scan goto [draw]
[quit] timer 0 close #1 end
|
|
|
Post by Carl Gundel on Apr 6, 2022 9:09:00 GMT -5
Here is the program, it fails at the sort command, if you rem that out it will run unsorted but it will fail at some point with "This exponent character has not been adequately supported" mentioned in another thread at the spritexy command. Thanks. That is a weird error, I have to say. LOL
|
|
|
Post by Rod on Apr 7, 2022 2:48:08 GMT -5
If you are looking at the sort command it could be HUGELY improved if it allowed the sorting to proceed on more than one column.
This is not as complex as it might sound. Firstly the optional column becomes a list of columns So sort array(,1,100,8,1,2
The optional column list at the end is the desired column sorting order
Let’s say 8=surname 1=first name and 2=title
Now inside your current sorting code, at the point you make the comparison between records, concatenate the desired columns to variables and compare those temporary variables. The array is thus sorted in multi column order. Fast,lean and mean.
Otherwise we need to trawl through the array creating this concactenated comparison variable and storing it in its own column. Slow and bloaty
|
|
|
Post by tsh73 on Apr 7, 2022 3:28:34 GMT -5
Another option is to implement SORT in stable algorithm (one that does not changes rows with same value of key) (my introduction to SORT was DBASE III - I really thought all sort algorithm supposed to do this) This way we just call SORT several time like, sort by first name then sort by last name -- result would be sort by last name, first name
|
|
|
Post by Rod on Apr 7, 2022 4:54:00 GMT -5
Yes stable sort would fix it. I grew up with DbaseIII. With the change I suggest we get the same outcome in one pass. Perhaps it is less of a coding change as only the comparators are amended. But it may be the sorting algorithm is Smalltalk based and we are stuffed!
|
|
|
Post by tsh73 on Oct 5, 2022 15:53:37 GMT -5
Well, the bug is still here I guess My findings: 1) double dimensioned sort produces Message Not Understood #aslfString 2) single dimensioned sort works OK, but... 3) for single dimensioned array it seems like some one-off error exist See, if I dim a(6) and sort a(), 1, 10 it complains out of bounds. ( "9 is out of range for a(" ) But for
sort a(), 1, 7 it produces empty (no text or icon) messagebox with single OK button 4) single dimensioned array does not allow sorting from 0 says "-1 is out of range fro a("
dim a(5) for i =0 to 5 a(i)=int(rnd(0)*10) next
for i =0 to 5 print a(i);" "; next print
sort a(), 0, 5
for i =0 to 5 print a(i);" "; next print
|
|