Simulate the BASIC INPUT command

[Autolink] Menu

 
/* example for simulating the input command used in BASIC             */

                        /* example call ...                           */
  thisString = input( "Enter a string: " )
  say "You entered '" || thisString || "'."

exit

/* ------------------------------------------------------------------ */
/* function: Simulate the BASIC command INPUT                         */
/*                                                                    */
/* call:     input( prompt )                                          */
/*                                                                    */
/* where:    prompt - prompt for the input                            */
/*                                                                    */
/* returns:  entered string                                           */
/*                                                                    */
Input: PROCEDURE
  parse arg prompt

  if prompt = "" then
    prompt = "Your Input:"

                         /* set word wrap off                         */
  call CharOut , "1B"x || "[7l"

                         /* show the prompt string                    */
  call charOut , prompt || " "

                         /* get the user input                        */
  thisRC = lineIn()

                         /* set word wrap on again                    */
  call CharOut , "1B"x || "[7h"

RETURN thisRC


[Back: Input & Output]
[Next: Simple Yes/No question]