[Prev][Next][Index][Thread]

re:A92: Can somebody check this coding




>If somebody could check to see if this coding works I would be much
>abligded.  If it doesn't work could you please tell me what doesn't and
>how to fix it.
>
>- -Phelan 'Amen' Wolf
>
>Here is my coding:
>
>()
>Prgm
>Lbl 0
>ClrHome
>ClrDraw
>PxlText "Password:",1,1
>PxlText "7 8 9",10,20
>PxlText "4 5 6",20,20
>PxlText "1 2 3",30,20
>PxlText "0",40,30
>While 1
>getKey()
>While Ans=0
>getKey()
>EndWhile
>If Ans=48
>Goto 1
>Goto Q
>EndIf
>Lbl 1
>PxlText "#",55,20
>While 1
>getKey()
>While Ans=0
>GetKey()
>EndWhile
>If Ans=49
>Goto 2
>Goto Q
>EndIf
>Lbl 2
>PxlText "##",55,20
>While 1
>getKey()
>While Ans=0
>getKey()
>EndWhile
>If Ans=50
>Goto 3
>Goto Q
>EndIf
>Lbl 3
>PxlText "###",55,20
>PxlText "Password: Accepted...",1,1
>Pause
>ClrHome
>ClrDraw
>Stop
>EndPrgm

You program will not work, for one 'Ans' is not exactly a varible and actually calls the ans(x) of the x'th entry in the history which is replaced on tokenization. To get around this you would need to use expr("ans(x)") with x being which ans you want from the home screen.

Instead I would use this program. It is bloated only because I made it highly extensible, so no nasty comments on your coding sucks. All of the -> are stores just press the [STO] button.

()
Prgm
Local a,b,c
ClrDraw
""->c
PxlText "Password:",1,1
PxlText "7 8 9",10,20
PxlText "4 5 6",20,20
PxlText "1 2 3",30,20
PxlText "0",40,20
While true
0a
While a=0
getKey()->a
EndWhile
If a=13:Exit
If a<48 or a>57 and a‚257:Cycle
If a=257 Then
If dim(c)>0:left(c,dim(c)-1)->c
Else
If dim(c)<3:c&char(a)->c
EndIf
PxlText left("###",dim(c))&right("   ",3-dim(c)),1,55
EndWhile
If ord(c)‚48 or ord(mid(c,2))‚49 or ord(mid(c,3))‚50 Then
ClrDraw:PxlOff 0,0
Stop
EndIf
PxlText "Accepted...",1,55
Pause 
EndPrgm


I only used the ords to stop the casual user for seeing a password string. Feel free to put the string in there, it will save a bit of space. This is currently designed to use three characters of input followed by a return and handles the delete key, you can change the max length by find all the 3's and the two strings of three and make them the max number.

Hope it helps,

Michael Van Der Kolk
mikev@iserv.net
http://www.iserv.net/~mikev
- ---
I pledge allegiance to the Mac of Apple Computer Incorporated, and to the
developers for which it stands, one platform, under Guy, indestructible,
with creativity and multimedia for all.


Follow-Ups: