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

Home » Public Forums » archive » End of Array - like - End Of File
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
End of Array - like - End Of File [message #25952] Fri, 27 July 2001 08:59 Go to next message
Emmler, Oliver is currently offline  Emmler, Oliver
Messages: 14
Registered: May 2001
Junior Member
Hi all,
i have a directory with different numbers of files. I read the filenames by

text = FINDFILE('H:/radiologie/*.dcm')

in my testdirectory there are 14 files so it's defined when to stop

FOR i=0,14 DO file[*,*,i] = READ_DICOM(text[i])

QUESTION:
How can i get the size of the array TEXT to stop by FOR i=0,stop DO ...
Is there something like EOA (EndOfArray) like EOF ?

Thanks,
Oliver Emmler

--
Oliver Emmler
University of Heidelberg
Departement of Radiology
Phone: +49-6221-7963059 E-Mail: Oliver.Emmler@med.uni-heidelberg.de
Re: End of Array - like - End Of File [message #26281 is a reply to message #25952] Mon, 20 August 2001 07:36 Go to previous messageGo to next message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Timm Weitkamp wrote:
>
> Reimar's suggestion of using the COUNT keyword to FINDFILE is indeed
> *much* better than using N_ELEMENTS, because the latter will result in
> an error when the file list is empty (unless you use an additional
> line to catch that situation). The reason is that when FINDFILE finds
> no matches, its return value is a scalar null string, and N_ELEMENTS()
> of that is one (not zero).
>
> Reimar Bauer <r.bauer@fz-juelich.de> wrote in message news:<3B7FF5BE.526BE6@fz-juelich.de>...
>> "Emmler, Oliver" wrote:
>>>
>>> Hi all,
>>> i have a directory with different numbers of files. I read the filenames by
>>>
>>> text = FINDFILE('H:/radiologie/*.dcm')
>>
>> you should use the count keyword of findfile
>>
>> Result = FINDFILE( File_Specification [, COUNT=variable] )
>>
>> FOR i=0,count-1 do ...
>>
>> regards
>> Reimar

I actually prefer the following syntax:

list = findfile('*.dcm')
if (list[0] ne '') then begin
;- process each name in list
endif

This takes advantage of the fact that FINDFILE returns a null string if
no files are found.

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
Re: End of Array - like - End Of File [message #26283 is a reply to message #25952] Mon, 20 August 2001 00:46 Go to previous messageGo to next message
weitkamp is currently offline  weitkamp
Messages: 33
Registered: October 1998
Member
Reimar's suggestion of using the COUNT keyword to FINDFILE is indeed
*much* better than using N_ELEMENTS, because the latter will result in
an error when the file list is empty (unless you use an additional
line to catch that situation). The reason is that when FINDFILE finds
no matches, its return value is a scalar null string, and N_ELEMENTS()
of that is one (not zero).

Reimar Bauer <r.bauer@fz-juelich.de> wrote in message news:<3B7FF5BE.526BE6@fz-juelich.de>...
> "Emmler, Oliver" wrote:
>>
>> Hi all,
>> i have a directory with different numbers of files. I read the filenames by
>>
>> text = FINDFILE('H:/radiologie/*.dcm')
>
> you should use the count keyword of findfile
>
> Result = FINDFILE( File_Specification [, COUNT=variable] )
>
> FOR i=0,count-1 do ...
>
> regards
> Reimar
>
> --
> Reimar Bauer
>
> Institut fuer Stratosphaerische Chemie (ICG-1)
> Forschungszentrum Juelich
> email: R.Bauer@fz-juelich.de
> http://www.fz-juelich.de/icg/icg1/
> ============================================================ ======
> a IDL library at ForschungsZentrum Juelich
> http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
>
> http://www.fz-juelich.de/zb/text/publikation/juel3786.html
> ============================================================ ======
>
> read something about linux / windows
> http://www.suse.de/de/news/hotnews/MS.html
Re: End of Array - like - End Of File [message #26287 is a reply to message #25952] Sun, 19 August 2001 10:22 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
"Emmler, Oliver" wrote:
>
> Hi all,
> i have a directory with different numbers of files. I read the filenames by
>
> text = FINDFILE('H:/radiologie/*.dcm')

you should use the count keyword of findfile

Result = FINDFILE( File_Specification [, COUNT=variable] )

FOR i=0,count-1 do ...

regards
Reimar

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
Re: End of Array - like - End Of File [message #26455 is a reply to message #26281] Fri, 24 August 2001 03:02 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
"Liam E. Gumley" wrote:
>
> Timm Weitkamp wrote:
>>
>> Reimar's suggestion of using the COUNT keyword to FINDFILE is indeed
>> *much* better than using N_ELEMENTS, because the latter will result in
>> an error when the file list is empty (unless you use an additional
>> line to catch that situation). The reason is that when FINDFILE finds
>> no matches, its return value is a scalar null string, and N_ELEMENTS()
>> of that is one (not zero).
>>
>> Reimar Bauer <r.bauer@fz-juelich.de> wrote in message news:<3B7FF5BE.526BE6@fz-juelich.de>...
>>> "Emmler, Oliver" wrote:
>>>>
>>>> Hi all,
>>>> i have a directory with different numbers of files. I read the filenames by
>>>>
>>>> text = FINDFILE('H:/radiologie/*.dcm')
>>>
>>> you should use the count keyword of findfile
>>>
>>> Result = FINDFILE( File_Specification [, COUNT=variable] )
>>>
>>> FOR i=0,count-1 do ...
>>>
>>> regards
>>> Reimar
>
> I actually prefer the following syntax:
>
> list = findfile('*.dcm')
> if (list[0] ne '') then begin
> ;- process each name in list
> endif
>
> This takes advantage of the fact that FINDFILE returns a null string if
> no files are found.
>

I know but there are always different result values if a function gives
no results.
The most popular are -1, '', 0 and <null pointer>

The count is known by where too and some others. This gives a
possibility to
write code always in the same way. And I like it much more as e.g.

if idx[0] ne -1 then ...
if ptr_valid(ptr) then ..
if list[0] ne '' then ..
if x[0] ne 0 then ..

Sometimes I wish all unknown results are returned as null pointer.
But then I have to change all old routines.


regards

Reimar




> Cheers,
> Liam.
> Practical IDL Programming
> http://www.gumley.com/

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Video for Windows, Clear text in Object Graphics and a genetic algorithm
Next Topic: Re: Puzzle with floating point underflow

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

Current Time: Wed Oct 08 15:16:05 PDT 2025

Total time taken to generate the page: 0.00711 seconds