X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 06 Aug 2015 03:40 PM by  Zachary Norman
Printing the line number you are on in .pro code
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Zachary Norman



Basic Member


Posts:173
Basic Member


--
06 Aug 2015 03:40 PM
    Is there a method to print out the current line that you are on in a program or .pro code?

    Zachary Norman



    Basic Member


    Posts:173
    Basic Member


    --
    06 Aug 2015 03:44 PM
    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 }
    You are not authorized to post a reply.