1. RE: Password prompt routine

coords=get_position()
position(coords[1],coords[2]-1)
puts(1,' ')
position(coords[1],coords[2]-1)

viola, problem solved

and what's wrong with the UNIX way?

new topic     » topic index » view message » categorize

2. RE: Password prompt routine

Here's one...

-----<khkhkjll>-------------

include graphics.e  --for get_position()
include get.e       --for wait_key()

constant BackSpace=8,
         CursorLeft=331,
         EscapeKey=27,
         ReturnKey=13

function getPassword(sequence prompt)
    sequence pos,r
    integer k

    r={}
    puts(1,prompt)
    pos=get_position()

    k=wait_key()
    while not find(k,{EscapeKey,ReturnKey}) do

        if find(k,{CursorLeft,BackSpace}) then --Backspace
            if length(r)>1 then
                r=r[1..length(r)-1]
            else
                r={}
            end if
        else
            r&=k -- Add char to string
        end if

        position(pos[1],pos[2])                 --
        puts(1,repeat('*',length(r))&' ')       --Redraw Display
        position(pos[1],pos[2]+length(r))       --

        k=wait_key()    --get next char
    end while

    if k=ReturnKey then --Return
        return r
    else         --Cancel
        return {}
    end if
end function



puts(1,"\n\n"&getPassword("Enter Password :"))


---------<gikrshg>----------------




Graeme

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu