Creating a Simple Program

In this section, we'll create a simple "Hello World" program consisting of two .pro files. Start the IDL Workbench and complete the steps described below.

Note
For information on using the IDL Editor, see

  1. Open a new IDL Source File. Start the IDL Editor by selecting FileIDL Source File or clicking the New IDL Source File button on the toolbar.
  2. Create a procedure. Type the following in the IDL Editor:
  3. PRO hello_main 
       name = '' 
       READ, name, PROMPT='Enter Name: ' 
       str = HELLO_WHO(name) 
       PRINT, str 
    END 
    
  4. Save the procedure. To save the file, select FileSave or click the Save button on the toolbar. Save the file with the name hello_main.pro in the main IDL directory (which the Save As dialog should already show).
  5. Create a function. Open a new IDL source file by selecting FileIDL Source File or clicking the New IDL Source File button on the toolbar. Enter the following code:
  6. FUNCTION hello_who, who 
       RETURN, 'Hello ' + who 
    END 
    
  7. Save the function. Save the file as hello_who.pro in the main IDL directory. This simple program, consisting of a user-defined procedure, calls a user-defined function.
  8. Compile the programs. Compile hello_main.pro and hello_who.pro programs by selecting ProjectBuild All.
  9. Note
    You can also type .COMPILE hello_who.pro, hello_main.pro at the IDL command prompt to compile the files. With functions, the compilation order does matter. See Compiling Your Program for details.

  10. Run the program. Select RunRun hello_main.
  11. Enter a name. Type your name at the IDL command line, which now reads "Enter Name" and press the Enter key. This passes the text to the function hello_who. The "Hello name" string is returned to the procedure and printed in the Console View.