Here is part 2 of the codes:
Code:
For i = 1 To 52
While "True"
fileNum = Math.GetRandomNumber(124)
lineNum = Math.GetRandomNumber(186)
filePath = "P:\cipherwheel\unique_words_groups\group_" + fileNum + ".wdef"
key = filePath + ":" + lineNum
If Text.IsSubText(usedCombinations, key) = "False" Then
usedCombinations = usedCombinations + key + "|"
word = File.ReadLine(filePath, lineNum)
letter = Text.GetCharacter(alphabet[i])
mapLine = letter + "|" + filePath + "|" + lineNum
File.AppendContents(sessionMapPath, mapLine + CRLF)
File.AppendContents("p:\cipherwheel\letter.map", mapLine + CRLF)
File.AppendContents("p:\cipherwheel\log.txt", "Letter: " + letter + " -> " + filePath + ", Linp: " + lineNum + ", Word: " + word + CRLF)
newcipheralpha[alphabet[i]] = word
Goto skipGen
EndIf
EndWhile
skipGen:
EndFor
Else
sessionMapPath = sessionList[choice]
File.WriteContents("p:\cipherwheel\last_session.txt", sessionMapPath)
For i = 1 To 52
line = File.ReadLine(sessionMapPath, i)
p1 = Text.GetIndexOf(line, "|")
p2 = Text.GetIndexOf(Text.GetSubTextToEnd(line, p1 + 1), "|") + p1
letter = Text.GetSubText(line, 1, p1 - 1)
filePath = Text.GetSubText(line, p1 + 1, p2 - p1 - 1)
lineNum = Text.GetSubTextToEnd(line, p2 + 1)
word = File.ReadLine(filePath, lineNum)
charCode = Text.GetCharacterCode(letter)
newcipheralpha[charCode] = word
usedCombinations = usedCombinations + filePath + ":" + lineNum + "|"
EndFor
EndIf
TextWindow.Write("Enter text to encodp: ")
texttoconvert = TextWindow.Read()
convertedText = ""
For i = 1 To Text.GetLength(texttoconvert)
char = Text.GetSubText(texttoconvert, i, 1)
charCode = Text.GetCharacterCode(char)
If char = " " Then
convertedText = convertedText + spaceReplacement
ElseIf newcipheralpha[charCode] <> "" Then
convertedText = convertedText + newcipheralpha[charCode] + "空"
Else
convertedText = convertedText + char + "空"
EndIf
EndFor
convertedText = Text.GetSubText(convertedText, 1, Text.GetLength(convertedText) - 1)
TextWindow.WriteLine("")
TextWindow.WriteLine("==== ENCRYPTION RESULT ====")
TextWindow.WriteLine("Original: " + texttoconvert)
TextWindow.WriteLine("Encoded: " + convertedText)
hist = "Session: " + sessionMapPath + CRLF + "Input: " + texttoconvert + CRLF + "Output: " + convertedText + CRLF + "----" + CRLF
File.AppendContents("p:\cipherwheel\history.log", hist)
Program.End()