DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing the line number of a VBS script

Is there a way to access the line number of a script, while in that script?  If I wanted to do some LogFileWrite commands and also record where in the script that was happening, is that possible?

 

Thanks!

0 Kudos
Message 1 of 5
(3,535 Views)

Hi JuliaDawkins,

 

Are you referring to programatically determining the line number (such as "dim X = thisLineNum()" )? I don't believe VBScript has this functionality. If you're referring to just seeing line numbers in the script editor, you can right-click inside the editor and select "Properties", there is an option to enable/disable line numbers.

 

From what you've described, it seems like the closest thing would be to hard-code a line number into a LogFileWrite command.

NickelsAndDimes
Product Support Engineer - sbRIO
National Instruments
0 Kudos
Message 2 of 5
(3,502 Views)

I asked for this a long time ago, there was no way to do it back then.  It's certainly there somewhere because the error message gives you the line number, but unless something changed since Diadem 2014, it's not available to the script interface.  

 

My workaround for this was to make my log file calls as descriptive as possible, and then just copy from the log file and do a find in my script for that text. 

Message 3 of 5
(3,470 Views)

Yes! "It's certainly there somewhere because the error message gives you the line number" 🙂 thanks for the input.

0 Kudos
Message 4 of 5
(3,466 Views)

Hi Julia,

 

If I do not mind stopping the script, then can do a err.raise and it will always give me the line number.

 

If though I have the "on error resume next" turning of error reporting, then do not get any line number details.

 

Paul

0 Kudos
Message 5 of 5
(3,440 Views)