X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



5754 Rate this article:
4.0

Starting working directory in apps run in IDL 6.1 (and later) Runtime, VM and Embedded-license mode

THIS INFORMATION ONLY PERTAINS TO SOFTWARE VERSIONS IDL 8.5, ENVI 5.3 AND PRIOR

Topic:

This article addresses the starting working directory behavior of precompiled native IDL application Save (*.sav) files that are executed in IDL 6.1 (and later) Runtime (RT) mode, Virtual Machine (VM) mode or Runtime Embedded License (EMB) mode. Collectively, RT, VM and EMB modes are known as IDL runtime environments.

Additional information about developing and distributing IDL Save file applications can be found in the "Building IDL Applications" online manual. For more information about Callable IDL see the IDL "External Development Guide".

Starting working directory behavior in a runtime verses a non-runtime IDL execution environment
  • Runtime environments
    In general, if a precompiled, native IDL *.sav file application is invoked in an IDL 6.1 or later runtime environment (RT, VM, EMB), then the starting working directory of that application session will be the directory location of the *.sav application file.

    Click here Table 1: Runtime environments to see an outline of runtime IDL execution environments in which running *.sav file applications causes this starting working directory behavior.

    NOTE: IDL 6.0 and earlier *.sav file application starting working directory behavior

    UNIX, Linux and Mac OS X
    For IDL 6.0 and earlier on UNIX, Linux and Mac OS X, the default starting IDL working directory for IDL *.sav file applications that were executed in VM, RT or EMB mode, was set to the same current working directory of the UNIX shell from which the user invoked the IDL application session.

    Windows
    For IDL 6.0 and before on Windows the starting working directory for *.sav file applications varied depending upon the method of invocation. Additionally a current working directory is not always easy to determine in a clickable Windows environment.
  • Non-runtime environments
    If the *.sav file application is restored and executed from the IDL command prompt, IDL source code or equivalent, then the just the execution of the *.sav file application will not automatically alter the working directory.

    Click here Table 2: Non-runtime environments to see an outline of non-runtime IDL execution environments in which running *.sav file applications do not cause the starting working directory to change.

Advantages of a Consistent Starting Working Directory Behavior in an IDL Runtime environment

IDL *.sav file applications are often distributed with or may create required files that exist relative to the application *.sav file itself. Being able to consistently reference the location of files relative to the main *.sav application file, and across platforms, makes it easy to keep track of associated files regardless of the installation location on a user's machine.

Changing the Default Starting Working Directory

However, if you require your IDL *.sav file application session to set the working directory to a location different than the directory that contains your *.sav file, your IDL program will need to explicitly reset the IDL current working directory (CD) to the desired location. Below are some examples that illustrate changing the working directory for your IDL application to a non-default location.

Discussion:

Starting Working Directory Behavior of *.sav File Applications, by IDL Execution Environment

Example approaches for changing the starting working directory for *.sav file applications launched in an IDL runtime environment

  • Example 1: Setting the IDL working directory to a hard-coded directory location (all platforms)

      If your IDL VM, RT or EMB *.sav file application requires that the working directory always starts in a fixed, known location, the programmer could simply set the working directory to a hard-coded path. For example, the initial IDL command for an application might look like:

        CD,'/usr/local/myappdir'

      The working directory can also be set to a location relative to the *.sav application file. For example, to set the working directory to a directory called 'myadjdir' that is adjacent to the *.sav application file location:

        CD,'../myadjdir'

      Be certain that the hard-coded directory path exists on the user's machine or an error will occur.

    [ back to top ^ ]
  • Example 2: Setting the IDL working directory to a system environment variable in the environment from which the application was executed (all platforms)

      This approach has the advantage of allowing the working directory to be specified from outside of the application code, via a system environment variable definition. For example, the initial IDL commands for an application might look like:

        sDir=GETENV('MYAPP_STARTDIR')
        IF sDir NE '' AND FILE_TEST(sDir,/DIRECTORY) THEN CD,sDir

      Using this approach on Windows, an IDL *.sav file application installer could automatically set the system environment "MYAPP_STARTDIR" in the system registry to the directory location of application files. Or you might have the user manually define the system environment variable as part of the installation process.

      On UNIX, the "MYAPP_STARTDIR" system environment variable could be defined in a user's shell setup (.*rc) file. Another strategy might be for the system environment variable to be defined within a shell script program that is created at installation time, setting the "MYAPP_STARTDIR" to the correct directory location.

    [ back to top ^ ]
  • Example 3: Setting the IDL working directory to the UNIX shell current working directory (UNIX / Linux / Mac OS X)

      On UNIX (as well as Linux and Mac OS X), in IDL 6.0 and earlier, the default starting working directory for IDL *.sav file applications executed in VM, RT or EMB mode, was set to the same current working directory of the UNIX shell from which the user invoked the IDL application session. In order to make a *.sav file application that is invoked in IDL *6.1* have a starting working directory behavior that is similar to IDL *6.0* behavior, a programmer could issue the following command at the beginning of the IDL program:

        CD,GETENV('PWD')

      This command uses the $PWD environment variable value (which specifies the shell's current working directory) of the shell that invoked the IDL session, in order to set the working directory location.

    [ back to top ^ ]

Solution:
[Edit this field in the IDL-based Tech Tip Editor, v62]

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »