Problem Creating XObjView Save File

QUESTION: I am having a problem creating an IDL save file that will run on the IDL Virtual Machine (VM) when the save file contains the IDL procedure XObjView. Consider, for example, this simple program.

   PRO TestSave
      s = Obj_New('IDLgrText', 'This is some example text')
      XObjView, s
   END

Starting in a fresh IDL session, I execute the following code as a batch file.

   .compile testsave
   Resolve_All, CLASS=['IDLExobjviewwid',$
                       'IDLExViewGroup', $
                       'IDLExObjView', $
                       'IDLExinscribingview', $
                       'IDLExViewManip', $
                       'IDLgrText']
   Save, FILE='C:\IDL\testsave.sav', /ROUTINES

I now exit IDL and drag the save file to the IDL Virtual Machine. It doesn't run. Tells me to contact the author of the program. Unfortunately, he is still drinking rum and cokes in the Bahamas.

If I put a Catch error handler into the TestSave program to get additional information about the error, I find the program is failing with the following, totally unhelpful, error.

   %XOBJVIEW: Unable to invoke method on NULL object reference:
   <OBJREF (<NullObject>)>.
   % Execution halted at XOBJVIEW 
   %                TESTSAVE
   %                IDLRTMAIN
   %                $MAIN$

I now start up IDL and restore the save file and run it, like this.

   IDL> Restore, 'C:\IDL\testsave.sav'
   IDL> testsave

The program runs perfectly and there is no indication anything else is compiled in this new IDL session.

Next, I do the very same thing as before, except this time in the batch file I actually run TestSave instead of compiling it.

   testsave
   Resolve_All, CLASS=['IDLExobjviewwid',$
                       'IDLExViewGroup', $
                       'IDLExObjView', $
                       'IDLExinscribingview', $
                       'IDLExViewManip', $
                       'IDLgrText']
   Save, FILE='C:\IDL\testsave.sav', /ROUTINES

This time, when I exit IDL and drag the save file to the Virtual Machine, it runs perfectly.

What in the world is going on here!? My theory, obviously, is that something is not getting compiled. But, what!?

ANSWER: Yes, this is a mystery. Thanks to PP Penteado on the IDL newsgroup for tracking it down for us.

It appears there is one more object needed in your CLASS keyword. Namely IDLexModelManip. It is pretty much impossible to know this, however, since that program has been written with the compile option "hidden" in every single one of its methods. Which means you will never get a message in the IDL console that the program has been compiled. I can't think of a single reason why the author of the program would do this, so I presume it is an oversight.

But if you add that object to your Resolve_All command, all will work as you expect.

   testsave
   Resolve_All, CLASS=['IDLExobjviewwid',$
                       'IDLExViewGroup', $
                       'IDLExObjView', $
                       'IDLExinscribingview', $
                       'IDLExViewManip', $
                       'IDLgrText', $
                       'IDLexModelManip']
   Save, FILE='C:\IDL\testsave.sav', /ROUTINES

Version of IDL used to prepare this article: IDL 7.1.2

Google
 
Web Coyote's Guide to IDL Programming