;Given a variable of any type, check if it is a single valid pointer, and if ;so, keep dereferencing it until it's not a single valid pointer anymore. ;Safe to use on any variable of any type. This will only return something ;different if the input variable is a single valid pointer. ; ;example: ; IDL> h=ptr_new(4) ; IDL> print,dereference_single(h) ;same as print,*h ; 4 ; IDL> h=ptr_new(ptr_new(ptr_new(h))) ; IDL> print,dereference_single(h) ;same as print,*(*(*(*h)))) ; 4 ;Note that the input parameter is not modified in any way. function snap,a b=a while (n_elements(b) eq 1) && (size(b,/type) eq size(ptr_new(),/type)) && (ptr_valid(b) eq 1) do b=*b return,b end