clear
set talk off
set safe off
set conf on
store space(10) to pass_word
set colo to /n
@3,5 say 'Enter Password :' get pass_word size 1,10
read
set colo to
Alternatively, to allow the user to enter a password but
have the keys typed when entering the password show up as
asterisks on the screen try the following piece of code.
FUNCTION PASSWORD
PARAMETER Y_COORD, X_COORD, M.WIDTH, M.COLOUR
PRIVATE M.EXIT, M.ENTRY, M.KEY
STORE IIF(EMPTY(M.WIDTH),16,M.WIDTH) TO M.WIDTH
STORE IIF(EMPTY(M.COLOUR),'w+/n',M.COLOUR) TO M.COLOUR
STORE '' TO M.ENTRY
STORE .F. TO EXIT
DO WHILE .NOT. M.EXIT
@ Y_COORD, X_COORD SAY SPACE(M.WIDTH) COLOR (M.COLOUR)
@ Y_COORD, X_COORD SAY REPLICATE('*',LEN(M.ENTRY)) COLOR (M.COLOUR)
M.KEY = INKEY(0)
DO CASE
CASE M.KEY=27
STORE '' TO M.ENTRY
STORE .T. TO M.EXIT
CASE M.KEY=13
STORE .T. TO M.EXIT
CASE M.KEY=127 .AND. LEN(M.ENTRY)>0
M.ENTRY = LEFT(M.ENTRY,LEN(M.ENTRY)-1)
CASE M.KEY>=48 .AND. LEN(M.ENTRY)<M.WIDTH
M.ENTRY = M.ENTRY+CHR(M.KEY)
OTHERWISE
? CHR(7)
ENDCASE
ENDDO
RETURN M.ENTRY
Put the above code into a dummy program and precede the
function call with:-
mypassword = password(10,10)
The password entered on screen will show as asterisks but
the value of mypassword will show as what was entered.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.