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

Home » Public Forums » archive » File units (de)allocation in IDL - what is the proper way?
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
File units (de)allocation in IDL - what is the proper way? [message #93459] Fri, 22 July 2016 02:05 Go to next message
DAVIDE LENA is currently offline  DAVIDE LENA
Messages: 22
Registered: September 2011
Junior Member
Hello everyone,
when opening files to write outputs I usually do:

OPENW, unit1, 'file1.txt', /GET_LUN
OPENW, unit2, 'file2.txt', /GET_LUN
...
CLOSE, unit1
CLOSE, unit2

FREE_LUN, unit1
FREE_LUN, unit2

However, it seems that closing *and freeing* can be equally achieved with:

CLOSE, unit1, unit2, /ALL

Is this correct? Is there a best practice?
Thanks in advance.
Dave
Re: File units (de)allocation in IDL - what is the proper way? [message #93460 is a reply to message #93459] Fri, 22 July 2016 02:51 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Friday, July 22, 2016 at 11:05:09 AM UTC+2, Dave wrote:
> Hello everyone,
> when opening files to write outputs I usually do:
>
> OPENW, unit1, 'file1.txt', /GET_LUN
> OPENW, unit2, 'file2.txt', /GET_LUN
> ...
> CLOSE, unit1
> CLOSE, unit2
>
> FREE_LUN, unit1
> FREE_LUN, unit2
>
> However, it seems that closing *and freeing* can be equally achieved with:
>
> CLOSE, unit1, unit2, /ALL
>
> Is this correct? Is there a best practice?
> Thanks in advance.
> Dave

I don't think so.
These commands:

CLOSE, unit1
CLOSE, unit2

are the same as

CLOSE, unit1, unit2

But this command could do much more:

CLOSE, unit1, unit2, /all

In fact it will close *all* open units. And you don't need to specify the units at all. In other words it is equivalent to:

CLOSE, /ALL

Now you should see the problem: If you have other units open, this will close them. So it is only useful if you lost track of open units and you want to close them all... Otherwise you might close units that you don't want to close at all.

I hope this helps.

Cheers,
Helder
Re: File units (de)allocation in IDL - what is the proper way? [message #93462 is a reply to message #93459] Fri, 22 July 2016 03:43 Go to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 07/22/2016 11:05 AM, Dave wrote:
> when opening files to write outputs I usually do:
>
> OPENW, unit1, 'file1.txt', /GET_LUN
> OPENW, unit2, 'file2.txt', /GET_LUN
> ...
> CLOSE, unit1
> CLOSE, unit2
>
> FREE_LUN, unit1
> FREE_LUN, unit2
>
> However, it seems that closing *and freeing* can be equally achieved with:
>
> CLOSE, unit1, unit2, /ALL
>
> Is this correct? Is there a best practice?

not correct, CLOSEing a unit doesn't free it's lun, meaning the file is
closed but the lun number is blocked and cannot be allocated for opening
another process.
However, FREE_LUN implies closing a file if it is not already closed.

For the rest, Herders remarks apply - except that FREE_LUN doesn't have
an /ALL keyword.

So, FREE_LUN, unit1, unit2 would be correct, using separate lines is
only necessary if you need to retrieve the EXIT_STATUS.


Markus Schmassmann

https://www.harrisgeospatial.com/docs/understanding__luns_.h tml
https://www.harrisgeospatial.com/docs/FREE_LUN.html
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Read an ASCII file in a table based on delimeter line string
Next Topic: very very strange thing is happening with modfits......

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

Current Time: Wed Oct 08 07:16:25 PDT 2025

Total time taken to generate the page: 0.00446 seconds