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

Home » Public Forums » archive » Re: How to check variable type?
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: How to check variable type? [message #40504] Mon, 16 August 2004 16:49 Go to previous message
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
Here's a little dual-action function you can use.

;+
; -------------------------
; IDL function: var_type.pro
; for a given input variable, this function returns
; the type of that variable. The returned value is a number 0-15
; equal to the second-to-last field in the "size" function,
; OR if the keyword "string" is set, a type name is returned.
;
; Examples:
; print, var_type(1d) ;--- returns "5"
; print, var_type(1d, /string) ;--- returns "DOUBLE"
; -------------------------
;-

function var_type, a, string = string
return, keyword_set(string) ? size(a, /TNAME) : size(a, /TYPE)
end




biophys@gmail.com (biophysics) wrote in message news:<512b0d8b.0408131520.46e68fbd@posting.google.com>...
> Hi, guys
>
> I want to write a function that processes data very differently
> according to the type. But How do I check the type inline? I couldn't
> find any clue by a quick look through the function list. Can anybody
> give me some hints?
>
[Message index]
 
Read Message
Read Message
Previous Topic: animate loaded images
Next Topic: Re: animate loaded images

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

Current Time: Sat Oct 11 01:33:46 PDT 2025

Total time taken to generate the page: 0.56131 seconds