PDA

View Full Version : how to get error-line & script?



ReneMiner
21-12-2015, 16:57
As you know i create some editor to code thinBasic-scripts.

Now I have a few questions.

Assume i make an executeable of thinICE that shall be able to run the current script if user hits F5.

Now how would i shell:


String scriptToRun = "c:\myScripts\myScript.tBasic"

OS_Shell( "c:\thinBasic\thinBasic.exe " & scriptToRun, %OS_WNDSTYLE_NORMAL, %OS_SHELL_SYNC )

???

What if "myScript.tBasic" is buggy and an error within script occured -

How can i find out the scriptunit & codeline with the error so i can display the buggy line?
Will OS_Shell return something like an absolute scriptline-number in this case,
like
if returns 1234 and myScript.tBasic #Includes "myUnit.tBasicU" with a length of 2000 lines at line 234
then the error occured in unit myUnit at line 1000?
And when returns 2345 then the error was at line 345 of myScript.tBasic since 2000 lines previous this are in another unit?


What switch to use when i want to run in debug-mode ( F8 ) ?

ErosOlmi
21-12-2015, 19:31
I have to spoil one of the thinBasic secrets :)

There are special command line options you can specify. Only one at the time.

Syntax is:

\thinBasic\thinBasic.exe [SpecialFlag] ScriptFullPathName

Special flags are:


@@L@@##
Instruct thinBasic to produce a log file containing execution results in case of runtime error


@@O@@##
Instruct thinBasic to create obfuscation version of the script (with extension .tbasicX)


@@B@@##
Start bundling (this will work only if called from thinAir)


@@D@@##
Execute script in debug mode












Example:
C\thinBasic\thinBasic.exe @@L@@## "C:\mypath\thinIce.tBasic"

If a runtime error will occur, you will find a .log file into current user temp directory.
Log file will be the name of the script .Log
Example thinIce.tbasic.log
From the log file you can get all the info you get in standard runtime error dialog.

You can get current user temp directory using:
OS_GetSpecialFolder(%CSIDL_LOCAL_APPDATA) & "temp\"
It is not the correct way but can work.

There is a special API called GetTempPath(...) but I've not implemented.

ErosOlmi
21-12-2015, 19:38
Log file is something like the following INI file:


[Script]
Main=C:\thinBasic\UserScripts\Rene\thinICE\thinICE.tbasic
Include=
[RunTimeError]
DateTime=21/12/2015 18:34:46
Code=18
Description=Unknown Keyword
Line=4
LineCode=X
Token=X
Additional=


Error can be in Main File or in Include File.
If Include File is not empty than error is in there at line ... (4 in the above example)