1
I’m doing that in a program that asks the user if he wants to continue using the program or if he wants to quit. So far, I can already make the program close with the user by typing "close", but when I try to type "restart" nothing happens, just skip the line on the console.
How do I make the program actually restart, either by quickly closing and reopening the program, or by getting it back to the question that asks for user’s answer?
In an example program, make it go back to the proper question of restarting or closing, or in a larger program, make it go back to the first question that requires the user to type something.
In Small Basic, what would be the best class and method for what I’m talking about?
Here is the current program I have in hand:
TextWindow.WriteLine("Programa para fechar e recomeçar")
TextWindow.WriteLine("")
Sub ReiniciarOuFecharPrograma
inicio:
If resposta = "reiniciar" Then
Goto inicio
ElseIf resposta = "fechar" Then
Program.End()
EndIf
EndSub
inicio = Program.GetArgument(20)
TextWindow.WriteLine("Escreva 'fechar' para sair.")
TextWindow.WriteLine("Escreva 'reiniciar' para recomeçar o programa.")
TextWindow.WriteLine("")
TextWindow.WriteLine("Você quer fechar/reiniciar?")
TextWindow.WriteLine("")
resposta = TextWindow.Read()
ReiniciarOuFecharPrograma()
The class and method Program.GetArgument()
wouldn’t be the right ones with what I want to do, right? They’re interacting with line 20 resposta = TextWindow.Read()
.
Ah, thank you so much for the answer, bigown! I had an idea that it would be better to wear a bow tie
While
, but had no idea how to implement it and because of that I usedGoto
. And I also thought thatProgram.GetArgument(20)
was what I wanted, but was proved wrong :)– user44182
But, if I want the program to close and reopen quickly if I type "restart", with the program coming back as open for the first time, what would be the steps to get to that restart method?
– user44182
I don’t know a way to do this and I don’t even know if it makes sense to do it.
– Maniero
Just to have a beautiful design, so the console screen does not get full of phrases.
– user44182
Clear the screen then, closing and starting again will be worse
TextWindow.Clear()
– Maniero
Putz, I had no idea! Thank you again!
– user44182