You can determine this by the use of the SCOPE_TRACEBACK function by doing this:
print, ((SCOPE_TRACEBACK(/STRUCT))[-1]).LINE
This will print the line of code that you are on ONLY if you are within a .pro file. This will not work if you restored a function from a .sav file because there are no lines to read from them. This function can also be used to find the location or source of a function/procedure, which is what I use it for all the time. it is especially handy when you want to save some output to the same location as the .pro code or .sav file. Here are the fields than can be returned by the scope traceback structure:
IDL> (SCOPE_TRACEBACK(/STRUCT))[-1]
{
"ROUTINE": "$MAIN$",
"FILENAME": "C:\Users\path\to\source.pro or .sav",
"LINE": 48,
"LEVEL": 0,
"IS_FUNCTION": false,
"METHOD": false,
"RESTORED": false,
"SYSTEM": false
}
|