X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 03 Feb 2008 01:35 PM by  anon
Simple question on path
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
03 Feb 2008 01:35 PM
    Hello, I am compiling running an ABC.pro in a given Linux directory. ABC.pro calls other procedures, lets say 123.pro, which are located in the same directiory as ABC.pro. At run time, I get an error saying that the "123" variable is undefined. How can I solve this problem? I went ahead and opende the 123.pro and compiled, then went back to my ABC.pro and it went well. How can I avoid the manually compiling 123 (or other procedures needed by ABC.pro) on the fly? Thanks!

    Deleted User



    New Member


    Posts:33
    New Member


    --
    03 Feb 2008 01:35 PM
    Hi Cecilia, In order for this to work correctly, the name of the file and the name of the procedure need to be the same. For instance, I wrote a procedure: pro a print,'i am in a' end and placed it in a file called a.pro I wrote a procedure: pro b print,'now I am in b' end and placed it in a file called b.pro. I wrote a procedure pro c a b end and placed it in a file called c.pro. I started IDL and did the following: IDL> .compile c.pro % Compiled module: C. IDL> c % Compiled module: A. i am in a % Compiled module: B. now i am in b IDL> and it automatically compiled the IDL procedures as long as the file name is the same as the procedure name. Note also that if there is more than one procedure in the file, it will keep compiling until it gets to a procedure name that is the same as the file's name, which will be the last one compiled. So, for example, if the file b.pro has procedures in it named b, e, f, g, b23 then all the procedures will be compiled up to procedure b, where ever it happens to be in the file. Therefore, in order to compile all the procedures, place procedure b as the last procedure in the file. I've seen this documented but I cannot recall where. Make sure the naming is correct - I do not recall if IDL procedure names can begin with a numeral. See the "Automatic Compiling" help, also.

    Deleted User



    New Member


    Posts:
    New Member


    --
    03 Feb 2008 01:35 PM
    This problem is a legacy from IDL's FORTRAN roots, which led to IDL accepting '( )' parentheses as markers for array subscripts. Most other modern languages require '[ ]' brackets, but IDL accepts both syntax forms. The problem with '( )' parentheses is that in some cases they can be ambiguous to the IDL interpreter/compiler. To remove the ambiguity, one option is to use the IDL statement FORWARD_FUNCTION, as in: FORWARD_FUNCTION 123 anywhere before the appearance of your first call to '123.pro'. (This example is a little flawed because IDL procedure names can not begin with a numeric digit.) There is also an IDL compiler option called: COMPILE_OPT STRICTARR which would accomplish the same, but requires you to use only '[ ]' for your array subscripting syntax. See IDL Online Help for more details on these two IDL statement types. James Jones
    You are not authorized to post a reply.