cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Better than "return" — debugging function for ridiculously long programs

SPauliszyn
11-Garnet

Better than "return" — debugging function for ridiculously long programs

I made a couple simple functions that I would like to share that helps with debugging of long Mathcad Prime (circa v9)  programs.  (file attached)

 

SPauliszyn_0-1695737701917.png

I was making a VERY LONG convoluted program that called several sub-functions (in order to split it up).  But it still had bugs by the time it was fully grown (don't we all;).

 

I made this function so that I could locate the errors before it happened.  It is basically a logger that lets the program continue.  It is better than a "return" statement in a few ways:

 

  • Since there is no 'remarks' statement in programing, this can also be a substitute—they do not need to be removed (except for speeding up long iteration functions).
  • You do not have to delete the "debug" functions in order to keep the program running and running to a proper conclusion whereas "return" statement must be added/removed every time it is needed.
  • "debug" functions do not screw up the output if it is in a sub-function
  • You can display the debug data wherever you need in your sheet, also as a confirmation that your function is working fine

Notes:

  • if you have "Auto Calculation" on, press F9 to make sure debug("") is refreshed.  The debug function does not dependant on your program so Mathcad will not refresh its output automatically.
  • When Mathcad Prime adds a function to delete a file, a command debug("delete") can be added.  Otherwise the file is saved in the same folder as the sheet it's in.

 

 

 

 

P.S.  Please forgive me if there is another post like this but there are lots to search though and I am not sure I used the right keywords.  There are a few posts about writing data to file but this is a complete function you can cut and paste into your sheet (or include).

0 REPLIES 0
Top Tags