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
- Open a new IDL Source File. Start the IDL Editor by selecting File → IDL Source File or clicking the New IDL Source File button on the toolbar.
- Create a procedure. Type the following in the IDL Editor:
- Save the procedure. To save the file, select File → Save or click the Save button on the toolbar. Save the file with the name
hello_main.proin the main IDL directory (which the Save As dialog should already show). - Create a function. Open a new IDL source file by selecting File → IDL Source File or clicking the New IDL Source File button on the toolbar. Enter the following code:
- Save the function. Save the file as
hello_who.proin the main IDL directory. This simple program, consisting of a user-defined procedure, calls a user-defined function. - Compile the programs. Compile
hello_main.proandhello_who.proprograms by selecting Project → Build All. - Run the program. Select Run → Run hello_main.
- 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.
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.