Category talk:Wren-debug: Difference between revisions

m
Now uses Wren S/H lexer.
m (→‎Source code: Typos and minor change to program comment.)
m (Now uses Wren S/H lexer.)
 
Line 3:
At present debugging a Wren script consists of strategically placing one or more ''System.print'' statements in your code and examining the output. This tends to be a tedious approach since, if you want to (say) print out the values of two variables and label them, you need to do something like this:
 
<syntaxhighlight lang="ecmascriptwren">var myvar1 = 42
var myvar2 = "forty two"
System.print(["myvar1 = ", myvar, "myvar2 = ", myvar2])</syntaxhighlight>
Line 16:
Now there is ongoing work on creating a debugger for Wren though the current indications are that this is not going to be ready for use any time soon. Whilst there are obvious limitations in what can be done solely from Wren code (as we don't have reflection either), the aim of this module is to try and provide a more structured approach to debugging with the tools we do have. The above code for example could be replaced by this:
 
<syntaxhighlight lang="ecmascriptwren">import "./debug" for Debug
 
var myvar1 = 42
Line 29:
 
Moreover, debugging can be turned off (it would be 'on' by default when you imported the module) or re-enabled using the following simple statements:
<syntaxhighlight lang="ecmascriptwren">import "./debug" for Debug
//....
Debug.off
Line 41:
==Source code==
 
<syntaxhighlight lang="ecmascriptwren">/* Module "debug.wren" */
 
import "./check" for Check
9,476

edits