03-21-2025, 07:49 AM
(This post was last modified: 03-21-2025, 08:59 AM by z-s.
Edit Reason: Added code in blocks
)
Hi there:
Not sure what I am doing wrong, I tried to write a simple cipher program for kids to play. The prime IDE compiled without any problem, but once create the new map and input the text to encrypt, the program terminated without showing the result in text window... I have created the unique word group it is saved into my P drive. I will have to post this in multiple parts as it has exceeded the maximum number of characters allowed
Any help would be great.
here are the code:
Not sure what I am doing wrong, I tried to write a simple cipher program for kids to play. The prime IDE compiled without any problem, but once create the new map and input the text to encrypt, the program terminated without showing the result in text window... I have created the unique word group it is saved into my P drive. I will have to post this in multiple parts as it has exceeded the maximum number of characters allowed
Any help would be great.
here are the code:
Code:
' Unified Encryption and Decryption Program for Small Basic
TextWindow.Write("Encrypt (E) or Decrypt (D)? ")
mode = Text.ConvertToLowerCase(TextWindow.Read())
If mode = "e" Then
Goto encryptMode
ElseIf mode = "d" Then
Goto decryptMode
Else
TextWindow.WriteLine("Invalid mode. Use E or D.")
Program.End()
EndIf
encryptMode:
CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
spaceReplacement = "空"
usedCombinations = ""
For i = 1 To 26
alphabet[i] = Text.GetCharacterCode(Text.GetSubText("ABCDEFGHIJKLMNOPQRSTUVWXYZ", i, 1))
EndFor
For i = 27 To 52
alphabet[i] = Text.GetCharacterCode(Text.GetSubText("abcdefghijklmnopqrstuvwxyz", i - 26, 1))
EndFor
TextWindow.WriteLine("Select cipher session:")
TextWindow.WriteLine("0: Generate new cipher map")
' Example hardcoded list
sessionList[1] = "p:\cipherwheel\session_maps\letter_map_2025-03-15_10-22-35.map"
sessionList[2] = "p:\cipherwheel\session_maps\letter_map_2025-03-16_11-30-00.map"
sessionList[3] = "p:\cipherwheel\session_maps\letter_map_2025-03-17_14-42-55.map"
sessionList[4] = "p:\cipherwheel\session_maps\letter_map_2025-03-18_16-12-45.map"
sessionList[5] = "p:\cipherwheel\session_maps\letter_map_2025-03-19_18-03-30.map"
sessionList[6] = "p:\cipherwheel\session_maps\letter_map_2025-03-20_09-44-10.map"
For i = 1 To 6
If sessionList[i] <> "" Then
TextWindow.WriteLine(i + ": " + sessionList[i])
EndIf
EndFor
TextWindow.Write("Choicp: ")
choice = TextWindow.ReadNumber()
If choice = 0 Then
now = Clock.Date + " " + Clock.Time
newTime = ""
For i = 1 To Text.GetLength(now)
ch = Text.GetSubText(now, i, 1)
If ch = "/" Or ch = ":" Then
newTime = newTime + "-"
ElseIf ch = " " Then
newTime = newTime + "_"
Else
newTime = newTime + ch
EndIf
EndFor
now = newTime
sessionMapPath = "p:\cipherwheel\session_maps\letter_map_" + now + ".map"
File.WriteContents("p:\cipherwheel\last_session.txt", sessionMapPath)
File.DeleteFile("p:\cipherwheel\letter.map")