function strnumbe,st,val ;+ ; NAME: ; STRNUMBER ; PURPOSE: ; Function to determine if a string is a valid numeric value. ; ; CALLING SEQUENCE: ; result = strnumbe( st, [val] ) ; ; INPUTS: ; st - any IDL scalar string ; ; OUTPUTS: ; 1 is returned as the function value if the string st has a ; valid numeric value, otherwise, 0 is returned. ; ; OPTIONAL OUTPUT: ; val - (optional) value of the string. real*8 ; WARNING: ; (1) Note that a blank string (e.g. " ") is not a valid numeric value, ; although an empty string ("") is (=0.0). ; (2) In V2.2.2 there was a bug in the IDL ON_IOERROR procedure that ; will cause the following statement to hang up IDL ; ; IDL> print,'' + string( strnumbe('xxx') ) ; This bug was fixed in V2.3.0 ; (3) As of V2.3.2, an IDL bug is seen in the following statements ; IDL> st = 'E' ; IDL> q = strnumbe(st) & print,st ; The variable 'st' gets modified to an empty string. This problem ; is related to the ambiguity of whether 'E' is a number or not ; (could be = 0.0E). A fix is expected in IDL V3.0 ; HISTORY: ; version 1 By D. Lindler Aug. 1987 ;- if N_params() EQ 0 then begin print,'Syntax - result = strnumbe( st, [val] ) return, 0 endif On_IOerror, L1 ;Go to L1 if conversion error occurs val = double(st) return, 1 ;No conversion error L1: return, 0 ;Conversion error occured end