Jump to content

Debugging Your Code


Chewett

Recommended Posts

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

Link to post
Share on other sites
  • 6 years later...

Archived

This topic is now archived and is closed to further replies.

  • Forum Statistics

    16,149
    Total Topics
    176,430
    Total Posts
  • Recently Browsing

    No registered users viewing this page.

  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...