Viewing contents of file '../idllib/sdss/allpro/field2string.pro'
FUNCTION field2string, field

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+
;
; NAME: 
;    FIELD2STRING
;       
; PURPOSE: 
;    Function outputs a string containing field of a photo tsObj 
;    file in the correct format.
;	
;
; CALLING SEQUENCE: 
;    result = field2string(field)
;      
; INPUTS: 
;    field
;       
; OUTPUTS: 
;    field string or '' if error.
; 
; PROCEDURE: 
;      field should have 4 characters padded with zero's if its
;      not big enough.  e.g. if input 33, output is '0033'
;	
; REVISION HISTORY:
;     Author: Erin Scott Sheldon  Umich 5/25/99
;                                      
;-                                       
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


  if N_params() eq 0 then begin
     print,'-Syntax: result = field2string(field)'
     print,''
     print,'Use doc_library,"field2string"  for more help.'  
     return,''
  endif

fstr = ntostr(long(field))
CASE 1 OF
  (field GT 0) AND (field LT 10): $
               return, '000'+fstr
  (field GE 10) AND (field LE 99): $
               return, '00'+fstr
  (field GE 100) AND (field LE 999): $
               return, '0'+fstr
  (field GE 1000) AND (field LE 9999): $
               return, fstr
  ELSE: BEGIN
          print,'Field must be in [0,9999]'
          return,''
        END
ENDCASE 

return, ''
end