'Copyright 1997-1999 The American Cryptogram Association (ACA) 'One Pidgeon Drive, Wilbraham MA 01095-2604 'All rights reserved. 'Program 2: Demo of GetCt$() Input "Enter File Name";Nam$ Input "Which problem"; CiphId$ Ct$ = GetCt$(Nam$,CiphId$) Print "CT length=";Len(Ct$) Print "CT = ";Ct$ 'Function GetCt$(Fi$,Id$) 'gets ciphertext from file Fi$. 'Scans file until Id string is 'found, then reads lines until 'it finds a slash. Returns the 'the string between slashes, keeping 'only characters found in Filter$. 'Lower case changed to upper case 'unless lower case is in Filter$. 'Ciphers with numbers or punctuation 'can be input by including digits, 'space, comma, etc. in Filter$. Function GetCt$(Fi$, Id$) Delim$="/" 'Slashes must surround Ct Lc$ = "abcdefghijklmnopqrstuvwxyz" Filter$="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Open Fi$ For Input As #1 Ct$ = "" If Id$ = "" Then Goto IdOk Id = 0 'Id not yet found Do While Not Eof(1) Line Input #1, Lin$ Id = Instr(1, Lin$, Id$) If Id > 0 Then Exit Do Loop If Id = 0 Then Goto Done IdOk: Sl = 0 'Slash not yet found Do While Not Eof(1) Line Input #1, Lin$ For I = 1 To Len(Lin$) C$ = Mid$(Lin$, I, 1) If C$ = Delim$ Then If Sl = 1 Then Goto Done Sl = 1 '1st slash found Goto nextchar End If If Sl = 0 Then Goto nextchar If Instr(1,Filter$,C$) Then Ct$ = Ct$ + C$ Elseif Instr(1, Lc$, C$) Then C$ = Chr$(Asc(C$) - 32) Ct$ = Ct$ + C$ End If Nextchar: Next I Loop 'while not eof Done: Close #1 GetCt$=Ct$ End Function 'GetCt$