Print Debug Messages Before and After Running Code
Arguments
- messageText
text to be printed before running the code
- expr
expressions to be run. Enclose more than one expression in curly braces
- newLine
integer controlling new lines. 0: no extra new line, 1: new line after
messageText, 2: new line after "ok.", 3: new line after both,messageTextand "ok."- dbg
logical. If
FALSE, output is suppressed.- log_time
logical. If
TRUE, the time elapsed during the evaluation ofexpris printed.
Value
This function returns the evaluation of expr. The result is
returned invisibly so that the result of an assignment as the last
expression in exprt does not show up on the console.
Examples
for (newLine in 0:3) {
catAndRun("work hard", newLine = newLine, {
cat("hard\nworking\n")
})
cat("here.\n\n")
}
#> work hard ... hard
#> working
#> ok. (0.00 secs) here.
#>
#> work hard ...
#> hard
#> working
#> ok. (0.00 secs) here.
#>
#> work hard ... hard
#> working
#> ok. (0.00 secs)
#> here.
#>
#> work hard ...
#> hard
#> working
#> ok. (0.00 secs)
#> here.
#>