REXX Tips & Tricks, Version 2.80


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Simulate the BASIC INPUT command





 
/* 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

  

Inf-HTML End Run - Successful