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

Home » Public Forums » archive » Possible to create 'keyword_used' type function?
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: Possible to create 'keyword_used' type function? [message #88717 is a reply to message #88715] Mon, 09 June 2014 15:42 Go to previous messageGo to previous message
Chip Helms is currently offline  Chip Helms
Messages: 24
Registered: November 2012
Junior Member
Here's a cleaner version with some documentation as well.



;===============================
; PROGRAMMER: Chip Helms
; DATE: 6/9/2014
; DESCRIPTION: Determines if a variable
; is being used in any way (either having
; been given a value or set equal to a named
; variable as often used with keywords).
; It is equivilent to using:
; "n_elements(var) ne 0 or arg_present(var)"
; Note, the result does not have any meaning
; when called from $MAIN$ as calling the
; function automatically guarentees 'key' is
; set to a named variable or has a value.
; The exception to this is the trivial case
; of 'keyword_used()', which will return 0.
; PARAMETERS:
; key := variable to be tested for use
;===============================
function keyword_used, key
; grab list of variables at scope of parent routine
varnames = scope_varname(key,level=-2, count=nvar)
; determine if keyword is used as per arg_present function
; also protect against varnames being undefined for some reason
argtest = (nvar ne 0) ? total(varnames ne '') ne 0 : 0b
; return results of test for keyword presence
return, n_elements(key) ne 0 or argtest
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Ternary Plot in IDL?
Next Topic: How to display an image (tvscl, shade_surf, etc.) with values cut-off

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

Current Time: Wed Oct 08 16:02:46 PDT 2025

Total time taken to generate the page: 0.00251 seconds