Fanning Software Consulting

Image as a Variable Name Has Been Appropriated

QUESTION: I am in the habit of writing code like this.

   image = cgDemoData(7)

But if I try to display this image using the Image() function in IDL 8 absolutely nothing happens! What's going on!?

    imgObj = Image(image)

ANSWER: Ah, yes, this is another case of the IDL 8 function graphics routines appropriating a number of commonly used names.

To get around this particular problem, you will have to use the compiler option STRICTARR. The normal way to do this is to declare the compiler option idl2 (which sets both STRICTARR and DEFINT32) both in your IDL start-up file (so it is in effect at the IDL command line) and in every single one of the procedures and functions you write in IDL 8.

The correct way to write this code is like this.

   .Reset
   Compile_Opt idl2
   image = cgDemoData(7)
   imgObj = Image(image)
Now the Image() function works.
By setting the compiler option STRICTARR, the Image() function can now work properly.
 

Version of IDL used to prepare this article: IDL 8.1.

Written: 17 September 2011