2014年8月7日 星期四

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

應該是在1987年的時候吧!
算起來,也有27年的時間了!
********************
輸入密碼的程式(範例)
Source : 1987/5/21
Author : John Lin
Complier : Clipper '87

*
* strno 是要求出今天是奇數日?或是偶數日?
*
* 例如, 05/21/87 是奇數日
* 21 % 2 =1
* 1+1=2
* strno = 2
* times[strno]=times[2]="hElLo"
* 所以,應鍵入 hElLo
*


Function password

clear
strno=val(substr(dtoc(date(), 4, 2) % 2+1
@ 7, 0 say " Times : "
@ 9, 0 say " Input Password : "

declare times[5]
times[1]="HeLlO"
times[2]="hElLo"
times[3]="1"
times[4]="2"
times[5]="3"
count=1
count1=1

do while count < 4
   @ 7, 10 say times[2+count1]
   @ 9, 19 say " "
   count2=1
   point=20
   waited=0
   answer=""
   do while count2 < 9
        waited=inkey()
        if waited=13
           count2 = 9
        else
             if waited <> 0
                if (count2 %2) = 1
                    @ 9, point say "*"
                else
                    @ 9, point say "|"
                endif
                point = point +1
                count2 = count2 + 1
                answer=answer+chr(waited)
            endif
         endif
   enddo
@ 9, 19 clear to 9, 50
set exact on
   if answer = times[strno]
      return(.T.)
   else
      count1 = count1 + 1
      count = count + 1
   endif
enddo

return (.f.)

沒有留言:

張貼留言