|Loïc Grenié on Fri, 26 May 2017 08:28:08 +0200|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: Getting my script to wait|
On Wed, May 24, 2017 at 05:58:22PM +0200, Dirk Laurie wrote:
> I'm writing a tutorial in GP that has little sections with a pattern
> of print text, print a Pari-GP _expression_, print its evaluation,
> print a little more text, wait until the reader is ready, go to the
> next section.
> I thought "input()" would wait for the user as it does in an interactive
> session. But no, if I invoke "gp tutorial.gp", it just continues as if the
> user typed an empty line, and the whole tutorial just fast-forwards by.
> I can understand why it does that: "tutorial.gp" becomes standard
> input, and there is nothing of it left.
> I can think of several workarounds, e.g. make a function of the whole
> tutorial which is invoked at the prompt, but also wonder whether I am
> missing something.
You are close tu the solution: make a function of the whole tutorial
and then execute the function as the last line of the script.