Answer the question
In order to leave comments, you need to log in
Poorly recognized (OCR) listing. How to correct errors?
Recommendations needed to correct recognition errors in the listing from the book:
DEFINT I-N: DEFSTR S
CLS : RANDOMIZE 231
DIM s(4, 32) AS STRING * 1
ns = 4
ss = "ААААААААААААААААААААААААААААА"
PRINT ss
'-----------ШИФРОВАНИЕ
x = RND(-231)
FOR i=0 TO ns
FOR j=0 TO 32:set(i,j) = CHR$(j):NEXT
FOR j=0 TO 32:SWAP s(i,j),s(i,32*RND):
NEXT
NEXT
s=""
FOR i = 1 TO LEN(ss) 'шифрование символа
k=ASC (MID$ (ss ,i ,1)): IF k>32 THEN k=k-128
FOR j = 0 TO ns:k=ASC(set(j, k)):NEXT
IF k < 32 THEN k = k+ 128
PRINT CHR$ (k); : s = s + CHR$ (k)
k = ns * RND 'поворот колес
FOR j=0 TO 31:SWAP s(k,j),s(k,j+1):NEXT
FOR j=0 TO 32
s(k,j)=CHR$((ASC(set(k, j)) + 32) MOD 33)
NEXT
NEXT
PRINT
'----------РАСШИФРОВЫВАНИЕ
x = RND(-231)
FOR i=0 TO ns
FOR j=0 TO 32:s(i,j)=CHR$(j):NEXT
FOR j=0 TO 32:SWAP s(i,j),s(i,32*RND):NEXT
FOR j=0 TO 32
IF ASC (set (i, j)) < 64 THEN
m =j:n=ASC(s(i, j))
DO
k=ASC(s(i,n)):s(i,n)=CHR$(m OR 64)
m=n: n=k
LOOP UNTIL m = j
END IF
NEXT j
FOR j=0 TO 32
s(i,j)=CHR$(ASC(s(i,j)) AND 63)
NEXT
NEXT i
ss = s
FOR i = 1 TO LEN(ss)
k=ASC(MID$(ss,i ,1)): IF k>32 THEN k=k-128
FOR j=ns TO 0 STEP -1
k=ASC(s(j,k))
NEXT
IF k<32 THEN k=k+128
PRINT CHR$ (k) ;
k = ns * RND 'поворот колес
FOR j = 0 TO 31: SWAP s(k,j),s(k,j+1):NEXT
FOR j = 0 TO 32
s(k,j)=CHR$((ASC(s(k,j))+32) MOD 33)
NEXT
NEXT i
END
More specifically: it's not quite clear what to do with "Array access, index expected" and "Array not dimensioned" errors in lines with s, ss, set a.bas(11) ERROR 71: Array NOT dimensioned, before '('
FOR j=0 TO 32:set(i,j) = CHR$(j):NEXT
^
a.bas(15) ERROR 72: Array ACCESS, index expected, before '='
s=""
^
a.bas(18) ERROR 71: Array NOT dimensioned, before '('
FOR j = 0 TO ns:k=ASC(set(j, k)):NEXT
^
a.bas(20) ERROR 72: Array ACCESS, index expected, before '='
PRINT CHR$ (k); : s = s + CHR$ (k)
^
a.bas(24) ERROR 71: Array NOT dimensioned, before '('
s(k,j)=CHR$((ASC(set(k, j)) + 32) MOD 33)
^
a.bas(34) ERROR 71: Array NOT dimensioned, before '('
IF ASC (set (i, j)) < 64 THEN
^
a.bas(46) ERROR 72: Array ACCESS, index expected
ss = s
^
Unfortunately, neither the original book nor the scanned version is available anywhere.
Answer the question
In order to leave comments, you need to log in
the best solution would be to find the source scan and look with your eyes at those lines on which the compiler swears, heuristics are indispensable here, even if you manage to fix compilation errors, it’s not a fact that the algorithm will do the same as it was intended
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question