2014年8月8日 星期五

老程式02-輸入密碼的程式(在DOS、Clipper時代)

* Program : bankpswd.prg
* Author : John Lin
* Source : 1994.5.10
* Compiler : dBFast for Windows v2.0

set procedure to bankpswd
restore from config.mem additive
acceptAt( 5, 10, "Please input password or ESC to Exit:→")

Function acceptAt
parameters row, col, prompt
private char, string
store "" to char, string
@ row, col say prompt
do while .t.
   char=inkey(0)
   do case
   case char = 13   && Return key
          loop
   case char = 27   && ESC key
          exit
   case char > 31 .and. char <127   && Printable characters
          string = string + chr(char)
          @ 5, col() say "*"
   case (char = 8 .or. char =19) .and. len(string) > 0   && Backspace or Leftarrow keys
          @ row(), col() - 1 say " "
          @ row(), col() - 1 say ""
          string = substr(string, 1, len(string) - 1)
   endcase
   if string = alltgrim(pWORD1)
      clear
      @ 10, 30 say "Checking now..."
      do bankmenu
      clear
      exit
   elseif .not. string $ alltrim(pWORD1)
      tone(1000, 5)
      warning("Wrong password!!!", 3)
      exit
   endif
enddo
return ""

沒有留言:

張貼留言