Get current script line number

Started by kifrostit, May 30, 2017, 02:30:27 PM

Previous topic - Next topic

kifrostit

Is there a way to get a compiled scriptââ,¬â,,¢s current executing line number during runtime that is not part of error handling?
So instead of doing something line below:
Display(5,"ProgramName line 229",original)    ; for debugging and if your script changes, then the Display is no longer valid
I would like to do something like:
LineNumber=SomeFunction()  or reserved variable or constant
Display(5,"ProgramName line %LineNumber%",original)


JTaylor

I am curious...If you are willing to answer, to what use would you put such a feature?

Jim

stanl

I'm also curious. If it is a compiled script and runs as an EXE and you want the line being executed not part of the error handler - how would you control that?  Certainly not with display() as that would resemble a weak step-through.

td

As already alluded to that sort  feature has limited  usefulness.

However, a way to implement the behavior would be to generate and trap a minor error.  You could then obtain the line number from the error information.   Or you could simply devise your own naming system for the desired check points within the script.   The latter is something that is done in some programming languages when a debugger is not available.

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

A possible approach.

Code (winbatch) Select
; Error handler UDF.
#DefineFunction DisplayLineNo(_e)
   Display(2,'Line Nunber',_e[8]-2)
#EndFunction

;Blah blah blah

; Script lines here...
x = 1 

; Point were you want a line number
IntControl(73,3,1,'DisplayLineNo',0)
CauseError =

exit
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade