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

Home » Public Forums » archive » Re: string definition question
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: string definition question [message #33608 is a reply to message #33607] Tue, 14 January 2003 10:04 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
mwvogel wrote:
>
> As my news server refuses my post, I'll paste it here :-)
>
> ///////////////////
> I would try KEYWORD_PRESENT; with A defined as 'IDL', B as '' and C
> undefined I get the following :
> IDL> A = 'IDL' & B = '' & PRINT, KEYWORD_SET(A), KEYWORD_SET(B),
> KEYWORD_SET(C)
>
> 1 0 0
>
> I guess that works in routines too.

D'oh! Why didn't I think of that!?

Thanks!

paulv




>
> Mika
> ///////////////////
>
> Mika
>
> "Paul van Delst" <paul.vandelst@noaa.gov> schreef in bericht
> news:<3E2432EC.18E46318@noaa.gov>...
>> Hello there,
>> Although I should probably know the answer to this, since all my IDL
>> reference books have
>> been borrowed, hope you don't mind me asking here.
>> I'm a bit anal about argument checking in IDL. After establishing that the
>> correct number
>> of arguments has been passed using:
>> n_arguments = 1
>> IF ( N_PARAMS() LT n_arguments ) THEN $
>> MESSAGE, 'Invalid number of arguments.', $
>> /NONAME, /NOPRINT
>>
>> My standard method for checking string arguments (like filenames to read)
>> is something
>> like:
>> IF ( N_ELEMENTS( FileNAME ) EQ 0 ) THEN BEGIN
>> MESSAGE, 'Input FileNAME argument not defined!', $
>> /NONAME, /NOPRINT
>>
>> IF ( STRLEN( FileNAME ) EQ 0 ) THEN $
>> MESSAGE, 'Input FileNAME argument not defined!', $
>> /NONAME, /NOPRINT
>> If I pass a zero-length string, e.g. FileNAME='', the N_ELEMENTS() test
>> passes so I always
>> test for a non-zero string length (it's happened). If I combine the two
>> tests using AND,
>> then if the variable is undefined, the STRLEN() function generates an
>> errors (since its
>> argument must be defined).
>> The above works great, but I have always felt that it should be
>> unnecessary. Is there a
>> one-step method to test that the argument is actually defined AND that the
>> string length
>> is not zero? Would the ARG_PRESENT function be useful here somehow? I read
>> the on-line
>> manual, but I really don't grok the text.
>> Thanks for any info,
>> paulv
>> -- Paul van Delst
>> CIMSS @ NOAA/NCEP/EMC
>> Ph: (301)763-8000 x7274
>> Fax:(301)763-8545

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Ph: (301)763-8000 x7274
Fax:(301)763-8545
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: string definition question
Next Topic: Re: 2-D Density Plots

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

Current Time: Wed Oct 08 17:14:17 PDT 2025

Total time taken to generate the page: 0.00412 seconds