Author Topic: Debugging Grammer Programs  (Read 1759 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4659
  • Rating: +718/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Debugging Grammer Programs
« on: February 25, 2012, 09:30:15 am »
I have in the past made some large Grammer programs that need to be debugged and a few others have needed to, as well. Because of this, a few months ago I added the solve(3 and solve(4 commands and I made Grammer able to output to OS vars. With these tools, you can make a powerful error catcher and handler.

I, like many, started programming in BASIC and one thing I liked to do when debugging was press ON and do Rcl <<offending var>>. So if I knew the issue was with the value in C, I would do Rcl C. But, Grammer uses its own variables, not OS vars, so you cannot do this! Instead, you can make Grammer copy the var to an OS var before exiting on an error! Here you go:
Code: [Select]
solve(3,Lbl "ERRHANDLE ;initiates the error handler
<<program code>>
.ERRHANDLE    ;label name is ERRHANDLE
→θ'           ;Ans will be initiated with the error code
C→iC          ;Stores C to the OS var C
solve(4,θ'    ;Lets Grammer continue with the regular error
End           ;Not really needed, since solve(4 will exit the parser
If you do not use solve(4, the program will not break. So if your error handler just has an End, the program will not break on its various errors (like on press). I made an example a while ago that brought up its own menu when ON was pressed or there was a memory error. It would give the user an option to exit, goto, or continue. That is an option you don't get in BASIC.