Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture clause for password 1

Status
Not open for further replies.

HarryB

Programmer
Sep 2, 2000
11
US
Is there a way to display an asterisk (*) instead of the keyed character in a password field?

TIA,

Harry
 
After a person enters a user ID, I use a function to handle entering passwords.

Try this...

@ 5, 7 say 'Enter ID:' ;
get User_ID ;
picture '@!'

read
if ( lastkey() != K_ESC )
@ 7, 7 say 'Password:'
get_pswd( 7, 17, PassWord, '*' )
endif


You can change the last parameter to whatever character you wish to display instead of letters of the password.


function get_pswd ( therow, thecol, thepass, character )
local maxlen := len( thepass ) ,;
thelength := 1 ,;
thepos := 0 ,;
thenew, thekey

@ therow, thecol say NULL
thecol--
setcursor( SC_BLOCK )

do while ( TRUE )

if ( ( thekey := inkey( 0 ) ) == K_ENTER OR ;
thekey == K_ESC OR ;
thekey == K_UP )
exit

elseif ( thekey == K_DELETE ) // delete
if ( thelength > thepos )
loop
endif
@ therow, thecol + thepos say ' '
thenew := len( thepass ) - thelength + 1
thepass := stuff( thepass, thelength, thenew, right( thepass, thenew - 1 ) + ' ')
thepos--

elseif ( thekey == BACKSPACE ) // backspace
if ( thelength == 1 )
loop
endif
@ therow, thecol + thepos say ' '
thenew := len( thepass ) - thelength + 2
thepass := stuff( thepass, --thelength, thenew, right( thepass, thenew - 1 ) + ' ' )
thepos--

elseif ( thekey == K_RIGHT )
if ( thelength = maxlen OR thelength > thepos )
loop
else
thelength++
endif

elseif ( thekey == LEFTARROW ) // left artherow
if ( thelength == 1 )
loop
else
thelength--
endif

elseif ( thekey < 32 OR thekey > 126 ) // invalid entry
badbeep()
loop

else
@ therow, thecol + thelength say character
if ( thelength > thepos )
thepos := thelength
endif
thepass := stuff( thepass, thelength, 1, chr( thekey ) )
if ( thelength == 12 )
exit
endif
thelength++

endif

@ therow, thecol + thelength say NULL

enddo

thepass := upper( thepass )

return ( TRUE )
 
o esto puede Funcionar: ( this can function )Function



Function PassWord(cClave)
Local aMsg
Local cPass,cCar,oCursor
Local j,i,y,x,bRet := FALSO

aMsg := MsgBox( &quot;Entre Clave&quot;,&quot;Digite su Clave Por Favor&quot; )
oCursor := SetCursor(SC_SPECIAL1)
For i := 1 to 3
@ 12,33 Say &quot;[**********]&quot; Color &quot;N/W*&quot;
cPass := Space(10)
For j := 1 to 10
SetPos(12,33+j)
cCar := Inkey(0)
IF cCar == K_ENTER .or. cCar == K_ESC
Exit
Else
@ 12,33+j Say Chr(254) Color &quot;B/W*&quot;
cPass -= IF( cCar == 32,&quot;-&quot;,Chr(cCar) )
End
Next
If cCar == K_ESC
Exit
End
IF Upper( AllTrim(cPass) ) == Upper( cClave )
bRet := VERDAD ; Exit
End
Next

SetCursor(oCursor)

If bRet == FALSO
@ 12,30 Say &quot;..Clave Incorrecta..&quot; Color &quot;R/W*&quot;
Inkey(0)
End
RstEnv( aMsg )
Return( bRet )


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top