We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
some help - part one
#2
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()
Reply


Messages In This Thread
some help - part one - by Yumda - 03-21-2025, 07:49 AM
RE: some help - part one - by Yumda - 03-21-2025, 07:50 AM
RE: some help - part one - by Yumda - 03-21-2025, 07:50 AM
RE: some help - part one - by z-s - 03-21-2025, 09:02 AM
RE: some help - part one - by Yumda - 03-21-2025, 10:35 AM
RE: some help - part one - by AbsoluteBeginner - 03-21-2025, 12:21 PM
RE: some help - part one - by litdev - 03-21-2025, 02:41 PM
RE: some help - part one - by Yumda - 03-22-2025, 09:16 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)