For the Y/N choice, I like this one too:
str = Base.prompt("[Y] / N ? ") in ("","y","Y") ? "Y" : "N"
For the Y/N choice, I like this one too:
str = Base.prompt("[Y] / N ? ") in ("","y","Y") ? "Y" : "N"
As usual, I learned something new and useful from you
Thanks! - This works only in the native Julia REPL, it does not work for me inside VScode
It works for me in both VS Code under Windows 11 and Code - OSS under Manjaro Linux.
import REPL
using REPL.TerminalMenus
menu = RadioMenu(["Yes", "No"]);
choice = request("Say Yes or No. Select via up and down keys:", menu);
@info(string("selection: ", choice))
If I restart Julia and execute via include("question.jl")
it works, but if I start the
code via the command Execute active file in REPL
inside VScode it shows a strange behavior.
(OS Linux, VScode). Nonetheless, thanks for your answer!
I guess that Execute active file in REPL
isn’t intended for interactive scripts.
Meanwhile, I figured out how to determine, if a given script is executed outside VScode, as REPL.TerminalMenus
/ Base.prompt()
does currently do not work inside the VScode-REPL
. Here my idea:
isincli() = isempty(Base.PROGRAM_FILE)