Chewett 4,943 Report post Posted October 28, 2009 (edited) Debugging Your Code Debugging is not some weird activity programmers do...well it is but if you want to do interesting things with MDScript you have to know about it. Seeing what is inside the variables you are working with is very important to understand what you should do with them next. Simple variables are easy to check, you just output them and see what value they have: print @va; (i usualy use 'echo' instead of 'print' , they do same thing, but print sounds easier to remember) Best practice is to put some other value next to the one you are looking for, so that if the variable is empty, you will see that and not just an empty page not knowing if it was output or not. print "V=".@va; This will output V=something or V= if @va has no value. Better than nothing at all. Arrays are harder to debug by just using simple output. Multidimensional arrays are even worse. Fortunately there are functions to help you see exactly what is inside a variable. Debug Function: debug(variable,label); Parameters: variable = any kind of variable simple or multidimensional array with or wihout data label = a label to help you identify the debug output, optional (means you can use just the variable parameter) debug(@va); This will be your best friend when trying to understand what data you have in all those variables. It will generate a nice colored box with all the details you need about the internal structure of the variable you are trying to analyze Edited September 2, 2016 by Chewett Cleaned it all up :) Quote Share this post Link to post Share on other sites
Rophs 289 Report post Posted December 9, 2015 (edited) Debug Function: [php]mds_debug(variable,label);[/php] The function is actually [php]debug(variable,label);[/php] Example code and output: [php] @va = array (1,2,3,4,5); debug(@va,"numbers"); [/php] Edited December 9, 2015 by Rophs Quote Share this post Link to post Share on other sites
Chewett 4,943 Report post Posted December 9, 2015 Thanks for that rophs :) Quote Share this post Link to post Share on other sites
Chewett 4,943 Report post Posted September 2, 2016 Cleaned up this post 1 Ivorak reacted to this Quote Share this post Link to post Share on other sites