Bill Allombert on Thu, 25 May 2017 23:50:26 +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", 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: "" 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.

  print("part 1");
  print("part 2");
  print("part 3");