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

Home » Public Forums » archive » CASE statement
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: CASE statement [message #27051 is a reply to message #26938] Fri, 05 October 2001 11:44 Go to previous messageGo to previous message
weitkamp is currently offline  weitkamp
Messages: 33
Registered: October 1998
Member
Reimar,

May I summarize the first statement you make like this: "KEYWORD_SET
is a nice function, but has the wrong name"?

It actually also has some counterintuitive features. This one, for
example:

IDL> PRINT, KEYWORD_SET([0])
1

The online help describes this behavior correctly, but accidentally
passing a 1-element array instead of a scalar happens easily. Wasn't
there something here recently about the pitfalls of IDL making a
difference between scalars and single-element arrays?

Timm

Timm Weitkamp
European Synchrotron Radiation Facility (ESRF), Grenoble, France
Phone: +33 4 76 88 28 86 E-mail: weitkamp@esrf.fr
Reimar Bauer <r.bauer@fz-juelich.de> wrote in message news:<3BBC0706.B983FB42@fz-juelich.de>...

> David Fanning wrote:

>>

>> George McCabe (george.mccabe@gsfc.nasa.gov) writes:

>>

>>> ;+

>>> ; PURPOSE:

>>> ; "On or Off", turn any variable into a strict logical type

>>> ; with only two values 0 or 1

>>> ;

>>

>> Impressive code, George. But couldn't this be

>> more simply done with this:

>>

>> on_off = Keyword_Set(variable)

>>

>

>

> Hi David and all others,

>

>

> the most problem with all these functions arg_present, n_elements,

> keyword_set

> is that's most beginners believe that's some of them only works by

> keywords

> and some only for positional parameters.

>

> To learn something about IDL and its parameters here are two exercises

> of our course.

>

>

> regards

>

> Reimar

>

>

> 1)

> There are three functions given

>

>

>

> FUNCTION test1,minimum=min_val

> IF KEYWORD_SET(min_val) THEN RETURN,1 ELSE RETURN,0

> END

>

>

> FUNCTION test2,minimum=min_val

> IF ARG_PRESENT(min_val) THEN RETURN,1 ELSE RETURN,0

> END

>

>

> FUNCTION test3,minimum=min_val

> IF N_ELEMENTS(min_val) GT 0 THEN RETURN,1 ELSE RETURN,0

> END

>

> Fill out the form:

>

>

>

>

> CALL | test1 | test2 |test3

> ____________________________________________________________ ____

> PRINT, testX( ) | | |

> ____________________________________________________________ ____

> PRINT, testX(minimum=0) | | |

> ____________________________________________________________ ____

> PRINT, testX(minimum=10) | | |

> ____________________________________________________________ ____

> PRINT, testX(minimum=-10) | | |

> ____________________________________________________________ ____

> mv=0 & PRINT, testX(minimum=mv) | | |

> ____________________________________________________________ _____

> mv=10 & PRINT, testX(minimum=mv) | | |

> ____________________________________________________________ _____

> PRINT, testX(minimum=mv2) | | |

> ____________________________________________________________ _____

>

>

>

>

>

> 2)

> There are three functions given

>

>

>

> FUNCTION test1,min_val

> IF KEYWORD_SET(min_val) THEN RETURN,1 ELSE RETURN,0

> END

>

>

> FUNCTION test2,min_val

> IF ARG_PRESENT(min_val) THEN RETURN,1 ELSE RETURN,0

> END

>

>

> FUNCTION test3,min_val

> IF N_ELEMENTS(min_val) GT 0 THEN RETURN,1 ELSE RETURN,0

> END

>

> Fill out the form:

>

>

>

>

> CALL | test1 | test2 |test3

> ____________________________________________________________ ____

> PRINT, testX( ) | | |

> ____________________________________________________________ ____

> PRINT, testX(0) | | |

> ____________________________________________________________ _____

> PRINT, testX(10) | | |

> ____________________________________________________________ ____

> PRINT, testX(-10) | | |

> ____________________________________________________________ ____

> mv=0 & PRINT, testX(mv) | | |

> ____________________________________________________________ _____

> mv=10 & PRINT, testX(mv) | | |

> ____________________________________________________________ _____

> PRINT, testX(mv2) | | |

> ____________________________________________________________ _____

>

>

>

> --

> 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
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL LINUX support question
Next Topic: interpol

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

Current Time: Sun Oct 12 02:15:45 PDT 2025

Total time taken to generate the page: 4.23893 seconds