Invisible entering - secure.prg [01/01] 
Author Message
 Invisible entering - secure.prg [01/01]

This is what I came up with.  Maybe it will help.  It did the job for me.
------------------------------------------------------------------------------
BEGIN -- Cut Here -- cut here
/* PROGRAM HEADER
   Program .............: SECURE.PRG
   Notice ..............: Use freely.  An "Honorable Mention" would be nice!!
   Author(s) ...........: Grant King
   Date Started ........: 6/30/92 (revised 7/23/93)
   Application Name ....: N/A
   Compile .............: Clipper SECURE /n/v/w
   Link ................: N/A
   Version .............: Clipper 5.2
   Purpose .............: UDF to prevent showing on the screen the entering
        of passwords and the like. Instead of showing what was entered, the
        function will show astericks for each key pressed.  If the backspace
        is used, it will backup erasing the asterick. Works better than
        "set console off" because the user can see if maybe he
        "double stroked" a key.  Parameters are Row, Column, Prompt,
        and Variable length.  The function terminates when the variable
        length is reached by input, or when the user presses <Enter>. Returns
        what the user input.  If the user enters nothing, the function
        returns an empty field of spaces the size of Variable.

       USAGE: cPassword := Secure(<Row>,<Column>,<Prompt>,<Size>)
       Example: cPassword := Secure(12, 12, "Enter Password: ", 8)

*/

FUNCTION Secure(nRow,nCol,cPrompt,nSize)

    /* initialize needed locals */
    local cVar := "", nCount := 0, nStart, nKey

    /* Clear screen area and display prompt */


    /* Reset starting column at the "Get" area */
    nCol := nStart := col()

    /* Turn off cursor and console */
    set cursor off
    set console off

    /* Loop through user input */
    do while nCount < nSize
        nKey := inkey(0)                  /* Wait for keystroke */
        if lastkey() <> 8                 /* Check for back space */
            if lastkey() == 13            /* <ENTER> was pressed, all done */
                exit
            endif
            if lastkey() > 31             /* Ignore everything less than <SPACE> */

                nCol ++                   /* Advance one column */
                nCount ++                 /* Increment counter */
                cVar := cVar + chr(nKey)  /* Add key pressed to variable */
            endif
        else                              /* Back space was pressed!! */
            if nCol > nStart              /* See if at beginning of prompt */
                nCol --                   /* Back up one column */

                nCount --                 /* Decrement counter */
                cVar := substr(cVar,1,LEN(cVar) - 1)  /* Remove last character from variable */
            endif
        endif
    enddo

    /* Clean up by setting console and cursor back on */
    set console on
    set cursor on

    /* Return what was input + spaces to the maximum of input */
    Return cVar + SPACE(nSize - len(cVar))

// EOF Secure.prg
END -- Cut Here -- cut here



Tue, 21 Apr 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. WANTED: smalltalk contract prgrmr, 6 months, Toronto, Ontario - contprm [01/01]

2. date 01 01 00

3. Saving Reports to Disk - tfn.clw [01/01]

4. Clarion for DOS 3.1 Release 3.102 - ft02.cla [01/01]

5. Real Classes in Clipper, -prolonged- with English explanation - clpcls.zip [01/01]

6. Real Classes in Clipper, -prolonged- Explanation/Samples - clpcls.zip [01/01]

7. test - topless.gif [01/01]

8. Coroutines for Oberon [01/01] (long)

9. Test for attach - test.gif [01/01]

10. REXX and RxSOCK socket programming - goserv.txt [01/01]

11. $$QUICK MONEY$$ - money.txt [01/01]

 

 
Powered by phpBB® Forum Software