Télécharger Imprimer la page

Tandy TRS-80 100 Mode D'emploi page 189

Publicité

1090 '
1100
7
Input thé filename and verify
1110 ' it has a -DO extension
1120 '
1130 A* = "Which file tn sort: " : GOSUE 2000
1140
INPUT F*
1150
IF MID*(F*,LEN(F*>-2,1> ,'> "." THEN F* = F* *- ".DO"
1170 OPEN F* FOR INPUT AS 1
1180 '
1190 ' Print thé first record of thé
1200 ' file and determi ne thé begin
1210
' and end position of thé sort
1220
' field, and uihether thé? fit>ld
1230 ' is TiuiTieric (F=l) or tiharacter
1240 ' (F=0>
1250 '
1260 LINE INPUT #1,ZS
1270
CLE
1T 0 PRINT"
.
1
.
2
.
3
.
4" ;
1290 PRINT Z*
1300 A* - -Begin at position: " : GOSUE 2000
1310 INPUT B
1315 IF B*0 THEN1300
1320 A» = "End at position: » : GGSUB 2000
1330 INPUT E
1370 N = 1
1380 '
1390 * Input th» remainder of thé f i l e
1400
* to détermine thé size for thé
1410 ' Din statement.
1420 '
1430 N = N + 1
1440 LINE INPUT #1,2*
1450 IF EOF(l) THEN GOTO
1470
1460 GOTO 1430
1470 CLOSE
1480 DIM D * < N >
1490 '
1500
' Read in thé data from thé f i l e
1510 '
1520 '
1530 '
1540 OPEN F* FOR INPUT AS 1
1550 FOR 1=1 TO N
1560 LINE INPUT #1,D*U>
1570 NEXT I
15B0_CLOSE 1
1600 '
.1,610 GOSUB 300B 'Call thé sort routine
1620 '
1630
'Write thé sorted file out to RAM
164B *
Ï6"45 KILL F»
1650 OPEN F» FOR OUTPUT AS 1
1660
FOR 1=1 TO N
1670 PRINT #1,D*<I)
1680 NEXT I
1690 CLOSE
1700 '
1710 ENDi'CHANGE BACK TO MENU
2000 '
2010'' Subroutine for printing prompts
2020 '
2030 PRINT 3240, STRINQ*(40,32);
2040 PRINT 3240, A*;
2050 RETURN
3000 '
3010 * Sorting «ubroutine
3020 '
3030 25 = N
3040 Z5 = INT(Z5/2>
3050 IF Z5 =* 0 THEN 3190
3O60 22 = 1 : Z3 - N - 25
3070 Zl =• Z2
3080 Z4 = 21 + Z5
3100
IF (MID*<D*(Z1),B,(E-B)-M M
< <MID*(D*(Z4),B,(E-B)+1)) THEN 3160
ELSE 3120
3120 26* = D * < Z 1 > : D*(Z1> = D*(24J : D*(Z4) = lût
3130 21 - 2l. - 25
3140
IF Zl . 1 THEN
3160
3150
GOTO :ï0B0
3160 22 -•-- ^1 + 3
3170
1F 72
73 THEN 31340
3180
GOTU .30/0
3190 RETURN
- 182 -

Publicité

loading

Produits Connexes pour Tandy TRS-80 100