Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 19, 2023 11:47:49 GMT
[1] nomainwin response$ = "exit" prompt " 1. " + chr$(13) + " Write in English-This word "; response$ if response$ = "The correct word" then notice "Bravo!" goto [2] end if if response$ = "exit" then end else notice "Sorry!" goto [1] end if [2] nomainwin response$ = "exit" prompt " 2. " + chr$(13) + " Write in English-That word "; response$ if response$ = "The correct word" then notice "Bravo!" goto [x] end if if response$ = "exit" then end else notice "Sorry!" goto [2] [x] end if end So, this is the code I created to teach foreign kids to learn words in English, but I can't close the dialogue box when I click on the X or cancel button so I had to type in "exit" in the prompt and it closes when I click on OK button because it recognizes it as a close word. I know it doesn't make much sense to close a program using OK button, but that was the only solution I had with my limited knowledge of programming. If anyone can help me to close this program when I click on cancel or X button, I'd be very grateful. Thanks in advance
|
|
|
Post by plus on Feb 19, 2023 13:49:59 GMT
What a weird thing but you are new welcome [1]
nomainwin response$ = "exit" prompt " 1. " + chr$(13) + " Write in English-This word "; response$ if response$ = "The correct word" then notice "Bravo!" goto [2] end if
if response$ = "exit" or response$ = "" then end else notice "Sorry!" goto [1] end if
[2]
' nomainwin <<<<<<<<<<< already have that at start
response$ = "exit"
prompt " 2. " + chr$(13) + " Write in English-That word "; response$
if response$ = "The correct word" then
notice "Bravo!"
goto [x]
end if
if response$ = "exit" then
end
else
notice "Sorry!"
goto [2]
'[x] ' <<<<<<<<<<<< not best place to GoTo
end if
[x] ' maybe here but why not just end end
nomainwindow isn't needed unless you actually Open a window. Main Window is main screen for displaying Print or Input if not Opening Window like your program that doesn't Open a window. This is more normal starter program for Basic student: Dim Spanish$(2) Spanish$(1) = "Hola" Spanish$(2) = "Adios"
Dim English$(2) English$(1) = "Hello" English$(2) = "Goodbye"
word = 1
[restart] Print "What is this word in Spanish: ";English$(word); " (just <enter> quits)" Input "Enter your answer here: ";reply$ if reply$ = "" then end ' quit if just pressed enter
If upper$(reply$) = upper$(Spanish$(word)) then ' make case insensitive print "Good!" word = word + 1 if word > 2 then print "That finishes our lesson for today." end else goto [restart] end if else print "Sorry, try again." goto [restart] end if
Use Print and Input in main screen for Input and Output to program, not Prompt and Notice until you Open a window.
|
|
|
Post by tsh73 on Feb 19, 2023 18:37:39 GMT
So Welcome to the forum! (to cut it short), PROMPT returns empty string ("") on Cancel (or ESC, or closing with red X in top right corner)
And there is a code tags (button with C in a square) that meant to use then posting code.
Also Don’t click the Preview if you are posting code. Click on the BBCode before you post the code.
If you then click the Preview the forum will still spoil your post and double space the lines. So use the quick reply or
|
|
|
Post by plus on Feb 19, 2023 20:38:58 GMT
This should be the default for everyone!
|
|