How to create a program?
- Open a new Editor window. Start the IDL Editor by selecting File to
New or clicking the New File button on the toolbar.
2. Create a procedure. Type the following in the IDL Editor window:
PRO hello_main
name = ''
READ, name, PROMPT='Enter Name: '
str = HELLO_WHO(name)
PRINT, str
END
3. Save the procedure. To save the file, select File to Save or click 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).
4. Create a function. Open a new Editor window by selecting File to New, and enter the following code:
FUNCTION hello_who, who
RETURN, 'Hello ' + who
END
5. 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.
6. Compile the programs. Compile hello_main.pro
and hello_who.pro
programs by selecting Run to Compile All.
7. Run the program. Select Run to Run hello_main.
8. Enter a name. Type a 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 Output window.