There are multiple ways to organize your code, and one of the best ways is to through IDL Workbench projects. The advantages of setting up individual projects rather than storing all of your files under one project are:
- Code and its related supporting files are kept together.
- Builds are cleaner and more efficient when you build an entire project at once, rather than compile .PRO files individually.
- You can set the compile order and other preferences for the project used during the build process.
- Exporting and sharing related files is easier.
- The IDL path can be managed through a project.
This topic discusses the following:
Guidelines for Using Projects
Suggested guidelines when using projects in the IDL Workbench include:
- Create projects that point to unique directories outside of the workspace provided by IDL. If you link projects to directories inside the program files area, you might lose them during an IDL upgrade, or you would need to move your existing .PRO files to the new IDL workspace or the new "Default" project. The "Default" workspace location is:
- Windows: C:\Users\<username>\IDLWorkspace8x
- Mac: /Users/<username>/IDLWorkspace8x
- Linux: /home/<username>/IDLWorkspace8x
- Do not store anything in the "Default" project that you want to keep. Use "Default" as a scratch space or a sandbox.
- Place routines that you consistently reuse in a separate directory and link them to a project. Keep this "library" project open so you can always access these routines.
- Keep your projects separated. For example, create directories on your computer or network to hold related IDL source code for tasks such as a programming project or a scientific paper. You can link these directories to the IDL Workbench with a project. For example:
- Keep all code for a single paper for publication in one project (i.e., each .PRO file creates a new figure for the finished paper).
- Keep all program files for a single programming deliverable together in one project to make performing a full build on the program easier.
Creating a Project
This section describes how to create a project.
Use the file browser to set up a directory in which to store the related .pro files for the paper. In the image below, a directory named TritiumContaminationPaper was created in the local Windows My Documents directory and three .PRO files that were created previously for this paper were moved into the directory.
Next, create the project from the IDL Workbench and connect it to the folder that was created on the local computer. Click the New Project icon in the Workbench toolbar.
The New IDL Project dialog appears. In the Name field, type TritiumContaminationPaper.
Select the Create the new project from an existing directory radio button, then click the Browse button. The Browse for a Directory dialog appears, which allows you to connect the new project to an existing directory.
Navigate to the directory to store the files in. In this case it is the TritiumContaminationPaper directory you created in the first step. Select the directory and click OK. From this dialog you can also create a new directory for your project files if you have not already created it.
The Workbench displays the new project in the Project Explorer. Expand the contents of the project by double-clicking its name to see the .PRO files stored there:
Compare the Workbench view of the project with the file browser's view of the folder:
Note that both windows display the .PRO files. Additionally, the file browser displays a file created by the IDL Workbench named .project. This file contains IDL-specific information about the project.
Projects and Path Management
One way to manage your path through IDL is through the project. It gives you a real-time, visual indication of your current path in the IDL Workbench.
By default, if a project's folder is "open" in your IDL Workbench's Project Explorer, then its underlying directory on your computer is automatically included in your IDL path. Conversely, if a project's folder is "closed," then its directory is not included in your IDL path. Note that you can override this behavior when creating a project.