End of Array - like - End Of File [message #25952] |
Fri, 27 July 2001 08:59  |
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 #26455 is a reply to message #26281] |
Fri, 24 August 2001 03:02  |
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
|
|
|