Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
47
Task/Align-columns/ZX-Spectrum-Basic/align-columns.basic
Normal file
47
Task/Align-columns/ZX-Spectrum-Basic/align-columns.basic
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
5 BORDER 2
|
||||
10 DATA 6
|
||||
20 DATA "The$problem$of$Speccy$"
|
||||
30 DATA "is$the$screen.$"
|
||||
40 DATA "Need$adapt$text$sample$"
|
||||
50 DATA "for$show$the$result$"
|
||||
60 DATA "without$problem$,right?$"
|
||||
70 DATA "But$see$the$code.$"
|
||||
80 REM First find the maximum length of a 'word'
|
||||
90 LET max=0: LET d$="$"
|
||||
100 READ nlines
|
||||
110 FOR l=1 TO nlines
|
||||
120 READ t$
|
||||
130 GO SUB 1000
|
||||
150 NEXT l
|
||||
155 LET s$=" "( TO max)
|
||||
160 REM Now display the aligned text:
|
||||
170 LET m$="l": GO SUB 2000: PRINT
|
||||
180 LET m$="r": GO SUB 2000: PRINT
|
||||
190 LET m$="c": GO SUB 2000
|
||||
200 STOP
|
||||
1000 REM Maximum length of a word
|
||||
1010 LET lt=LEN t$: LET p=1: LET lw=0
|
||||
1020 FOR i=1 TO lt
|
||||
1030 IF t$(i)=d$ THEN LET lw=i-p: LET p=i: IF lw>max THEN LET max=lw
|
||||
1040 NEXT i
|
||||
1050 RETURN
|
||||
2000 REM Show aligned text
|
||||
2010 RESTORE 20
|
||||
2020 FOR l=1 TO nlines
|
||||
2030 READ t$
|
||||
2040 GO SUB 3000
|
||||
2050 NEXT l
|
||||
2060 RETURN
|
||||
3000 REM Show words
|
||||
3010 LET lt=LEN t$: LET p=1: LET lw=0
|
||||
3020 FOR i=1 TO lt
|
||||
3030 IF t$(i)<>d$ THEN GO TO 3090
|
||||
3035 LET lw=i-p
|
||||
3040 LET p$=t$(p TO i-1): LET p=i+1: LET z$=s$
|
||||
3050 IF m$="l" THEN LET z$( TO lw)=p$
|
||||
3060 IF m$="r" THEN LET z$(max-lw+1 TO )=p$
|
||||
3070 IF m$="c" THEN LET z$((max/2)-(lw/2) TO )=p$
|
||||
3080 PRINT z$;
|
||||
3090 NEXT i
|
||||
3095 PRINT
|
||||
3100 RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue