Atari 400 Basic Reference Manual page 102

Vintage computer
Hide thumbs Also See for 400:
Table of Contents

Advertisement

BUBBLE SORT
This program uses the string comparison operator"<=" that orders strings ac-
cording to the AT
ASCII
values of the various characters. Since Atari BASIC does
not have arrays of strings, all the strings used in this program are actually
substrings of one large
string.
A bubble sort,
though
relatively slow ifthere are
a lot of items to be stored, is easy to write, fairly short, and simpler to under-
stand than more complex sorts.
10 DU1 8$( 1)
~'0
GRAPHICS 0 : ?
.
·~
II
..
STF.: I t·lG
:;o
RT"
=?
30
TRAP
30=?
:7
11
Ent.er· ifta>::iiltl_.liil
str·lns le
ngth
11
; :
H~PUT ~tEt-l:
SLEf-H=SLHl-1
35 IF SLHl< 1 OR HlTC3LHD<
>SLHl
THHi ?
II
PLEASE
Et-HEP A
P03
IT I!.}£ I t·HEGEP
>
0
.
11
:
GO
TO 30
40
TRAP
40: ?
=?
"Enter·
111a>::
l
iftlAiit nt.lfftbe;-·
of
ent.r· ies . "
41 ?
!I (
Entr·
.i es
l.(ih
.i d-,
are shor·t.er· than t.h
e
tna;dt'itUfft
'.•.till
be t=·added
'
- 'JiU-,
blanks
.
)
II
42 INPJJT
ENT~~
I ES
45 IF
HHF.~IE:3<2 Of;~
IHT(
Ef.~TPIE::;
>
<
>Hm~:IE:
: ;
THEt·l ?
11
PLEASE HHER A POSIT I lJE I
r~TEGER
>
1.
11
=GOTO 40
47 TRAP
40(10~)
50 Dit1 A$(
:3LEt·t;;(ENT~~
IE~:;
),,
iEt·
1 F'$(
~:t
. .
Et·i)
60 ? : ? "Enter· st.r-
.i .
n::.s •:.ne at a
t.
i
1ne .
u
70 ? "Enter·
e111Ph.t
str· in::;.
!.•.ih~n
done
(
.iust.
hi
t.~:ETUPr·i
>.
II
75
·? :?
11
PLEA:3E
STAt·~D
8\"'
~~JHILE
THE
:3TRii·~
GS ARE BE I
r·~G
CLEAPED . .
.
" .;
80
FOF~
I =1 TO
SLEf-t:;~Ef·~TPIE::;
:
A!.( I
.
' I
>=u ":
t·~
E::<T I
85 ·? :?
90 I=l
101-) FOP
.J=l
TO HlTRIE::;
110
? "#" , ;
,
J ;
II
II;
:
HlPUT TH1P$
120 IF
LEN(
TEt-1P$ )=0
THEf·
i
Et·
~
T~:IE::;=
. ...l-1: GOT
0 190
130
A$( I .. I +::;LB·i 1
)=
TEt'iP$
140 I= I
+::;LEt-4
150
~lE:-=:T
J
190 ?
:? :?
"PLEASE
~:TAr·[!
E:\'
1·~HILE
THE
~::
TR!HGS
ARE BEWG :::OF.:TEO ...
II
,;
200
GOSUB
1000
:
REt·1 CALL
SOF~T
ROUT
H-IE
202
·? :?
205 I=l
210
FOR
K=l TO
Etn~~IE:::
220? "#";K;"
";A$(!,I+SLEN1)
225 I= I
+SLD·i
230 NE:=<T
K
24€1
TRAP 330 : · - ; - - :?
"WOULD
YOU LIKE A PR
Hi
Appendix
H-5

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

800

Table of Contents