function test_integer,a
;+
; NAME:
;  test_integer
; PURPOSE:
;   Test a string to see if it is a valid integer 
; CALLING STATEMENT:
;   result = test_integer( string_variable )
;
;   test_integer('32')   will return 1
;   test_integer('32b')  will return 0
;   test_integer('3 21') will return 0
;   test_integer('a321') will return 0
;
; INPUTS:
;   string_variable	= Must be a scalar string
; RETURNS:
;   1 if input can be converted to an integer 
;   0 if input CANNOT be converted to an integer
;   1 if the input variable is not a string
;
; MODIFICATION HISTORY:
;   12-may-95, J. R. Lemen (LPARL), Written.
;-

if n_elements(a) ne 1 then message,'Input variable must be a scalar'	; This will halt
sz = size(a)
if sz(sz(0)+1) ne 7 then return,1	; If no string passed in, return a 1

on_ioerror, nogood			; Set error condition to jump if necessary
nchar = strlen(a)
result = 1				; 1 = true (this was an integer)
for i=0,nchar-1 do bb = long(strmid(a,i,1))	; Try to convert to an integer

goto, good				; Jump to good if things are O.K.

nogood: result=0			; Jump here if not an integer

good:   on_ioerror, null		; Reset the error condition
return,result
end
