Author Topic: Sorting Demo  (Read 1167 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 312
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Sorting Demo
« on: October 14, 2021 »
Took me a while to see it.

I'm now trying fish bowl.

Use D-Pad to change.

Code: [Select]
open window 640,512
restore stats
read file
dim firstname$(file)
dim lastname$(file)
dim age(file)
dim height(file)
dim weight(file)
dim order$(file)

for a=1 to file
read firstname$(a)
read lastname$(a)
read age(a)
read height(a)
read weight(a)
next a

restore stat
read select
dim selection$(select)
dim x1(select)
dim x2(select)

for a=1 to select
read selection$(a)
read x1(a)
read x2(a)
next a

restore heading
read column
dim name$(column)
dim place(column)

for a=1 to column
read name$(a)
read place(a)
next a

sel=1

repeat
setdispbuf vm
vm=1-vm
setdrawbuf vm
clear window
c=peek("port1")

if and(c,16)<>0 up=1
if up=1 U=U+1
if U>2 U=2
if U=2 up=0
if and(c,16)=0 U=0

if and(c,64)<>0 down=1
if down=1 D=D+1
if D>2 D=2
if D=2 down=0
if and(c,64)=0 D=0

if up=1 col=col-1
if down=1 col=col+1
if col<1 col=1
if col>file col=file

if and(c,128)<>0 left=1
if left=1 L=L+1
if L>2 L=2
if L=2 left=0
if and(c,128)=0 L=0

if and(c,32)<>0 right=1
if right=1 R=R+1
if R>2 R=2
if R=2 right=0
if and(c,32)=0 R=0

if left=1 sel=sel-1
if right=1 sel=sel+1

if sel<1 sel=1
if sel>select sel=select

setrgb 1,256,256,256

text 120,20,"select D-Pad L/R"

for a=1 to select
if sel=a then
setrgb 1,192,96,0
fill rectangle x1(a)-2,70 to x2(a)+2,55
setrgb 1,256,256,256
text 120,40,selection$(a)
'line x1(a),70 to x2(a),70
endif
next a

for b=1 to select
for a=1 to file
if sel=1 order$(a)=firstname$(a)
if sel=2 order$(a)=lastname$(a)
if sel=3 order$(a)=str$(age(a))
if sel=4 order$(a)=str$(height(a))
if sel=5 order$(a)=str$(weight(a))
next a
next b

for K=1 to file-1
for J=1 to file-K

if order$(J)>order$(J+1) then

temp$=firstname$(J)
firstname$(J)=firstname$(J+1)
firstname$(J+1)=temp$

temp$=lastname$(J)
lastname$(J)=lastname$(J+1)
lastname$(J+1)=temp$

temp=age(J)
age(J)=age(J+1)
age(J+1)=temp

temp=height(J)
height(J)=height(J+1)
height(J+1)=temp

temp=weight(J)
weight(J)=weight(J+1)
weight(J+1)=temp

temp$=order$(J)
order$(J)=order$(J+1)
order$(J+1)=temp$

endif

next J
next K

for a=1 to file
if col=a then
setrgb 1,0,256,0
else
setrgb 1,256,256,256
endif
text 200-len(firstname$(a))*10,a*15+80,firstname$(a)
text 210,a*15+80,lastname$(a)
text 320,a*15+80,str$(age(a))
text 370,a*15+80,str$(height(a))
text 450,a*15+80,str$(weight(a))
next a

for a=1 to column
if sel=a then
setrgb 1,0,256,0
else
setrgb 1,256,256,256
endif
text place(a),65,name$(a)
next a

'setrgb 1,256,256,256
'text 100,65,"first name last name age  height  weight"

until (1=0)

label heading
data 5
data "first name",100
data "last name",210
data "age",310
data "height",360
data "weight",440

label stat
data 5
data "sort order by first name",100,200
data "sort order by last name",210,300
data "sort order by age",310,340
data "sort order by height",360,420
data "sort order by weight",440,500

label stats
data 21
data "vance","mccarthy",56,1750,8255
data "paul","mccarthy",52,1690,6985
data "paul","voitre",55,1680,8400
data "ruth","voitre",53,1585,5715
data "rachael","meagher",49,1600,6666
data "patrick","mccarthy",80,1680,8890
data "marilyn","mccarthy",75,1580,6150
data "kelly","waterman",71,1725,6250
data "penny","waterman",70,1550,6400
data "christopher","waterman",40,1910,9210
data "michael","voitre",26,1860,8350
data "courtney","voitre",19,1610,6670
data "leah","mcnabb",29,1590,6980
data "blair","mooney",27,1800,8200
data "shane","mooney",28,1850,8300
data "christopher","mooney",24,1625,8100
data "ashwad","khan",37,1730,6900
data "mark","maloney",53,1700,9200
data "peter","sharp",63,1650,6700
data "jim","fayan",74,1950,9500
data "jeremy","cathcart",22,1900,8250
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.