[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2019-01-10T23:32:54-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/9439 2019-01-10T23:32:54-05:00 2019-01-10T23:32:54-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=32653#p32653 <![CDATA[Caxton Foster's Bifid Analysis Tools]]>
Hopefully, I'm not too off topic here but bare with me a bit.

I'm trying to convert the Bifid decryption tools in Caxton Foster's book<I><s></s> Cryptanalysis for microcomputers. <e></e></I> I have typed the programs as they are presented (line numbers included) in his book in Chapter 13 but, try as I may, I cannot get it to run without a bad function call (error #5) for the line Print chr$(t+64);"reverse off"; in line 770.

Here are my few ideas why it is not working:
  • There is something specific to PET BASIC I'm unfamiliar with and have not accounted for,
  • The program itself is faulty,
  • The program works only in interpreter mode but not when compiled (haven't tested that yet),
  • There is a conflict between PETSCII and ASCII,
  • There are too may GOTOs, GOSUBs and labels,
  • Some variable names are too close to each other which confused the compiler (e.g. T & T%() and lastly (taa-daa),
  • I have made a monumental stoooopid that I can't find.
Anyway, I'm attaching the program as far as I got with it and, hopefully, someone here can spot where it all falls apart. Thank you all in advance for your help. One thing that bothers me in QB64 is that there seem to be no debugging tools. Are there stand-alone programs to do that? Is there, perchance, some line number removal tools that work under Windows 10. The one I have runs only in DOS or DOSBox.

Again, thank you all for your help.

Code:

1 DIM T%(1000), L1(26), L2(26), TA%(1000), TB%(1000), TC%(1000)4 DIM TP%(50), R%(1000), C%(1000), B(11), LB(11)5 DIM KS%(9, 9), RL%(26), CL%(26)10 REM DETERMINE PERIOD20 REM OPEN FILES, READ AND PURGE25 GOSUB 90000: REM Set UP And OPEN FILES30 GOSUB 10000: REM READ DATA FROM FILE40 GOSUB 10200: REM REMOVE UNWANTED CHARACTERS & SPACES41 PRINT "DO YOU KNOW THE PERIOD? TYPE Y OR N."42 A$ = "": A$ = INKEY$: IF A$ = "" GOTO 4243 IF UCASE$(A$) = "Y" GOTO 30045 PRINT "PERIOD IC"50 FOR P = 3 TO 20    55 FOR Q = 1 TO 26: L1(Q) = 0: NEXT Q    60 HP = INT(P / 2)    70 OD = P - 2 * HP    75 S = 0    80 TA% = 0: K = 0    90 FOR B = 0 TO J - P STEP P        100 FOR X = 1 TO HP + OD            110 F = T%(B + X)            120 G = T%(B + X + HP)            125 S = S + 1            130 GOSUB 1000        140 NEXT X        150 FOR X = 1 TO HP            160 L1(T%(X + B)) = L1(T%(X + B)) + 1            170 L2(T%(B + P + 1 - X)) = L2(T%(B + P + 1 - X)) - 1        180 NEXT X    190 NEXT B    200 IC = 0    210 GOSUB 2000    220 GOSUB 3000    230 PRINT P; INT((IC * 625) + .5); INT(CS + .5): REM MODIFIED TO SHOW INTEGER VALUES ONLY240 NEXT P250 REM PLACE THE TIP (SUSPECTED WORD OR PHRASE ENCIPHERED WITHIN THE MESSAGE)300 INPUT "WHAT IS THE PERIOD? "; P320 HP = INT(P / 2)330 OD = P - 2 * HP340 INPUT "ENTER THE TIP -- NO BLANKS "; A$355 TL = LEN(A$)360 FOR I = 1 TO TL    370 TP%(I) = ASC(MID$(A$, I, 1)) - 64: REM INDEX OMITTED IN ORIGINAL LISTING380 NEXT I390 REM MAKE VECTORS OF ROW AND COLUMN ELEMENTS: AR = 1, AC = 101400 K = 1401 REM SEE ALSO: ALTERNATE CODE ON P. 243410 FOR B = 0 TO J - P STEP P    415 C%(K) = T%(B + 1)    420 FOR X = 1 TO HP + OD        430 R%(K) = T%(B + X)        440 R%(K + 1) = T%(B + X) - 100        445 C%(K + 1 - OD) = T%(B + X + HP) + 100        450 C%(K + 2 - OD) = T%(B + X + HP + 1)        460 K = K + 2    470 NEXT X    480 K = K - OD490 NEXT B495 B(11) = 10000: FOR XX = 1 TO 10: B(XX) = 0: NEXT XX500 IF OD = 0 GOTO 610510 REM FIND ODD PERIOD NATURALS520 FOR I = 0 TO B - TL    530 C = 0    540 FOR K = 1 TO TL        550 IF R%(I + K) = TP%(K) THEN C = C + 1        560 IF C%(I + K) = TP%(K) + 100 THEN C = C + 1    570 NEXT K    580 GOSUB 4000590 NEXT I600 GOTO 700610 REM DO IDENTICALS FOR EVEN PERIOD620 FOR I = 0 TO B - TL    630 C = 0    640 FOR K = 1 TO TL        650 IF (TP%(K) = R%(I + K)) AND (TP%(K + 1) = C%(I + K)) THEN C = C + 2    670 NEXT K    680 GOSUB 4000690 NEXT I700 PRINT: PRINT "PT=" ': REM CHECK THIS ORIGINALLY 700 PRINT: PRINT "PT='710 FOR I = 1 TO TL    720 PRINT CHR$(TP%(I) + 64);730 NEXT I735 PRINT740 FOR I = 10 TO 1 STEP -1    745 IF B(I) = 0 GOTO 830    750 PRINT LB(I),    760 FOR X = 1 TO TL        765 T = R%(LB(I) + X): IF T > 100 THEN T = T - 100: PRINT "reverse";        770 PRINT CHR$(T + 64); "reverse off";    780 NEXT X    790 PRINT: PRINT ,    800 FOR X = 1 TO TL        805 T = C%(LB(I) + X): IF T > 100 THEN T = T - 100: PRINT "reverse";        810 PRINT CHR$(T + 64); "reverse off";    820 NEXT X    825 PRINT830 NEXT I833 CLOSE #2835 A$ = "": A$ = INKEY$: IF A$ = "" THEN GOTO 835840 STOP1000 FOR Y = 1 TO K    1010 IF (F = TA%(Y)) AND (G = TB%(Y)) THEN TC%(Y) = TC%(Y) + 1: RETURN1020 NEXT Y1030 K = K + 11040 TA%(K) = F1050 TB%(K) = G1060 TC%(K) = I1070 RETURN2000 FOR Y = 1 TO K    2010 IC = IC + TC%(Y) * (TC%(Y) - 1)2020 NEXT Y2030 IC = IC / (S * (S - 1))2040 RETURN3000 CS = 03010 FOR Z = 1 TO 26    3015 IF L1(Z) + L2(Z) = 0 GOTO 3030    3020 CS = CS + (L1(Z) - L2(Z)) ^ 2 / (L1(Z) + L2(Z))3030 NEXT Z3040 RETURN4000 IF C < B(1) THEN RETURN4010 FOR XX = 2 TO 11    4020 IF C < B(XX) THEN B(XX - 1) = C: LB(XX - 1) = I: RETURN    4030 B(XX - 1) = B(XX)    4040 LB(XX - 1) = LB(XX)4050 NEXT XX4060 RETURN10000 REM Read in the text10010 J = 010020 F = 010030 CLS: PRINT10040 PRINT "ENTERING TEXT FROM FILE"10045 PRINT: PRINT10050 LINE INPUT #1, A$10055 PRINT A$10060 FOR I = 1 TO LEN(A$)    10070 X = ASC(MID$(A$, I, 1)) - 64    10080 IF X = -17 THEN F = 1    10090 J = J + 1    10100 T%(J) = X10110 NEXT I10120 IF F = 0 GOTO 1005010121 SLEEP 5: PRINT: PRINT10130 J = J - 110135 CLOSE #110140 RETURN10200 REM SQUEESE OUT THE BLANKS10210 I = 010220 FOR K = 1 TO J    10230 IF T%(K) < 1 OR T%(K) > 26 GOTO 10260    10240 I = I + 1    10250 T%(I) = T%(K)10260 NEXT K10270 J = I10280 RETURN90000 REM OPEN INPUT AND OUTPUT FILE90005 SCREEN _NEWIMAGE(800, 600, 256): REM SET SCREEN PROPERTIES90010 CLS90020 INPUT "WHAT IS THE NAME OF THE INPUT FILE  > "; A$90030 OPEN A$ FOR INPUT AS #190040 PRINT: PRINT90050 INPUT "WHAT IS THE NAME OF THE OUTPUT FILE > "; A$90060 OPEN A$ FOR OUTPUT AS #290070 RETURN

Statistics: Posted by AElfstangard — Thu Jan 10, 2019 11:32 pm


]]>