Password masking and tabbing in v9.1d

dayv2005

Member
First off i was wondering if there was and easier way of masking the password fields on a login screen in version 9.1d i know there is for newer versions but not sure about our current version.

This is how we did it on a trigger

Code:
DO.
    CASE KEYFUNCTION(LASTKEY):
    
    WHEN "DELETE-CHARACTER" THEN 
        DO:
            /* Remove last char from password and last "*" from fill-in. */
            IF LENGTH(pword) > 0 THEN 
                DO:
                    pword = SUBSTRING(pword,1,(LENGTH(pword) - 1)).
                    pwd:SCREEN-VALUE =
                    SUBSTRING(pwd:SCREEN-VALUE,1,
                    LENGTH(pwd:SCREEN-VALUE) - 1).
                    pwd:CURSOR-OFFSET = LENGTH(pwd:SCREEN-VALUE) + 1.
                    RETURN NO-APPLY.
                END.
        END.

WHEN "BACKSPACE" THEN 
    DO:
        /* Remove last char from password and last "*" from fill-in. */
        IF LENGTH(pword) > 0 THEN 
            DO:
                pword = SUBSTRING(pword,1,(LENGTH(pword) - 1)).
                pwd:SCREEN-VALUE =
                SUBSTRING(pwd:SCREEN-VALUE,1,
                LENGTH(pwd:SCREEN-VALUE) - 1).
                pwd:CURSOR-OFFSET = LENGTH(pwd:SCREEN-VALUE) + 1.
                RETURN NO-APPLY.
            END.
     END.
WHEN "RETURN" THEN DO:
/* User believes password is correct -- validate password. */
APPLY "entry" TO button-ok.
/* Your validation code here. */

RETURN NO-APPLY.
END.

WHEN "TAB" THEN DO:
/* User believes password is correct -- validate password. */

/* Your validation code here. */

RETURN NO-APPLY.
END.

WHEN "END-ERROR" THEN DO:

/* END-ERROR */
RETURN NO-APPLY.
END.

OTHERWISE DO:
/* check for printable character */
IF KEYCODE(KEYFUNCTION(LASTKEY)) > 0 AND
KEYCODE(KEYFUNCTION(LASTKEY)) < 200
THEN DO:
/* Build password from input & display "*" in fill-in. */
pword = pword + KEYFUNCTION(LASTKEY).
pwd:SCREEN-VALUE = pwd:SCREEN-VALUE + "*".
pwd:CURSOR-OFFSET = LENGTH(pwd:SCREEN-VALUE) + 1.
/* pwd:CURSOR-OFFSET = pwd:CURSOR-OFFSET + 2.  */
RETURN NO-APPLY.

END.
ELSE RETURN NO-APPLY. /* ignore non-printables */
END.

END CASE.

END.
Also we are having trouble when it wont let you tab out of the password field is there any way to fix that?
 

longhair

Member
dayv2005,
i'll have a closer look at your code tomorrow for you second issue but as far as the first rather than putting "*" in the field why something like:
do while a <> b:
update b blank with frame f-1.
end.
where you have already populated a with the correct password that you retrieved when they put their ID in?
this way they cannot leave the frame until the password is correct.
regards,
longhair
 

wilcoNL

New Member
Using windows API will work also. When setting the field as a password field, you can set the 'blank' character to whatever you want.
 

dayv2005

Member
Using windows API will work also. When setting the field as a password field, you can set the 'blank' character to whatever you want.

Are you able to do this in V9.1d? I know you can in OE10 if so how

here's an img

pic11111.jpg
 

sphipp

Member
Using Character, we use something like the following (Yes, I know it uses the soon-to-be-obselete editing phrase):

def var this_password as char.

run p_password (input "#",output this_password).
message this_password view-as alert-box.

procedure p_password:
def input param inp_mask as char no-undo.
def output param out_password as char no-undo.

def var validchars as char no-undo.
def var backcursor as char initial "backspace,delete-character" no-undo.
def var this_loop as int no-undo.
def var endchars as char initial "go,return" no-undo.
def var pass1 as char.

form pass1 label "Password" with frame fr_password side-labels 1 down.
validchars = " qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890".

update pass1 with frame fr_password editing:
readkey.
if lookup (keyfunc(lastkey),backcursor) > 0 then
if out_password <> "" then
out_password = substring (out_password,1, length (out_password) - 1).
if keyfunc(lastkey) = "clear" then out_password = "".
if index (validchars,chr(lastkey)) > 0 then
out_password = out_password + chr(lastkey).
pass1 = fill (inp_mask,length (out_password)).
display pass1 with frame fr_password.
if lookup (keyfunc(lastkey),backcursor) > 0 then
apply "cursor-left".
else
apply "cursor-right".
if keyfunc(lastkey) = "end-error" then do:
out_password = "".
apply "go".
end.
if lookup (keyfunc (lastkey), endchars) > 0 then apply "go".
end.
hide frame fr_password no-pause.

end procedure.
 
Top