launch a file [message #91968] |
Wed, 23 September 2015 14:38 |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
I wanted to be able to launch any file (e.g. a .pdf or .pptx file) from IDL, in the same way that the OS or a browser does. The program file_launch.pro at
http://idlastro.gsfc.nasa.gov/ftp/v84/file_launch.pro
will do this (e.g. IDL> file_launch,'test.xlsx' ). It first tries to use the
Java desktop class
https://docs.oracle.com/javase/tutorial/uiswing/misc/desktop .html
and if this fails, it spawns to the appropriate launch command for the oS.
if !VERSION.OS_NAME EQ 'Mac OS X' then spawn,'open "'+ file +'" &' else begin
case StrUpCase(!Version.OS_Family) OF
'WINDOWS': spawn, 'start "" "'+ file +'"', /nowait
'UNIX': spawn, 'xdg-open "'+ file +'" &'
else: print, 'Unable to launch ' + file + ' automatically.'
endcase
endelse
Two questions:
1. Is there an existing method within IDL to do this? I'd rather not pollute the IDL namespace with a new program, if there is already a way to open files.
2. I would be interested to know if the program fails on some IDL Version/OS combination. I've only tested it on the 3 machines I have access to.
--Wayne
|
|
|