home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / grpasswo.prg < prev    next >
Text File  |  1993-10-14  |  3KB  |  118 lines

  1. /*
  2.  * File......: GRPASSWO.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_GRPASSWORD()
  24.  *  $CATEGORY$
  25.  *      General
  26.  *  $ONELINER$
  27.  *      Get reader for password entry
  28.  *  $SYNTAX$
  29.  *      GT_GRPassword( oGet , aGetExitKeys )
  30.  *  $ARGUMENTS$
  31.  *      oGet         - GET object
  32.  *      aGetExitKeys - Array of keys that can cause exit from GET
  33.  *  $RETURNS$
  34.  *      .F.
  35.  *  $DESCRIPTION$
  36.  *      A GET reader for password entry.  Any keys pressed are placed in
  37.  *      cargo and a block character is output to the screen.
  38.  *  $EXAMPLES$
  39.  *
  40.  *  $SEEALSO$
  41.  *
  42.  *  $INCLUDE$
  43.  *      GT_LIB.CH
  44.  *  $END$
  45.  */
  46.  
  47. *
  48. #include "GT_lib.ch"
  49.  
  50. FUNCTION GT_GRPassword( oGet , aGetExitKeys )
  51.  
  52. /*****************************************************************************
  53.  Purpose - Get reader for password entry
  54.  Returns - None
  55.  Author  - Log
  56.  Created - 07/01/93
  57. ******************************************************************************
  58.  Parameters - oGet         - Get object
  59.               aGetExitKeys - Keys that can cause exit from READ
  60.  Privates   - None
  61.  Locals     - nKey         - Key pressed by user
  62. *****************************************************************************/
  63.  
  64. LOCAL nKey := 0
  65.  
  66. * Read the GET if the WHEN condition is satisfied
  67. IF ( GetPreValidate( oGet ) )
  68.  
  69.     // activate the GET for reading
  70.     oGet:SetFocus()
  71.  
  72.     DO WHILE ( oGet:exitState == GE_NOEXIT )
  73.  
  74.         // check for initial typeout (no editable positions)
  75.         IF ( oGet:typeOut )
  76.             oGet:exitState := GE_ENTER
  77.         ENDIF
  78.  
  79.         // apply keystrokes until exit
  80.         DO WHILE ( oGet:exitState == GE_NOEXIT )
  81.             nKey := INKEY( 0 )
  82.  
  83.             DO CASE
  84.                 CASE nKey >= 32 .AND. nKey <= 255
  85.                     oGet:cargo += UPPER( CHR( nKey ) )
  86.                     GetApplyKey( oGet , ASC( "█" ) , aGetExitKeys )
  87.  
  88.                 CASE nKey == K_BS
  89.                     oget:Cargo := LEFT( oget:Cargo , LEN( oget:Cargo ) - 1 )
  90.                     GetApplyKey( oGet , K_BS , aGetExitKeys )
  91.  
  92.                 OTHERWISE
  93.                     GetApplyKey( oGet , nKey , aGetExitKeys )
  94.  
  95.             ENDCASE
  96.  
  97.         ENDDO
  98.  
  99.         // disallow exit if the VALID condition is not satisfied
  100.         IF ( !GetPostValidate( oGet ) )
  101.             oGet:exitState := GE_NOEXIT
  102.         ENDIF
  103.  
  104.     ENDDO
  105.  
  106.     // de-activate the GET
  107.     oGet:KillFocus()
  108.  
  109.     * If the user escaped from the GET, blank the password
  110.     IF oGet:exitState == GE_ESCAPE
  111.         oGet:Cargo := ""
  112.     ENDIF
  113.  
  114. ENDIF
  115.  
  116. RETURN .F.
  117. *
  118.