Executing a Simple IDL Program

To show IDL's programming capabilities, the following program example uses the iVolume iTool to display volume data. This example uses Black Hole volume data provided by the University of North Carolina.

  1. From the IDL Workbench, open a new IDL Editor window by selecting File  New  IDL Source File.
  2. Type (or copy) the following lines of code into the new Editor window to form a program:
  3. PRO my_ivolume, _EXTRA=_extra 
     
    ; Set the variable fname to the black hole volume data file 
    fname = FILEPATH('cduskcD1400.sav', SUBDIR=['examples', 'data']) 
    RESTORE, fname 
    ; load a color table and supress the color table message using 
    ; the keyword /SILENT 
    LOADCT, 15, /SILENT 
    ; Return the Red, Green, Blue values from the  
    ; internal color tables  
    ; to the variables r, g, b 
    TVLCT, r, g, b, /GET 
    ; Display the data using the iVolume iTool 
      IVOLUME, density, RGB_TABLE0=[[r],[g],[b]], $ 
        /AUTO_RENDER, /NO_SAVEPROMPT 
    END 
     
    

    Note
    Semicolons (;) in IDL code are indicators of the beginning of comment lines, which explain what the actual code lines are doing and/or help you understand your code (while being ignored by IDL itself).

    Note
    The dollar sign ($) at the end of a line is the IDL continuation character. It allows you to enter long IDL commands as multiple lines.

Saving, Compiling, and Running

To view the program at work, IDL requires a few additional steps:

  1. Save the file as my_ivolume.pro by selecting FileSave As and then entering "my_ivolume.pro".
  2. Run the program by selecting Run Run my_ivolume.pro (IDL automatically compiles the program if it is in the IDL path).

The resulting iVolume window displays the following image:

program_example_screenshot.gif

Note
If your program encounters an error while executing, be sure to check your code for typographical errors.