Hi, I was writing a ti-basic password protection system,
and every-time i input anything, weather right or wrong, it
shutdowns the program. whereas when i type in the correct pass
the keys xkcd it should show me a welcome screen

Code:

:ClrHome:Disp "CalcLock! By M.A"
:0:Asm(prgmONBLOCK
:Disp "       --"
:Disp "      !  !"
:Disp "      ----"
:Disp "      !{box} !"
:Disp "      ----"
:Disp "      Pass"
:For(A,1,4)
:Repeat Ans
:getKey
:End
:Ans→K
:K→∟KEY2(A)
:Output(8,6+A,"*"
:End
:{91,63,43,51}→∟BACK
:If dim(∟KEY2)=dim(∟BACK
:Then
:If min(∟KEY2≠∟BACK
:Goto W
:End
:If min(∟KEY2≠∟KEY):Then
:Goto W
:Else
:Goto S
:End
:Lbl S:ClrHome
:Disp "Welcome!":Disp "Max":Disp ""
:Goto U
:
:Lbl W:ClrHome
:DelVar A
:DelVar B
:DelVar K
:DelVar ∟BACK
:1:Asm(prgmONBLOCK
:Asm(prgmCALCOFF
:Stop:End
:
:Lbl U
:DelVar A
:DelVar B
:DelVar K
:DelVar ∟BACK
:1:Asm(prgmONBLOCK
:Asm(prgmDISDONE
:Stop:End


I really don't want it optimized, just want to know what the error is.
please and thank you!
For starters, you really shouldn't be Goto'ing inside a If-Then statement, or even using labels at all. That said, have you made sure that LBACK is equal to LKEY?
Yes, I have, also, i like Gotos they make it simpler and easier
i know i shouldn't but w/e.
Also LKEY is currently equal to 92,92,92,92, and if i type in 1111 the
thing shuts-down, whereas 1111, is the correct pass.
Nvm i got it fixed! Thanks for the help. Just needed to restructure it a bit.
If you type in "1111", it will shutdown because of the following code:

Code:
:If dim(∟KEY2)=dim(∟BACK
:Then
:If min(∟KEY2≠∟BACK
:Goto W
:End

LBACK contains the keycodes for "xkcd", so if you type "1111" the program will jump to label W and turn off you calculator.

Edit: Oh, you got it fixed. In the future, please avoid double posting, use the Edit button instead.
Sorry, but I'm going to be a bit of a Grammar police for a sec:

Yes, I have. Also, I like Gotos. They make it simpler and easier. I know I shouldn't, but w/e. Also, LKEY is currently equal to {92,92,92,92}, and if I type in 1111, the thing shuts down, whereas 1111 is the correct pass.

Though Goto's might seem easier, they make programs messier, and the calc has to search the entire program for the label everytime it sees a goto. You can almost ALWAYS make better code using loops and If's, etc. (versus just plopping random chunks of code in where-ever they fit and jumping to them, which is what gotos are)

But sorry, you came here for help with your problem ... I'd help if I could, but I am not familiar with the ASM programs you are using in there. However, I'll bet that it's either something about how you are using the ASM programs, or it has something to do with your labels and gotos. One wrong placement can cause all kinds of issues; but the calc will tell you if you misuse other constructs (and other people will be able to look at your code and help you without having to draw a map). But I applaud your efforts; this looks like an awesome program idea Smile Smile
souvik1997 wrote:
If you type in "1111", it will shutdown because of the following code:

Code:
:If dim(∟KEY2)=dim(∟BACK
:Then
:If min(∟KEY2≠∟BACK
:Goto W
:End

LBACK contains the keycodes for "xkcd", so if you type "1111" the program will jump to label W and turn off you calculator.

Edit: Oh, you got it fixed. In the future, please avoid double posting, use the Edit button instead.


Sure thing, Just coudn't find it >.< normally it's at the top right on most forums :p
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement