PDA

View Full Version : Is there any debugger for MIVA?


volod
06-13-06, 01:35 PM
Hello.
Is there any debugger for MIVA code?
I miss it. Really!
Thank you.
Vladimir.

mvmarkus
06-13-06, 01:50 PM
Hi Vladimir,

What do you expect such a debugger to do? I mean, most (if not all) syntax errors are caught by the compiler, and you never have to worry about memory issues (leaks, overflows etc.). Invalid array-indices are probably the most "dangerous" problems that you can run into, and even a debugger will not prevent those - only proper coding and testing.

Actually, I think that one of the greatest strength of Mivascript is that it is such a safe language.

But maybe I missed something?

Markus

volod
06-13-06, 04:01 PM
script workflow requires debugging.
I've got a website on miva. It has a really strange structure and bugs.
Other languages are also stable, but also have dubuggers 'cause the problem is not in language, but in software that you develop. It is always good to know what and why is happening wrong in your code.

mvmarkus
06-13-06, 06:50 PM
Hello Vladimir,

One good way to handle this is to add conditional debugging instructions into the code that can be compiled depending on special flags. In that case, these tests appear only at debugging time, but not in a finalized version. You won't find this in the manual, but in the readme file of Empresa/compiler 5.x.

Another way, which I use, is to collect the output of the script in a variable and wrap the entire script into MvCAPTURE. Once the script has been executed, I display the variable (basically the result of the script), and all debugging instructions that you have inside your code will then be displayed when you show the result from the MvCAPTURE. I am sure that I explain this pretty badly, sorry for that. The neat thing is that you display the page first, and underneath the debugging info, which you can turn on or off (display the MvCAPTURE or not display it).

Only drawback of this approach is that you can't use MvEXIT anymore, because it'll clear the capture and display nothing at all. Also, this is really only practical when you write the script from scratch, because it is quite tedious to rewrite the functions in a way where the output is always collected.

BTW: When I wrote that Miva is a SAFE language, I didn't mean "stable". Safe really means what it says, that it is actually pretty difficult to write a Mivascript that could "hurt" or endanger your server (unlike languages that have more low-level capabilities).

Markus

volod
06-13-06, 07:28 PM
That is interesting.
How do I turn MvCAPTURE on and off?

mvmarkus
06-13-06, 08:54 PM
Very simple:



MvIF g.capture
MvCAPTURE VARIABLE="l.xyz"
/MvIF


function()
function()
function()

MvIF g.capture
/MvCAPTURE
/MvIF



And then, to display it:

MvIF g.capture
MvEVAL="{l.xyz}">
/MvIF


So simply by setting the variable g.capture = 1 to activate it. No magic tricks here.

Markus