Print debugging statement: Difference between revisions

no edit summary
m (→‎{{header|Phix}}: added personal tag)
No edit summary
Line 447:
[DEBUG][PrintDebuggingStatement.kt PrintDebuggingStatementKt$main$oops$1.invoke#21] oops
[DEBUG][PrintDebuggingStatement.kt PrintDebuggingStatementKt$main$1.invoke#25] nested</pre>
 
=={{header|Ksh}}==
<lang ksh>
#!/bin/ksh
 
# Print debugging statement
 
# # Variables:
#
typeset -C clr # Colours
clr.lin='�[1;7;33m' # Line number
clr.cmd='�[1;36m' # Command
clr.out='�[1m' # Output
clr.rst='�[0m' # ANSI reset
 
alias D_WRITE='print -u2' # to stderr (2)
 
# # Functions:
#
 
# # Function _debug() - print some debug info to stderr
#
function _debug {
D_WRITE -n "${clr.lin}Line ${.sh.lineno}:${clr.rst} "
D_WRITE "${clr.cmd}Command: '${.sh.command}'${clr.rst}"
[[ -n ${x} ]] && D_WRITE " ${clr.out}x=${x}${clr.rst}"
[[ -n ${y} ]] && D_WRITE " ${clr.out}y=${y}${clr.rst}"
[[ -n ${result} ]] && D_WRITE " ${clr.out}result=${result}${clr.rst}"
}
 
######
# main #
######
trap _debug DEBUG # Call _debug() on DEBUG trap (i.e. every line)
 
integer x y result
x=1
y=5
(( result = x + y ))
exit
</lang>
{{out}}<pre>
Line 33: Command: 'typeset -li x y result'
Line 34: Command: 'x=1'
x=1
Line 35: Command: 'y=5'
x=1
y=5
Line 36: Command: '(( result = x + y ))'
x=1
y=5
Line 37: Command: 'exit'
x=1
y=5
result=6
</pre>
 
=={{header|Mercury}}==
70

edits