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 
Return to the default flat view Create a new topic Submit Reply
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 messageGo 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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
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: Sat Oct 11 13:43:51 PDT 2025

Total time taken to generate the page: 0.72153 seconds