Code: Select all
Enumeration
#codeco_window
#code_button
#decode_button
#text_close_box
#text_entry_box
#wavelength_box
#wavelength_title
#text_entry_title
#text_display_title
EndEnumeration
Dim code_array.b(95)
Dim alphabet.b(95)
For K = 0 To 94
alphabet(K) = K + 32
Next K
If WindowID = OpenWindow(#codeco_window, 251, 133, 538, 447, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_WindowCentered , "Coder/Decoder, by Sheep Enterprises")
If CreateGadgetList(WindowID(0))
ButtonGadget(#code_button, 10, 420, 80, 20, "Code")
GadgetToolTip(#code_button, "Click here to code text in the upper box")
ButtonGadget(#decode_button, 100, 420, 80, 20, "Decode")
GadgetToolTip(#decode_button, "Click here to decode text in the upper box")
StringGadget(#text_close_box, 10, 260, 510, 150, "")
GadgetToolTip(#text_close_box, "Coded/decoded text is entered here")
StringGadget(#text_entry_box, 10, 80, 510, 150, "")
StringGadget(#wavelength_box, 10, 30, 190, 20, "",#PB_String_Numeric)
TextGadget(#wavelength_title, 10, 10, 80, 20, "Wavelength")
TextGadget(#text_entry_title, 10, 60, 220, 20, "Text Entry")
TextGadget(#text_display_title, 10, 240, 160, 20, "Text Display")
Repeat
main_program:
code_text$ = ""
solved_code$ = ""
Repeat
random_starter = Val(GetGadgetText(#wavelength_box))
RandomSeed(random_starter)
Until random_starter <> 0
For J = 0 To 94
Repeat
do_over = 0
random_number=Random(94) + 32
For K=0 To J
If random_number = code_array(K)
do_over = 1
Break
EndIf
Next K
Until do_over = 0
code_array(J) = random_number
Next J
Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
EndIf
End
code_section:
OpenConsole()
PrintN("Enter text to be coded:")
text$ = Input()
string_length = Len(text$)
For K = 1 To string_length
For J = 0 To 94
alphabet_check$ = Chr(alphabet(J))
code_check$ = Chr(code_array(J))
If Mid(text$,K,1) = alphabet_check$
code_text$ = code_text$ + code_check$
EndIf
Next J
Next K
PrintN("")
PrintN(code_text$)
CloseConsole()
Return
Perhaps it is something wrong with my system. I have been unable to run DEW.Line. As soon as I click the little spaceship to start the program, it suddenly closes itself and ends.
But, why is the program opening up the console? I told the program to End after the If OpenWindow() loop -- it shouldn't be running the subsection of code after the End, right?