comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » programmatically compile a procedure without a .pro extension
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
programmatically compile a procedure without a .pro extension [message #85662] Sat, 24 August 2013 18:10 Go to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Does anyone know if there is a way to programmatically compile a procedure that does not have a .pro extension? For example, if I have a file named a1.bak containing the following 4 lines:

pro a1
print,'Inside procedure a1'
return
end

then the user can successfully compile this using

IDL> .run a1.bak

But the tools to programmatically compile a file don't work in this case, i.e.

IDL> resolve_routine,'a1.bak'
or
IDL> file_compile,'a1.bak'

where file_compile is from Craig Markwardt's library
http://www.physics.wisc.edu/~craigm/idl/down/file_compile.pr o

It is reasonable to ask why I would not simply use a .pro extension. But the answer is fairly complicated so I don't (yet) want to distract from the straightforward question above. Thanks, --Wayne
Re: programmatically compile a procedure without a .pro extension [message #85663 is a reply to message #85662] Sun, 25 August 2013 05:10 Go to previous messageGo to next message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
If you don't want to get a .pro file by renaming (or making a copy of)
the .bak file, you can do something like the following. The routine
below creates a temporary .pro file and includes the files with other
extensions by use of the @ include file character:

pro compile,filenames
;
tempfile='compile_temp'
openw,lun,/get_lun,tempfile+'.pro'
printf,lun,'@'+filenames,form='(a)'
free_lun,lun
;
catch,error
if ~error then resolve_routine,tempfile
catch,/cancel
;
end

The catch statement suppresses an error message from the compiler,
that there is no compile_temp routine.

Note that you can specify the filenames by a string array, if you want
to compile more than one file.

Cheers, Heinz
Re: programmatically compile a procedure without a .pro extension [message #85667 is a reply to message #85663] Sun, 25 August 2013 20:23 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Heinz,

Thanks. That is an elegant use of CATCH.

I still have mild trepidation about requiring an arbitrary user to have write access to a disk. But I've never had any problem using IDL_TMPDIR as a scratch writeable directory, so I should probably
stop worrying. --Wayne

On Sunday, August 25, 2013 8:10:37 AM UTC-4, Heinz Stege wrote:
> If you don't want to get a .pro file by renaming (or making a copy of)
>
> the .bak file, you can do something like the following. The routine
>
> below creates a temporary .pro file and includes the files with other
>
> extensions by use of the @ include file character:
>
>
>
> pro compile,filenames
>
> ;
>
> tempfile='compile_temp'
>
> openw,lun,/get_lun,tempfile+'.pro'
>
> printf,lun,'@'+filenames,form='(a)'
>
> free_lun,lun
>
> ;
>
> catch,error
>
> if ~error then resolve_routine,tempfile
>
> catch,/cancel
>
> ;
>
> end
>
>
>
> The catch statement suppresses an error message from the compiler,
>
> that there is no compile_temp routine.
>
>
>
> Note that you can specify the filenames by a string array, if you want
>
> to compile more than one file.
>
>
>
> Cheers, Heinz
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Does Java polymorphism not work via the IDL Java Bridge?
Next Topic: x/y margin from map_set to plot position and cgimage

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:39:28 PDT 2025

Total time taken to generate the page: 0.00433 seconds