Author Topic: Finished my first project! And it doesn't work mostly. :'C  (Read 6391 times)

0 Members and 3 Guests are viewing this topic.

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Finished my first project! And it doesn't work mostly. :'C
« 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!"
« Last Edit: August 30, 2012, 02:04:27 pm by The Elite Noob »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #1 on: August 30, 2012, 02:25:14 pm »
I haven't read through all your code, but here are some things I noticed:
  • 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.
  • I don't think you meant to do this:
    Quote from: Axe
    :GetCalc("appvTEMP")T
    :If T
    :GetCalc("appvTEMP",100)T
    :End
    You're checking if the appvar exists, and if it exists you overwrite it with a new appvar. Did you mean to use !If T?
  • Since you use the string "appvTEMP" twice, you can save a few bytes by storing it to a static variable (like Str1) and using that instead. That way, there's only one copy of the string in the program data, rather than two. ("appvTEMP"→Str1:GetCalc(Str1) is exactly the same as GetCalc("appvTEMP"), except that you can reuse Str1 in another line.)




Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #2 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.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #3 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 ;))
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #4 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.




Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #5 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 ?
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #6 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.
« Last Edit: August 30, 2012, 02:46:40 pm by Deep Thought »




Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #7 on: August 30, 2012, 02:43:54 pm »
A few notes about the locking program:

  • Since it looks like you're just using appvTEMP for 4 bytes of temporary storage, you don't really need an appvar for it at all. You could read the password the user enters into any 4-byte section of static RAM, like L1. To clarify a little bit, "static RAM" is RAM that is always allocated for certain things. Many static RAM location do no hold essential data during assembly program execution, so you can use them as temporary storage without having to request dynamically-allocated storage in user memory.
  • Get rid of the two DelVar commands that you have at the end of the program. In Axe, the A-theta variables are assigned to a section of static RAM, so there's no need to delete them when your program ends because they aren't real variables that consume user memory. Also, DelVar expects the argument passed to it to be a string containing the name of the variable to be deleted, not an actual variable token. I wouldn't be surprised if this is what's causing the RAM clear.
« Last Edit: August 30, 2012, 02:49:29 pm by Runer112 »

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #8 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
« Last Edit: August 30, 2012, 02:49:22 pm by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #9 on: August 30, 2012, 02:51:49 pm »
Or more optimized:
:While 1
:EndIf getKey
:→K
EDIT: IRC ninja'd :P
« Last Edit: August 30, 2012, 02:52:25 pm by Deep Thought »




Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #10 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
« Last Edit: August 30, 2012, 07:01:51 pm by Link »

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #11 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?

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #12 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?
« Last Edit: August 30, 2012, 10:56:31 pm by Runer112 »

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: Finished my first project! And it doesn't work mostly. :'C
« Reply #13 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!
« Last Edit: August 31, 2012, 12:04:02 pm by Link »