Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Link on August 30, 2012, 02:03:54 pm

Title: Finished my first project! And it doesn't work mostly. :'C
Post by: Link on August 30, 2012, 02:03:54 pm
Well, I created my first Axe project program, Its a port of a Ti-Basic program, and it doesn't seem to work, even though I check everything. Asked for help in some other threads, as well as referencing the docs.

It's a locking mechanism, but whenever I try to use it, Ram just gets cleared. Is there anything else that I seem to be missing?

Lock Mechanism
Code: [Select]
:.CALCLOCK
:ClrHome
:GetCalc("appvTEMP")→T
:If T
:GetCalc("appvTEMP",100)→T
:End
:GetCalc("appvPASS",100)→P
:Disp "CALCLOCK3 By M.A"
:Output(7,1,"{-}{-}")
:Output(6,2,"!  !")
:Output(6,3,"{-}{-}{-}{-}")
:Output(6,4,"!{box} !")
:Output(6,5,"{-}{-}{-}{-}")
:Output(6,6,"Pass")
:For(B,1,4)
:Repeat K
:getKey→K
:End
:K→{B+T}
:Output(5+B,7,"*")
:0→K
:End
:For(B,1,4)
:If {B+T}≠{B+P}
:Asm(FDCB1696)
:Return
:End:End
:DelVar B
:DelVar K

Password changing utility
Code: [Select]
:.PASSUTIL
:ClrHome
:GetCalc("appvPASS",100)→P
:Disp "PASSUTIL3 By M.A"
:Disp "PASS?:"
:For(B,1,4)
:Repeat K
:getKey→K
:End
:K→{B+P}
:Output(6+B,1,"*")
:0→K
:End
:Disp "PASS CHANGED!"
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Deep Toaster on August 30, 2012, 02:25:14 pm
I haven't read through all your code, but here are some things I noticed:
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Link on August 30, 2012, 02:32:35 pm
No, it's not backwards, that's how I meant to do it.Thanks for the string trick, I'll do that now. Finally, Yea, I meant !If T instead :p.
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Hayleia on August 30, 2012, 02:38:04 pm
You seem to have the parameters for Output( backwards (like in TI-BASIC). In Axe it's X, then Y. You'll probably end up writing outside the screen, which corrupts RAM.
And note that in Basic coordinates are between (1,1) and (16,8) while in Axe it is between (0,0) and (15,7). But it seems fine in your program :)

Also, I guess the TEMP appvar is a temp appvar ? :P
Which means that you don't need it to be saved after you ran your prog and you don't need to have it at the launching of your program ?
If so, I'd advise you to use a DelVar "appvTEMP" (or DelVar Str1 is you use Deep Thought's tip) at the beginning and at the end of your program.
This way:
 - the appv is deleted after the program ran and doesn't waste any RAM
 - the appv is deleted at the beginning of the program so you don't need to check if it already exists: you deleted it.
(note that DelVar deletes the appvar if it exists and does nothing otherwise ;))
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Deep Toaster on August 30, 2012, 02:39:57 pm
- the appv is deleted at the beginning of the program so you don't need to check if it already exists: you deleted it.
You don't need to delete it anyway because GetCalc( will automatically delete the appvar if it exists.
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Hayleia on August 30, 2012, 02:42:23 pm
- the appv is deleted at the beginning of the program so you don't need to check if it already exists: you deleted it.
You don't need to delete it anyway because GetCalc( will automatically delete the appvar if it exists.
O.O I didn't know that. I thought it could try to create a second appvar and cause some corruption :P
So the beginning should just be GetCalc("appvTEMP",100)→T without deleting anything and without checking if it already exists ?
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Deep Toaster on August 30, 2012, 02:43:44 pm
Yep.

I didn't realize appvTEMP was supposed to be a temporary appvar <_<

EDIT: Why do you need a temporary appvar at all? You could just create a buffer in the program itself, with Buff(100)→Str0 or something similar. That way you won't have problems if there's not enough RAM to create the appvar, and you don't have to worry about creating it and deleting it and stuff.

EDIT2: Ninja'd by a Runerpost.
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Runer112 on August 30, 2012, 02:43:54 pm
A few notes about the locking program:

Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Hayleia on August 30, 2012, 02:48:55 pm
Also, when the program arrives here, in the for loop:
  :Repeat K
  :getKey→K
  :End
I don't see where you initialized K to 0 so it is probably not at 0 and all this is skipped.
You may need to do this
  :0→K
  :Repeat K
  :getKey→K
  :End
Or more optimized:
  :0
  :Repeat
  :getKey
  :End
  :→K
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Deep Toaster on August 30, 2012, 02:51:49 pm
Or more optimized:
:While 1
:EndIf getKey
:→K
EDIT: IRC ninja'd :P
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Link on August 30, 2012, 03:22:30 pm
Thanks guys, but I have a problem, when I create the pass appvar, it isn't actually being created?
This code should create an appvar called PASS, but it doesn't? Whats wrong?

Pass:
Code: [Select]
:.PASSUTIL
:ClrHome
:GetCalc("appvPASS",100)→P
:Disp "PASSUTIL3 By M.A"
:Disp "PASS?:"
:For(B,1,4)
:0
:Repeat
:getKey
:End
:→K
:K→{B+P}
:Output(6+B,1,"*")
:End
:ClrHome
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Link on August 30, 2012, 10:25:27 pm
Also, when my appvar is being created, it isn't.

I did this:
Code: [Select]
:GetCalc("appvPASS",100)→P
:Disp P>Dec
It returns 41111, but when I check for the appvar in the memory menu, it isn't there? Whats wrong?
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Runer112 on August 30, 2012, 10:30:03 pm
You are checking in the appvar section of the memory management menu, correct? And you are sure that you are using the actual "appv" token (2nd + 8), not just spelling it out?
Title: Re: Finished my first project! And it doesn't work mostly. :'C
Post by: Link on August 31, 2012, 10:21:34 am
Hmm, that might actually be the problem. I'll check, thank you!
Edit:Yup! That was it, it works now thanks!