TYL PROGRAMMING LANGUAGE
▶ DEBUGGING
Basic Debugging in Tyl
Tyl supports code debugging in the form of logging debug data in a file. All debug functions start with the symbol: '@', and can be found in the debugging reference.

To write debug text:
@ 'PROGRAM DEBUGGING FILE'
Running the code will result in the generation of a file called: 'tyl-run-debug.log'. This is the default Tyl debug file name. You can open the file and see the text:
PROGRAM DEBUGGING FILE
In order to log debug data in a different file:
@debug_file 'app.debug'
@ 'APP DEBUG'
Line: @debug_file 'app.debug', indicates to the system to set debug file name: 'app.debug'. Running the code will generate a debug file: 'app.debug'.

To log variable data:
counter 120
@ counter
Line: '@ counter', will log counter value: 120.

@ debug functions works with statements too, and logs the result of the statement, as demonstrated here.

Debugging function names are in the format: '@<FUNC_NAME>', where <FUNC_NAME> is the name of the function. So writing: @counter, without space, will cause the system to search for: @counter debug function!

To see the variable name too, use @k debug function:
counter 120
@k counter
@k causes the system to print the variable key and value in the format: 'key: value'
counter: 120

To see the current time, use @time:
counter 120

index 3 ~
pause 0.3
counter ++
@time counter
^
Will print something like this:

[13 OCT 2020 12:09:18.604] - 121
[13 OCT 2020 12:09:18.963] - 122
[13 OCT 2020 12:09:19.290] - 123


While debugging a program with functions, it is possible to show the current function name in the debug log:
@ 'greet program debug'
@ '‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾'
@ 'this program prints each function'
@ 'name upon calling.' + newline

go:
@f
greet 'Mitarai'

greet me:
@f
@ 'function `greet` prints: `Hi ' + me + '`'
print 'Hi ' + me
The line: @f, causes the system to log the current enclosing function. So upon program running, the system calls go function, and than greet function, each time @f logs the function name:

greet program debug
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
this program prints each function
name upon calling.

go
greet
function 'greet' prints: 'Hi Mitarai'


If full function information needed, use @fp to log the parameters too:
go:
print trunc 'String to Truncate' 2 13

trunc str start length:
@fp
str string.section str start length
The trunc function along with its incoming arguments will be logged:

_______________________________
trunc

str: String to Truncate

start: 2

length: 13

PART 2