REM mscode.bas Jim FitzSimons W7ANF 15 February, 2001 MS$ = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 'MS$ is a list of all the characters needed for MS. 'Find all codes that have equal number of low and high tones. n% = 8 'n% is the number of bits. n2% = 2 ^ n% - 1 'n2% is largest possible code with n% bits. ValidCodes% = 0 'ValidCodes% is the number of valid codes. OPEN "mscode.out" FOR OUTPUT AS #1 FOR c% = 0 TO n2% 'c% is a possible code. b% = 1 'This is the bit location mask. BitCount% = 0 'BitCount% is the difference in the number 'of high tones and low tones. a$ = "" 'a$ is sequence of tones for the code c%. FOR BitLoc% = 1 TO n% 'BitLoc% is the bit location. IF (c% AND b%) = 0 THEN BitCount% = BitCount% - 1 a$ = "1" + a$ ELSE BitCount% = BitCount% + 1 a$ = "3" + a$ END IF b% = b% + b% NEXT BitLoc% IF BitCount% = 0 THEN ValidCodes% = ValidCodes% + 1 PRINT #1, MID$(MS$, ValidCodes%, 1); " 22"; a$; ValidCodes%; c% END IF NEXT c% CLOSE #1 PRINT ValidCodes% END