restart; with(Maplets[Elements]): tadvance := proc(let) local abet, loc, nlet; abet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; loc := StringTools:-Search(let, abet); if loc < 26 then nlet := abet[loc+1]; else nlet := abet[1]; fi: convert(nlet, symbol); end: treverse := proc(let) local abet, loc, nlet; abet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; loc := StringTools:-Search(let, abet); if loc > 1 then nlet := abet[loc-1]; else nlet := abet[26]; fi: convert(nlet, symbol); end: capt := proc(llist) local i, nlist; nlist := []; for i from 1 to nops(llist) do nlist := [op(nlist), StringTools[Select](StringTools[IsUpper], StringTools[UpperCase](convert(llist[i], string)))] od: nlist; end: pclean := proc(plugL) local nplugL, oplugL, i, tset; oplugL := capt(plugL); nplugL := []; for i from 1 to nops(oplugL) do if length(oplugL[i]) = 2 then nplugL := [op(nplugL), oplugL[i]]; tset := oplugL[i]; subsop(i = NULL, oplugL); break; fi: od: for i from 1 to nops(oplugL) do if length(oplugL[i]) = 2 then if StringTools:-Search(oplugL[i][1], tset) = 0 and StringTools:-Search(oplugL[i][2], tset) = 0 then tset := cat(tset, oplugL[i]); nplugL := [op(nplugL), oplugL[i]]; fi: fi: od: nplugL; end: plugb := proc(let, plugL) local nplugL, nlet, i; nlet := let; nplugL := pclean(plugL); for i from 1 to nops(nplugL) do if let = nplugL[i][1] then nlet := nplugL[i][2]; elif let = nplugL[i][2] then nlet := nplugL[i][1]; fi: od: nlet; end: enigma := proc(inp, word, iiset, rrset, pb, rt, r4type) local r, ref, abet, ltable, iset, rset, newiset, offset, r4offset, let, i, n, r4, r4set, rotor4; r[1] := "EKMFLGDQVZNTOWYHXUSPAIBRCJ"; r[2] := "AJDKSIRUXBLHWTMCQGZNPYFVOE"; r[3] := "BDFHJLCPRTXVZNYEIWGAKMUSQO"; r[4] := "ESOVPZJAYQUIRHXLNFTGKDCMWB"; r[5] := "VZBRGITYUPSDNHLXAWMJQOFECK"; r[6] := "JPGVOUMFYQBENHZRDKASXLICTW"; r[7] := "NZJHGRCXMYSWBOUFAIVLPEKQDT"; r[8] := "FKQHTLXOCBJSPDZRAMEWNIUYGV"; n[1] := "Q"; n[2] := "E"; n[3] := "V"; n[4] := "J"; n[5] := "Z"; n[6] := ["Z", "M"]; n[7] := ["Z", "M"]; n[8] := ["Z", "M"]; abet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; ltable := table(); for i from 1 to 26 do ltable[ abet[i] ] := i: od: iset := iiset; rset := rrset; r4 := 0; if length(iset) = 4 then r4 := iset[1]; iset := cat(iset[2], iset[3], iset[4]); r4set := rset[1]; rset := subsop(1 = NULL, rset); if rt = "B" then ref := "ENKQAUYWJICOPBLMDXZVFTHRGS"; else ref := "RDOBJNTKVEHMLFCWZAXGYIPSUQ"; fi: if r4type = "beta" then rotor4 := "LEYJVCNIXWPBQMDRTAKZGFUHOS"; else rotor4 := "FSOKANUERHMBTIYCWLQPZXVGJD"; fi: else if rt = "B" then ref := "YRUHQSLDPXNGOKMIEBFZCWVJAT"; else ref := "FVPJIAOYEDRZXWGCTKUQSBNMHL"; fi: fi: if (ltable[ iset[3] ] + 1) mod 26 <> 0 then newiset := cat(iset[1], iset[2], abet[ (ltable[ iset[3] ] + 1) mod 26 ]); else newiset := cat(iset[1], iset[2], abet[26]); fi: if iset[3] = n[word[3]][1] or iset[3] = n[word[3]][2] then if (ltable[ newiset[2] ] + 1) mod 26 <> 0 then newiset := cat(newiset[1], abet[ (ltable[ newiset[2] ] + 1) mod 26 ], newiset[3]); else newiset := cat(newiset[1], abet[26], newiset[3]); fi: fi: if iset[2] = n[word[2]][1] or iset[2] = n[word[2]][2] then if (ltable[ newiset[1] ] + 1) mod 26 <> 0 then newiset := cat(abet[ (ltable[ newiset[1] ] + 1) mod 26 ], newiset[2], newiset[3]); else newiset := cat(abet[26], newiset[2], newiset[3]); fi: if (ltable[ newiset[2] ] + 1) mod 26 <> 0 and iset[3] <> n[word[3]][1] and iset[3] <> n[word[3]][2] then newiset := cat(newiset[1], abet[ (ltable[ newiset[2] ] + 1) mod 26 ], newiset[3]); elif iset[3] <> n[word[3]][1] and iset[3] <> n[word[3]][2] then newiset := cat(newiset[1], abet[26], newiset[3]); fi: fi: let := plugb(inp, pb); offset[3] := ltable[newiset[3]] - rset[3]; if (ltable[let] + offset[3]) mod 26 <> 0 then let := abet[(ltable[let] + offset[3]) mod 26]; else let := abet[26]; fi: let := r[word[3]][ltable[let]]; if (ltable[let] - offset[3]) mod 26 <> 0 then let := abet[(ltable[let] - offset[3]) mod 26]; else let := abet[26]; fi: offset[2] := ltable[newiset[2]] - rset[2]; if (ltable[let] + offset[2]) mod 26 <> 0 then let := abet[(ltable[let] + offset[2]) mod 26]; else let := abet[26]; fi: let := r[word[2]][ltable[let]]; if (ltable[let] - offset[2]) mod 26 <> 0 then let := abet[(ltable[let] - offset[2]) mod 26]; else let := abet[26]; fi: offset[1] := ltable[newiset[1]] - rset[1]; if (ltable[let] + offset[1]) mod 26 <> 0 then let := abet[(ltable[let] + offset[1]) mod 26]; else let := abet[26]; fi: let := r[word[1]][ltable[let]]; if (ltable[let] - offset[1]) mod 26 <> 0 then let := abet[(ltable[let] - offset[1]) mod 26]; else let := abet[26]; fi: if r4 <> 0 then r4offset := ltable[r4] - r4set; if (ltable[let] + r4offset) mod 26 <> 0 then let := abet[(ltable[let] + r4offset) mod 26]; else let := abet[26]; fi: let := rotor4[ltable[let]]; if (ltable[let] - r4offset) mod 26 <> 0 then let := abet[(ltable[let] - r4offset) mod 26]; else let := abet[26]; fi: fi: let := ref[ltable[let]]; if r4 <> 0 then if (ltable[let] + r4offset) mod 26 <> 0 then let := abet[(ltable[let] + r4offset) mod 26]; else let := abet[26]; fi: let := abet[ StringTools:-Search(let, rotor4) ]; if (ltable[let] - r4offset) mod 26 <> 0 then let := abet[(ltable[let] - r4offset) mod 26]; else let := abet[26]; fi: fi: if (ltable[let] + offset[1]) mod 26 <> 0 then let := abet[(ltable[let] + offset[1]) mod 26]; else let := abet[26]; fi: let := abet[ StringTools:-Search(let, r[word[1]]) ]; if (ltable[let] - offset[1]) mod 26 <> 0 then let := abet[(ltable[let] - offset[1]) mod 26]; else let := abet[26]; fi: if (ltable[let] + offset[2]) mod 26 <> 0 then let := abet[(ltable[let] + offset[2]) mod 26]; else let := abet[26]; fi: let := abet[ StringTools:-Search(let, r[word[2]]) ]; if (ltable[let] - offset[2]) mod 26 <> 0 then let := abet[(ltable[let] - offset[2]) mod 26]; else let := abet[26]; fi: if (ltable[let] + offset[3]) mod 26 <> 0 then let := abet[(ltable[let] + offset[3]) mod 26]; else let := abet[26]; fi: let := abet[ StringTools:-Search(let, r[word[3]]) ]; if (ltable[let] - offset[3]) mod 26 <> 0 then let := abet[(ltable[let] - offset[3]) mod 26]; else let := abet[26]; fi: let := plugb(let, pb); if r4 <> 0 then newiset := cat(r4, newiset); fi: RETURN(let, newiset); end: enigmain := proc(ilet) local let, rn, word, rset, wset, r4type, ref, pb, ct, llet, abet, i, npb; abet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; let := convert(ilet, string); Maplets:-Tools:-Set('TW1'('value') = StringTools[Select](StringTools[IsUpper], StringTools[UpperCase](convert(Maplets:-Tools:-Get('TW1'), string)))); Maplets:-Tools:-Set('TW2'('value') = StringTools[Select](StringTools[IsUpper], StringTools[UpperCase](convert(Maplets:-Tools:-Get('TW2'), string)))); Maplets:-Tools:-Set('TW3'('value') = StringTools[Select](StringTools[IsUpper], StringTools[UpperCase](convert(Maplets:-Tools:-Get('TW3'), string)))); Maplets:-Tools:-Set('TW4'('value') = StringTools[Select](StringTools[IsUpper], StringTools[UpperCase](convert(Maplets:-Tools:-Get('TW4'), string)))); rn := Maplets:-Tools:-Get('DDRN'::integer, corrections); if rn = 4 then r4type := convert(Maplets:-Tools:-Get('DDW1'), string); word := [convert(convert(Maplets:-Tools:-Get('DDW2'::algebraic, corrections), string), arabic), convert(convert(Maplets:-Tools:-Get('DDW3'::algebraic, corrections), string), arabic), convert(convert(Maplets:-Tools:-Get('DDW4'::algebraic, corrections), string), arabic)]; rset := [Maplets:-Tools:-Get('DDR1'::integer, corrections), Maplets:-Tools:-Get('DDR2'::integer, corrections), Maplets:-Tools:-Get('DDR3'::integer, corrections), Maplets:-Tools:-Get('DDR4'::integer, corrections)]; wset := cat(convert(Maplets:-Tools:-Get('TW1'), string), convert(Maplets:-Tools:-Get('TW2'), string), convert( Maplets:-Tools:-Get('TW3'), string), convert(Maplets:-Tools:-Get('TW4'), string)); elif rn = 3 then r4type := "": word := [convert(convert(Maplets:-Tools:-Get('DDW2'::algebraic, corrections), string), arabic), convert(convert(Maplets:-Tools:-Get('DDW3'::algebraic, corrections), string), arabic), convert(convert(Maplets:-Tools:-Get('DDW4'::algebraic, corrections), string), arabic)]; rset := [Maplets:-Tools:-Get('DDR2'::integer, corrections), Maplets:-Tools:-Get('DDR3'::integer, corrections), Maplets:-Tools:-Get('DDR4'::integer, corrections)]; wset := cat(convert(Maplets:-Tools:-Get('TW2'), string), convert( Maplets:-Tools:-Get('TW3'), string), convert(Maplets:-Tools:-Get('TW4'), string)); fi: ref := Maplets:-Tools:-Get('DDR'); pb := [convert(Maplets:-Tools:-Get('TPB1'), string), convert(Maplets:-Tools:-Get('TPB2'), string), convert(Maplets:-Tools:-Get('TPB3'), string), convert(Maplets:-Tools:-Get('TPB4'), string), convert(Maplets:-Tools:-Get('TPB5'), string), convert(Maplets:-Tools:-Get('TPB6'), string), convert(Maplets:-Tools:-Get('TPB7'), string), convert(Maplets:-Tools:-Get('TPB8'), string), convert(Maplets:-Tools:-Get('TPB9'), string), convert(Maplets:-Tools:-Get('TPB10'), string), convert(Maplets:-Tools:-Get('TPB11'), string), convert(Maplets:-Tools:-Get('TPB12'), string), convert(Maplets:-Tools:-Get('TPB13'), string)]; pb := pclean(pb); for i from 1 to nops(pb) do npb := convert(cat("TPB", convert(i, string)), symbol); Maplets:-Tools:-Set(npb = convert(pb[i], symbol)); od: for i from nops(pb) + 1 to 13 do npb := convert(cat("TPB", convert(i, string)), symbol); Maplets:-Tools:-Set(npb = ""); od: ct := enigma(let, word, wset, rset, pb, ref, r4type); for i from 1 to 26 do llet := convert(cat("T", abet[i]), symbol); Maplets:-Tools:-Set(llet('background') = 'white'); od: llet := convert(cat("T", ct[1]), symbol); Maplets:-Tools:-Set(llet('background') = 'yellow'); if rn = 4 then Maplets:-Tools:-Set('TW2' = ct[2][2], 'TW3' = ct[2][3], 'TW4' = ct[2][4]); elif rn = 3 then Maplets:-Tools:-Set('TW2' = ct[2][1], 'TW3' = ct[2][2], 'TW4' = ct[2][3]); fi: Maplets:-Tools:-Set('TB1'('append') = let); Maplets:-Tools:-Set('TB2'('append') = ct[1]); if Maplets:-Tools:-Get('CHB1') = true and length( StringTools:-Remove( rcurry( member, { " " } ), Maplets:-Tools:-Get('TB2'))) mod 5 = 0 then Maplets:-Tools:-Set('TB1'('append') = " "); Maplets:-Tools:-Set('TB2'('append') = " "); fi: end: wsetup := proc(rv) if rv = 4 then Maplets:-Tools:-Set('DDW1'('enabled') = 'true', 'DDW2'('enabled') = 'true', 'DDW3'('enabled') = 'true', 'DDW4'('enabled') = 'true', 'DDR1'('enabled') = 'true', 'DDR2'('enabled') = 'true', 'DDR3'('enabled') = 'true', 'DDR4'('enabled') = 'true', 'DDR'('enabled') = 'true', 'BAW1'('enabled') = 'true', 'BAW2'('enabled') = 'true', 'BAW3'('enabled') = 'true', 'BAW4'('enabled') = 'true', 'BAR1'('enabled') = 'true', 'BAR2'('enabled') = 'true', 'BAR3'('enabled') = 'true', 'BAR4'('enabled') = 'true', 'TW1'('background') = 'white', 'TW2'('background') = 'white', 'TW3'('background') = 'white', 'TW4'('background') = 'white', 'TW1'('editable') = 'true', 'TW2'('editable') = 'true', 'TW3'('editable') = 'true', 'TW4'('editable') = 'true'); elif rv = 3 then Maplets:-Tools:-Set('DDW1'('enabled') = 'false', 'DDW2'('enabled') = 'true', 'DDW3'('enabled') = 'true', 'DDW4'('enabled') = 'true', 'DDR1'('enabled') = 'false', 'DDR2'('enabled') = 'true', 'DDR3'('enabled') = 'true', 'DDR4'('enabled') = 'true', 'DDR'('enabled') = 'true', 'BAW1'('enabled') = 'false', 'BAW2'('enabled') = 'true', 'BAW3'('enabled') = 'true', 'BAW4'('enabled') = 'true', 'BAR1'('enabled') = 'false', 'BAR2'('enabled') = 'true', 'BAR3'('enabled') = 'true', 'BAR4'('enabled') = 'true', 'TW1'('background') = 'black', 'TW2'('background') = 'white', 'TW3'('background') = 'white', 'TW4'('background') = 'white', 'TW1'('editable') = 'false', 'TW2'('editable') = 'true', 'TW3'('editable') = 'true', 'TW4'('editable') = 'true' ); fi: Maplets:-Tools:-Set('BQ'('enabled') = 'true', 'BW'('enabled') = 'true', 'BE'('enabled') = 'true', 'BR'('enabled') = 'true', 'BT'('enabled') = 'true', 'BZ'('enabled') = 'true', 'BU'('enabled') = 'true', 'BI'('enabled') = 'true', 'BO'('enabled') = 'true', 'BA'('enabled') = 'true', 'BS'('enabled') = 'true', 'BD'('enabled') = 'true', 'BF'('enabled') = 'true', 'BG'('enabled') = 'true', 'BH'('enabled') = 'true', 'BJ'('enabled') = 'true', 'BK'('enabled') = 'true', 'BP'('enabled') = 'true', 'BY'('enabled') = 'true', 'BX'('enabled') = 'true', 'BC'('enabled') = 'true', 'BV'('enabled') = 'true', 'BB'('enabled') = 'true', 'BN'('enabled') = 'true', 'BM'('enabled') = 'true', 'BL'('enabled') = 'true'); Maplets:-Tools:-Set('TPB1'('editable') = 'true', 'TPB2'('editable') = 'true', 'TPB3'('editable') = 'true', 'TPB4'('editable') = 'true', 'TPB5'('editable') = 'true', 'TPB6'('editable') = 'true', 'TPB7'('editable') = 'true', 'TPB8'('editable') = 'true', 'TPB9'('editable') = 'true', 'TPB10'('editable') = 'true', 'TPB11'('editable') = 'true', 'TPB12'('editable') = 'true', 'TPB13'('editable') = 'true'); end: wsetup := proc(rv) if rv = 4 then Maplets:-Tools:-Set('DDW1'('enabled') = 'true', 'DDW2'('enabled') = 'true', 'DDW3'('enabled') = 'true', 'DDW4'('enabled') = 'true', 'DDW2'('itemlist') = ["I", "II", "III", "IV", "V","VI", "VII", "VIII"], 'DDW3'('itemlist') = ["I", "II", "III", "IV", "V","VI", "VII", "VIII"], 'DDW4'('itemlist') = ["I", "II", "III", "IV", "V","VI", "VII", "VIII"], 'DDR1'('enabled') = 'true', 'DDR2'('enabled') = 'true', 'DDR3'('enabled') = 'true', 'DDR4'('enabled') = 'true', 'DDR'('enabled') = 'true', 'BAW1'('enabled') = 'true', 'BAW2'('enabled') = 'true', 'BAW3'('enabled') = 'true', 'BAW4'('enabled') = 'true', 'BAR1'('enabled') = 'true', 'BAR2'('enabled') = 'true', 'BAR3'('enabled') = 'true', 'BAR4'('enabled') = 'true', 'TW1'('background') = 'white', 'TW2'('background') = 'white', 'TW3'('background') = 'white', 'TW4'('background') = 'white', 'TW1'('editable') = 'true', 'TW2'('editable') = 'true', 'TW3'('editable') = 'true', 'TW4'('editable') = 'true'); elif rv = 3 then Maplets:-Tools:-Set('DDW1'('enabled') = 'false', 'DDW2'('enabled') = 'true', 'DDW3'('enabled') = 'true', 'DDW4'('enabled') = 'true', 'DDW2'('itemlist') = ["I", "II", "III", "IV", "V"], 'DDW3'('itemlist') = ["I", "II", "III", "IV", "V"], 'DDW4'('itemlist') = ["I", "II", "III", "IV", "V"], 'DDR1'('enabled') = 'false', 'DDR2'('enabled') = 'true', 'DDR3'('enabled') = 'true', 'DDR4'('enabled') = 'true', 'DDR'('enabled') = 'true', 'BAW1'('enabled') = 'false', 'BAW2'('enabled') = 'true', 'BAW3'('enabled') = 'true', 'BAW4'('enabled') = 'true', 'BAR1'('enabled') = 'false', 'BAR2'('enabled') = 'true', 'BAR3'('enabled') = 'true', 'BAR4'('enabled') = 'true', 'TW1'('background') = 'black', 'TW2'('background') = 'white', 'TW3'('background') = 'white', 'TW4'('background') = 'white', 'TW1'('editable') = 'false', 'TW2'('editable') = 'true', 'TW3'('editable') = 'true', 'TW4'('editable') = 'true' ); fi: Maplets:-Tools:-Set('BQ'('enabled') = 'true', 'BW'('enabled') = 'true', 'BE'('enabled') = 'true', 'BR'('enabled') = 'true', 'BT'('enabled') = 'true', 'BZ'('enabled') = 'true', 'BU'('enabled') = 'true', 'BI'('enabled') = 'true', 'BO'('enabled') = 'true', 'BA'('enabled') = 'true', 'BS'('enabled') = 'true', 'BD'('enabled') = 'true', 'BF'('enabled') = 'true', 'BG'('enabled') = 'true', 'BH'('enabled') = 'true', 'BJ'('enabled') = 'true', 'BK'('enabled') = 'true', 'BP'('enabled') = 'true', 'BY'('enabled') = 'true', 'BX'('enabled') = 'true', 'BC'('enabled') = 'true', 'BV'('enabled') = 'true', 'BB'('enabled') = 'true', 'BN'('enabled') = 'true', 'BM'('enabled') = 'true', 'BL'('enabled') = 'true'); Maplets:-Tools:-Set('TPB1'('editable') = 'true', 'TPB2'('editable') = 'true', 'TPB3'('editable') = 'true', 'TPB4'('editable') = 'true', 'TPB5'('editable') = 'true', 'TPB6'('editable') = 'true', 'TPB7'('editable') = 'true', 'TPB8'('editable') = 'true', 'TPB9'('editable') = 'true', 'TPB10'('editable') = 'true', 'TPB11'('editable') = 'true', 'TPB12'('editable') = 'true', 'TPB13'('editable') = 'true'); end: clearvar := proc() local i, llet, abet; abet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Maplets:-Tools:-Set('DDRN'('value') = "?", 'DDW1'('enabled') = 'false', 'DDW2'('enabled') = 'false', 'DDW3'('enabled') = 'false', 'DDW4'('enabled') = 'false', 'DDW1'('value') = "beta", 'DDW2'('value') = "I", 'DDW3'('value') = "I", 'DDW4'('value') = "I", 'DDR1'('value') = "1", 'DDR2'('value') = "1", 'DDR3'('value') = "1", 'DDR4'('value') = "1",'DDR1'('enabled') = 'false', 'DDR2'('enabled') = 'false', 'DDR3'('enabled') = 'false', 'DDR4'('enabled') = 'false', 'DDR'('enabled') = 'false', 'DDR'('value') = "B", 'BAW1'('enabled') = 'false', 'BAW2'('enabled') = 'false', 'BAW3'('enabled') = 'false', 'BAW4'('enabled') = 'false', 'BAR1'('enabled') = 'false', 'BAR2'('enabled') = 'false', 'BAR3'('enabled') = 'false', 'BAR4'('enabled') = 'false', 'TW1'('background') = 'black', 'TW2'('background') = 'black', 'TW3'('background') = 'black', 'TW4'('background') = 'black', 'TW1'('editable') = 'false', 'TW2'('editable') = 'false', 'TW3'('editable') = 'false', 'TW4'('editable') = 'false', 'TW1'('value') = "A", 'TW2'('value') = "A", 'TW3'('value') = "A", 'TW4'('value') = "A"); Maplets:-Tools:-Set('BQ'('enabled') = 'false', 'BW'('enabled') = 'false', 'BE'('enabled') = 'false', 'BR'('enabled') = 'false', 'BT'('enabled') = 'false', 'BZ'('enabled') = 'false', 'BU'('enabled') = 'false', 'BI'('enabled') = 'false', 'BO'('enabled') = 'false', 'BA'('enabled') = 'false', 'BS'('enabled') = 'false', 'BD'('enabled') = 'false', 'BF'('enabled') = 'false', 'BG'('enabled') = 'false', 'BH'('enabled') = 'false', 'BJ'('enabled') = 'false', 'BK'('enabled') = 'false', 'BP'('enabled') = 'false', 'BY'('enabled') = 'false', 'BX'('enabled') = 'false', 'BC'('enabled') = 'false', 'BV'('enabled') = 'false', 'BB'('enabled') = 'false', 'BN'('enabled') = 'false', 'BM'('enabled') = 'false', 'BL'('enabled') = 'false'); Maplets:-Tools:-Set('TPB1'('editable') = 'false', 'TPB2'('editable') = 'false', 'TPB3'('editable') = 'false', 'TPB4'('editable') = 'false', 'TPB5'('editable') = 'false', 'TPB6'('editable') = 'false', 'TPB7'('editable') = 'false', 'TPB8'('editable') = 'false', 'TPB9'('editable') = 'false', 'TPB10'('editable') = 'false', 'TPB11'('editable') = 'false', 'TPB12'('editable') = 'false', 'TPB13'('editable') = 'false', 'TPB1'('value') = "", 'TPB2'('value') = "", 'TPB3'('value') = "", 'TPB4'('value') = "", 'TPB5'('value') = "", 'TPB6'('value') = "", 'TPB7'('value') = "", 'TPB8'('value') = "", 'TPB9'('value') = "", 'TPB10'('value') = "",'TPB11'('value') = "", 'TPB12'('value') = "", 'TPB13'('value') = ""); for i from 1 to 26 do llet := convert(cat("T", abet[i]), symbol); Maplets:-Tools:-Set(llet('background') = 'white'); od: Maplets:-Tools:-Set('TB1'('value') = "", 'TB2'('value') = ""); end: enigmamaplet := Maplet( Window( 'title'="Enigma Cipher", BoxColumn('halign' = 'none', 'background' = 'navy', 'inset' = 2, BoxRow('inset' = 0, 'halign' = 'none', BoxColumn(DropDownBox['DDRN']( 'value' = "?", ["?", "3", "4"], 'font' = Font("times", 14), 'enabled' = 'true', onchange = Action(Evaluate('function' = "wsetup", 'DDRN')) ), 'spacing' = 0, Label("# of", 'font' = Font("arial", 16)), Label("Rotors", 'font' = Font("arial", 16))), BoxColumn(DropDownBox['DDR']( 'value' = "B", ["B", "C"], 'font' = Font("times", 14), 'enabled' = 'false' ), Label("Reflector", 'font' = Font("arial", 16))), BoxColumn(BoxRow(DropDownBox['DDW1']( 'value' = "beta", ["beta", "gamma"], 'font' = Font("times", 15), 'enabled' = 'false'), DropDownBox['DDW2']( 'value' = "I", ["I", "II", "III", "IV", "V", "VI", "VII", "VIII"], 'enabled' = 'false', 'font' = Font("times", bold, 14)), DropDownBox['DDW3']( 'value' = "I", ["I", "II", "III", "IV", "V", "VI", "VII", "VIII"], 'enabled' = 'false', 'font' = Font("times", bold, 14)), DropDownBox['DDW4']( 'value' = "I", ["I", "II", "III", "IV", "V", "VI", "VII", "VIII"], 'enabled' = 'false', 'font' = Font("times", bold, 14))), Label("Rotors", 'font' = Font("arial", 16))), BoxColumn(BoxRow(DropDownBox['DDR1']( 'value' = "1", ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16","17", "18", "19", "20", "21", "22", "23", "24", "25", "26"], 'font' = Font("times", 14), 'enabled' = 'false'), DropDownBox['DDR2']( 'value' = "1", ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16","17", "18", "19", "20", "21", "22", "23", "24", "25", "26"], 'font' = Font("times", 14), 'enabled' = 'false'), DropDownBox['DDR3']( 'value' = "1", ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"], 'font' = Font("times", 14), 'enabled' = 'false'), DropDownBox['DDR4']( 'value' = "1", ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16","17", "18", "19", "20", "21", "22", "23", "24", "25", "26"], 'font' = Font("times", 14), 'enabled' = 'false')), Label("Ring Settings", 'font' = Font("arial", 16))), seq(HorizontalGlue(), i = 1..2) ), BoxRow('halign' = 'none', 'inset' = 0, seq(HorizontalGlue(), i = 1..15), Label("Window Letters: ", 'font' = Font("arial", 16)), BoxColumn( Button['BAW1']( 'background' = 'black', 'caption' = ">>", 'enabled' = 'false', 'font' = Font("times",bold, 10), Evaluate('TW1' = "tadvance", Argument('TW1', 'quotedtext' = 'true') ) ), TextField['TW1']('foreground' = 'black', 'background' = 'black', 'editable' = 'false', 'value' = "A", 2, 'font' = Font("times", bold, 12), 'halign' = 'center'), Button['BAR1']( 'background' = 'black', 'caption' = "<<", 'enabled' = 'false', 'font' = Font("times",bold, 10), Evaluate('TW1' = "treverse", Argument('TW1', 'quotedtext' = 'true')) )), BoxColumn( Button['BAW2']( 'background' = 'black', 'caption' = ">>", 'enabled' = 'false', 'font' = Font("times",bold, 10), Evaluate('TW2' = "tadvance", Argument('TW2', 'quotedtext' = 'true') ) ), TextField['TW2']('foreground' = 'black', 'background' = 'black', 'editable' = 'false', 'value' = "A", 2, 'font' = Font("times", bold, 12), 'halign' = 'center'), Button['BAR2']( 'background' = 'black', 'caption' = "<<", 'enabled' = 'false', 'font' = Font("times",bold, 10), Evaluate('TW2' = "treverse", Argument('TW2', 'quotedtext' = 'true')) )), BoxColumn( Button['BAW3']( 'background' = 'black', 'caption' = ">>", 'enabled' = 'false', 'font' = Font("times",bold, 10), Evaluate('TW3' = "tadvance", Argument('TW3', 'quotedtext' = 'true')) ), TextField['TW3']('foreground' = 'black', 'background' = 'black', 'editable' = 'false', 'value' = "A", 2, 'font' = Font("times", bold, 12), 'halign' = 'center'), Button['BAR3']( 'background' = 'black', 'caption' = "<<", 'enabled' = 'false', 'font' = Font("times",bold, 10), Evaluate('TW3' = "treverse", Argument('TW3', 'quotedtext' = 'true')) )), BoxColumn( Button['BAW4']( 'background' = 'black', 'caption' = ">>", 'enabled' = 'false', 'font' = Font("times",bold, 10), Evaluate('TW4' = "tadvance", Argument('TW4', 'quotedtext' = 'true')) ), TextField['TW4']('foreground' = 'black', 'background' = 'black', 'editable' = 'false', 'value' = "A", 2, 'font' = Font("times", bold, 12), 'halign' = 'center'), Button['BAR4']( 'background' = 'black', 'caption' = "<<", 'enabled' = 'false', 'font' = Font("times",bold, 10), Evaluate('TW4' = "treverse", Argument('TW4', 'quotedtext' = 'true')) )), seq(HorizontalGlue(), i = 1..30) ), BoxColumn('background' = 'black', 'halign'= 'none', BoxRow('halign' = 'none', seq(HorizontalGlue(), i = 1..6), TextField['TQ']('foreground' = 'red', 'background' = 'white', 'value' = "Q", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TW']('foreground' = 'red', 'background' = 'white', 'value' = "W", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false','halign' = 'center'), TextField['TE']('foreground' = 'red', 'background' = 'white', 'value' = "E", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TR']('foreground' = 'red', 'background' = 'white', 'value' = "R", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TT']('foreground' = 'red', 'background' = 'white', 'value' = "T", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' ='center'), TextField['TZ']('foreground' = 'red', 'background' = 'white', 'value' = "Z", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TU']('foreground' = 'red', 'background' = 'white', 'value' = "U", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TI']('foreground' = 'red', 'background' = 'white', 'value' = "I", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TO']('foreground' = 'red', 'background' = 'white', 'value' = "O", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' ='center'), seq(HorizontalGlue(), i = 1..6) ), BoxRow('halign' = 'none', seq(HorizontalGlue(), i = 1..5), " ", TextField['TA']('foreground' = 'red', 'background' = 'white', 'value' = "A", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TS']('foreground' = 'red', 'background' = 'white', 'value' = "S", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TD']('foreground' = 'red', 'background' = 'white', 'value' = "D", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TF']('foreground' = 'red', 'background' = 'white', 'value' = "F", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TG']('foreground' = 'red', 'background' = 'white', 'value' = "G", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TH']('foreground' = 'red', 'background' = 'white', 'value' = "H", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TJ']('foreground' = 'red', 'background' = 'white', 'value' = "J", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TK']('foreground' = 'red', 'background' = 'white', 'value' = "K", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' ='center'), seq(HorizontalGlue(), i = 1..6)), BoxRow('halign' = 'none', seq(HorizontalGlue(), i = 1..6), TextField['TP']('foreground' = 'red', 'background' = 'white', 'value' = "P", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TY']('foreground' = 'red', 'background' = 'white', 'value' = "Y", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TX']('foreground' = 'red', 'background' = 'white', 'value' = "X", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TC']('foreground' = 'red', 'background' = 'white', 'value' = "C", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TV']('foreground' = 'red', 'background' = 'white', 'value' = "V", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TB']('foreground' = 'red', 'background' = 'white', 'value' = "B", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TN']('foreground' = 'red', 'background' = 'white', 'value' = "N", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TM']('foreground' = 'red', 'background' = 'white', 'value' = "M", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), TextField['TL']('foreground' = 'red', 'background' = 'white', 'value' = "L", 3, 'font' = Font("arial", bold, 14), 'editable' = 'false', 'halign' = 'center'), seq(HorizontalGlue(), i = 1..6) ) ), BoxColumn('background' = 'black', 'halign'= 'none', BoxRow('halign' = 'none', 'inset' = 0, 'background' = 'black', Button['BQ']('foreground' = 'blue', 'background' = 'black', 'caption' = "Q", 'enabled' = 'false', 'font' = Font("arial",bold, 14), Evaluate('function' = 'enigmain(Q)') ), Button['BW']('foreground' = 'blue', 'background' = 'black', 'caption' = "W", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(W)')), Button['BE']('foreground' = 'blue', 'background' = 'black', 'caption' = "E", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(E)')), Button['BR']('foreground' = 'blue', 'background' = 'black', 'caption' = "R", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(R)')), Button['BT']('foreground' = 'blue', 'background' = 'black', 'caption' = "T", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(T)')), Button['BZ']('foreground' = 'blue', 'background' = 'black', 'caption' = "Z", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(Z)')), Button['BU']('foreground' = 'blue', 'background' = 'black', 'caption' = "U", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(U)')), Button['BI']('foreground' = 'blue', 'background' = 'black', 'caption' = "I", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(I)')), Button['BO']('foreground' = 'blue', 'background' = 'black', 'caption' = "O", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(O)'))), BoxRow('halign' = 'none', " ", 'background' = 'black', Button['BA']('foreground' = 'blue', 'background' = 'black', 'caption' = "A", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(A)')), Button['BS']('foreground' = 'blue', 'background' = 'black', 'caption' = "S", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(S)')), Button['BD']('foreground' = 'blue', 'background' = 'black', 'caption' = "D", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(D)')), Button['BF']('foreground' = 'blue', 'background' = 'black', 'caption' = "F", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(F)')), Button['BG']('foreground' = 'blue', 'background' = 'black', 'caption' = "G", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(G)')), Button['BH']('foreground' = 'blue', 'background' = 'black', 'caption' = "H", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(H)')), Button['BJ']('foreground' = 'blue', 'background' = 'black', 'caption' = "J", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(J)')), Button['BK']('foreground' = 'blue', 'background' = 'black', 'caption' = "K", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(K)'))), BoxRow('halign' = 'none', 'background' = 'black', Button['BP']('foreground' = 'blue', 'background' = 'black', 'caption' = "P", 'enabled' = 'false', 'font' = Font("arial",bold, 14), Evaluate('function' = 'enigmain(P)')), Button['BY']('foreground' = 'blue', 'background' = 'black', 'caption' = "Y", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(Y)')), Button['BX']('foreground' = 'blue', 'background' = 'black', 'caption' = "X", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(X)')), Button['BC']('foreground' = 'blue', 'background' = 'black', 'caption' = "C", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(C)')), Button['BV']('foreground' = 'blue', 'background' = 'black', 'caption' = "V", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(V)')), Button['BB']('foreground' = 'blue', 'background' = 'black', 'caption' = "B", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(B)')), Button['BN']('foreground' = 'blue', 'background' = 'black', 'caption' = "N", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(N)')), Button['BM']('foreground' = 'blue', 'background' = 'black', 'caption' = "M", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(M)')), Button['BL']('foreground' = 'blue', 'background' = 'black', 'caption' = "L", 'enabled' = 'false', 'font' = Font("arial", bold, 14), Evaluate('function' = 'enigmain(L)'))) ), BoxRow('halign' = 'none', Label("Plugboard Connections: ", 'font' = Font("arial", 16)), TextField['TPB1']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false','halign' = 'center'), TextField['TPB2']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false','halign' = 'center'), TextField['TPB3']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' = 'center'), TextField['TPB4']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' = 'center'), TextField['TPB5']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' ='center'), TextField['TPB6']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' = 'center'), TextField['TPB7']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' = 'center'), TextField['TPB8']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' = 'center'), TextField['TPB9']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' ='center'), TextField['TPB10']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' ='center'), TextField['TPB11']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' ='center'), TextField['TPB12']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' ='center'), TextField['TPB13']('foreground' = 'Teal', 'background' = 'white', 2, 'font' = Font("arial", bold, 13), 'editable' = 'false', 'halign' ='center')), BoxRow( BoxColumn('inset' = 0, " ", " ", " ", " ", Label("5 letter", 'font' = Font("arial", 16)), Label("display", 'font' = Font("arial", 16)), CheckBox['CHB1']('value' = 'true', 'background' = 'gold'), " ", " ", " ", " ", 'spacing' = 0), BoxColumn('background' = 'navy', BoxRow('halign' = 'none', 'inset' = 1, BoxColumn('spacing' = 0, " ", Label("Input ", 'font' = Font("arial", 16)), Label("Letters ", 'font' = Font("arial", 16)), " ") , TextBox['TB1']('editable' = 'false', 4..42, 'foreground' = 'blue', 'font' = Font("times", bold, 15)), seq(HorizontalGlue(), i = 1..1) ), BoxRow('halign' = 'none','inset' = 1, BoxColumn('spacing' = 0, " ", Label("Output ", 'font' = Font("arial", 16)), Label("Letters", 'font' = Font("arial", 16)), " "), TextBox['TB2']( 'editable' = 'false', 4..42, 'foreground' = 'red', 'font' = Font("times", bold, 15) ), seq(HorizontalGlue(), i = 1..1) ))), BoxRow('halign' = 'center', 'inset' = 0, 'background' = 'navy', Button( "Clear", 'font' = Font("arial", bold, 15), Action(SetOption('TB1' = ""), SetOption('TB2' = ""))), Button( "Reset", 'font' = Font("arial", bold, 15), Evaluate('function' = 'clearvar()') ), Button( "Quit", 'font' = Font("arial", bold, 15), Shutdown() ) ) ) ) ): Maplets[Display]( enigmamaplet ): # # # # # # # # # # # # # # # # # # #