'Copyright 2000 The American Cryptogram Association (ACA) '3613 Piedmont Drive, Plano TX 75075-6234 'All rights reserved. 'Demo of Pollux-related Functions 'using ACA & You example. ACA&Y puts 'the symbol for 0 (dot) at end of 'key, but this code needs it first. Key$ = ".x-..x.--x" Ct$ = "08639342570241768596304" Ct$ = Ct$ + "14562349087453609" Errors = PolluxToText(Key$,Ct$,Pt$) Print "Plaintext: ";Pt$ Print "Errors:";Errors Function MorseToText$(M$) Static If MC$="" Then MC$="*ETIANMSURWDKGOHVF*L*PJBXCYZQ**" End If Posn = 0 : BitVal = 1 LenM = Len(M$) If (LenM>4) Then LenM = 0 For I = LenM to 1 Step -1 If mid$(M$,I,1) = "-" Then Posn = Posn + BitVal End If BitVal = BitVal + BitVal Next I Posn = Posn + BitVal MorseToText$ = Mid$(MC$,Posn,1) End Function 'MorseToText$ Function PolluxToText(K$,C$,P$) CONST AsciiZero = 48 DIM KeyArr$[10] 'Put key chars in array For J = 0 to 9 KeyArr$[J] = Mid$(K$,J+1,1) Next J 'Inits: P$ = Plaintext ' M$ = Morse string ' NAster = Number of asterisks ' Ch$ = Cipher digit as . - or x P$="" : M$="" : NAster=0 : Ch$="" X2Flag=0 'Two x's not yet found 'Loop: Process each cipher digit LenCt = Len(C$) For I = 1 TO LenCt 'Convert cipher digit to x - or . ChTemp = Asc(Mid$(C$,I,1)) Ch$ = KeyArr$[ChTemp-AsciiZero] 'If Ch$ is . or - ' add it to Morse string 'Else Process the 'x' depending ' on how many consecutive x's ' we have found. If Ch$ <> "x" Then 'Add dot or dash to M$ M$ = M$ + Ch$ X2Flag = 0 ElseIf M$ <> "" Then '1st x; add ltr to plaintext Ltr$ = MorseToText$(M$) P$ = P$ + Ltr$ If Ltr$ = "*" Then NAster = NAster + 1 End If M$ = "" ElseIf X2Flag=0 Then '2nd x found; end of word. P$ = P$ + " " 'Add space X2Flag = 1 Else '3rd x found: error = * P$ = P$ + "*" NAster = NAster + 1 End If Next I PolluxToText = Naster End Function 'PolluxToText