Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does one use "read_int()"? #45

Open
brabalan opened this issue Oct 4, 2013 · 2 comments
Open

How does one use "read_int()"? #45

brabalan opened this issue Oct 4, 2013 · 2 comments

Comments

@brabalan
Copy link

brabalan commented Oct 4, 2013

I have a lab session where the students need to enter some data. Before, we were using "read_int()" for that, but in ocaml_top it seems to hang, waiting for the input.

Is there a way to give some input to a program? Maybe by opening a dialog box?

@AltGr
Copy link
Member

AltGr commented Oct 4, 2013

That's a difficult question.

It would be problematic to allow one to send the input directly to the stdin of ocaml (which is where read_int() reads from), because this is the same channel that is used to send it the source code, and there is no easy way to delimit different kinds of input (ie ocaml-top has no way to know that it's your script reading an int and not the ocaml toplevel). Using different inputs, or a socket, could help, but we want ocaml-top to remain compatible with any external top-level.

So re-defining read_* functions to trigger a different means of input sounds like the way to go ; we already redefine output functions anyway (so that your program's output and ocaml's can be recognized).
I'll see what can be done; opening a dialog box would be nice but requires a GUI lib to be available from the toplevel so that will be difficult to keep portable.

@ghost
Copy link

ghost commented Nov 4, 2016

Hello, basically, in your console, if you type let x = read_int();; , you will be prompted for input. If you enter an integer, then, the value of x will become the value you entered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants