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

Home » Public Forums » archive » Re: Passing Batch File Names
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Passing Batch File Names [message #62281 is a reply to message #62277] Tue, 02 September 2008 11:16 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Trae wrote:
> Just in case another poor soul needs this and searches the group, here
> are the lines of code that made it work. NB: EXECUTE only accepts
> scalars as an input. Bogus.

Your solution is very handy, but one should point out that blind execution of commands
read from a file is potentially dangerous. It's probably not that big of an issue for IDL,
but some of those batch file lines could be something like,

stuff = file_search('*')
for i=0,n_elements(stuff)-1 do file_delete, stuff[i], /quiet,/recursive

Keep those batch files protected from disgruntled employees. :o)

Using exec capabilities blindly is generally discouraged in scripting languages.

cheers,

paulv


>
> First define a batch file named batch_test.pro with the commands
>
> a=5
> b=6
> c=sin(!dpi/4.)
>
>
> Now here are the commands to read and execute it.
>
>
> file='batch_test.pro'
>
>
>
>
> openr, lun, file, /GET_LUN
> var_arr=''
> ;while not eof do begin
>
> WHILE ~ EOF(lun) DO BEGIN
> line=''
> READF,lun , line
> var_arr=[var_arr,line]
> ENDWHILE
> FREE_LUN, lun
> var_arr=var_arr[1:*]
>
> for i=0ul,n_elements( var_arr) -1ul do result=execute(var_arr[i])
>
> END
>
>
> So you can define the variable 'file' anyway you want and it can have
> as many or as few commands as you need.
>
> Thanks for the help everyone!
>
> I'm off to be quite pleased with myself for awhile! :)
>
> Cheers,
> -Trae
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Singular Value Decomposition in 3 Dimensions
Next Topic: FFT and ROTATE

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

Current Time: Fri Oct 10 00:46:36 PDT 2025

Total time taken to generate the page: 0.48610 seconds