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
#1
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:
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")
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)