Console program

Does anyone know if it is possible to create text-based program where a user interacts with the console at the bottom of the screen?

One of my students saw that they could put text into the console, but can’t figure out how to read what is being put into that console. I suggested using the “prompt” command but it seems like it should be possible to do directly from the console. I’ve done some googling on the subject but cannot seem to figure it out.

Ideas @jkeays @hwalden @frank_w_lee???

KT

1 Like

@kaitie_o_bryan It is possible to do it. Although I haven’t tried in the AppLab environment. You are correct about using prompt. The program will then accept the input from the variable provide a result based on the entry. Example to follow soon.

2 Likes

@kaitie_o_bryan I think I’d encourage them to make their own simulated “console box” at the bottom of their screen using a combination of prompt and the text element.

2 Likes

Code: https://studio.code.org/projects/applab/Wb0ePU_lRgYlA4DW5TBiqw

Sorry, all I could find was about the “prompt” command, used like so:


var x = prompt(“How old are you?”);
if (x > 150) {
console.log(“dang, u is old”);
}

@kaitie_o_bryan
create a short named function that takes in the message.
like inCon for inConsole
This would work, perhaps remove the eval stuff at the bottom though.

1 Like

I was having this same thought. “prompt” works, but doesn’t leave a breadtrail of what the user has done as they interact with the program, unless the interactions are explicitly output again using console.log or text.

I also feel like prompt is kind of invasive with the big window popping up.

I understand that if there is an option to interact directly with the console that the project won’t be able to be shared since there is no console on the share page, but it would be nice to have.

So… is there an option other than prompt?

@mradl3r are you looking to get text in general from a user? If so, a UI element for “Text Inputs” would certainly work. Or are you looking for something else?