Use ANSI for a password input routine

[Autolink] Menu

 
/* sample input routine for passwords using ANSI sequences to hide    */
/* the input (stolen from a message on a public CompuServe forum)     */
/*                                                                    */

  myPassWord = GetPassword( "Please enter the password: " )

  say "You entered the password: " || myPassword

exit

/* ------------------------------------------------------------------ */
/* function: get a password from the user (without showing it on the  */
/*           screen)                                                  */
/*                                                                    */
/* call:     GetPassword( {prompt} )                                  */
/*                                                                    */
/* where:    prompt - prompt string                                   */
/*                    def.: none                                      */
/*                                                                    */
/* returns:  the entered password                                     */
/*                                                                    */
/* note:     This code only works with ANSI enabled                   */
/*                                                                    */
/*                                                                    */
GetPassword: PROCEDURE
  parse arg prompt

                    /* show the prompt (if any) and set the screen    */
                    /* attributes to notvisible                       */
  call CharOut , prompt || "1B"x || "[8m"

                    /* get the user input                             */
  parse pull password
                    /* reset the screen attributes                    */
  call CharOut , "1B"x || "[0m"

RETURN password


[Back: Using function keys]
[Next: Using the lower right corner of the display]