X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 02 Jul 2015 03:08 PM by  anon
Request help with simple hello world. --- Execution halted at: $MAIN$
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:81
New Member


--
02 Jul 2015 03:08 PM
    IDL user question: Hello, I am new to IDL and in early phase of learning. I wanted to create simple function to print Hello world and created helloworld.pro with following lines function helloworld print, 'Hello World' end I am however facing issue when I try to compile and run with below message - IDL> .compile -v 'C:\Users\Shreyas\IDLWorkspace84\Default\helloworld.pro' % Compiled module: HELLOWORLD. IDL> helloworld % Compiled module: HELLOWORLD. % Compiled module: HELLOWORLD. % Attempt to call undefined procedure: 'HELLOWORLD'. % Execution halted at: $MAIN$ IDL> This is definitely a minor issue on my part. But I have not been able to figure out a solution :( I read on some threads that this is an issue with setting of IDL_DLM_PATH. If this is the case please suggest what should this environment variable be pointing to. Could anyone please help me resolve this.

    Deleted User



    New Member


    Posts:81
    New Member


    --
    02 Jul 2015 03:16 PM
    The IDL language has the separate concepts of routines as procedures or as functions. FUNCTIONS: Functions (where a function program is defined with the FUNCTION statement) are called in IDL statements with parentheses, where the parentheses may contain no parameters, one or more positional parameters, and/or keyword settings, depending on how the function is defined. (See: http://www.exelisvis.com/docs/definin... ) Function calls will return a value that can be assigned to a variable or used directly as a parameter in another routine call. (See the "Function Example" section of the IDL help page referenced above.) Normally, functions are expected to include an explicit RETURN statement with a value. However, if a function does not explicitly use a RETURN statement then upon completion, the function call will return the value zero (0). The "Run" button on the IDL Workbench toolbar will only call routines using procedure syntax. In your example: function helloworld print, 'Hello World' end the routine should be called with function syntax with no parameters, for example: a = helloworld() Additionally, since a RETURN is not explicitly used in the program upon completion, a zero value is returned. The the statement above, a will have the value of zero, for example: IDL> a = helloworld() Hello World IDL> help, a A INT = 0 You could send the (implicitly) returned value from the function helloworld to be used directly by another routine, such as PRINT, for example: IDL> print, helloworld() Hello World 0 --where the inside of the program helloworld prints "Hello World" and the PRINT statement that uses the output from helloworld(), prints "0". With IDL 8.4, you can used an implied PRINT statement and simply call the "helloworld" function at the IDL> command prompt (implied print won't work within a written program), without an explicit assignment to a variable or use of "print", for example: IDL> helloworld() Hello World 0 Note that if you attempt to run a function program from the IDL Workbench (IDLDE) by using the "Run" button, the call will fail because the run button will attempt to execute the routine as if it were a procedure. For example, the equivalent to this would be to try calling your helloworld function as if it instead were a procedure (without parenthesis), which would not be found: IDL> helloworld % Compiled module: HELLOWORLD. % Attempt to call undefined procedure: 'HELLOWORLD'. % Execution halted at: $MAIN$ PROCEDURES: Procedures are called in IDL without parentheses. (See: http://www.exelisvis.com/docs/Definin... ) Procedures don't return a value (implicit or explicit) that can be directly assigned to a variable or used in another statement (in the way that functions can). For example, to define your helloworld program as a procedure: pro helloworld print, 'Hello World' end Such a program could be called at an IDL> command prompt as follows: IDL> helloworld Hello World ---------------- Note that the IDL_DLM_PATH preference will only affect the search path for "dynamically loadable modules" used by IDL. (See: http://www.exelisvis.com/docs/DLM.html http://www.exelisvis.com/docs/prefs_d... ) See also: http://www.exelisvis.com/docs/Managin... http://www.exelisvis.com/Support/Help...
    You are not authorized to post a reply.