pro for_struct_to_string,structin,stringout,flat=flat ;+ ; Name: FOR_HEAD_TO_STRUCT_STRING ; ; INPUT -- STRUCTIN -- structure input ; ; KEYWORD FLAT -- will remove 3D trace ; for now it is default and also wwe have not tested not having it ; ; OUTPUT -- STRINGOUT -- string array output ; ; for now cannot handle array or structure sub elements -- will ignore them ; ***STILL TESTING -- NOT USED -- MWRITEFITS WORKS WITH STRUCTURE ; default,flat,1 tnames=strupcase(tag_names(structin)) n_key=n_tags(structin) stringout=strarr(n_key+1) count=0 for i = 0,n_key-1 do begin z=execute("key = structin."+tnames[i]) if n_elements(size(key)) eq 3 then begin ; if tnames[i] ne 'XTENSION' and tnames[i] ne 'NAXIS3' and tnames[i] ne 'EXTNAME' then begin if tnames[i] ne 'XTENSION' and tnames[i] ne 'NAXIS1' and tnames[i] ne 'NAXIS2' and tnames[i] ne 'BITPIX' and tnames[i] ne 'NAXIS3' and tnames[i] ne 'NAXIS' and tnames[i] ne 'EXTNAME' then begin stringout[i]=tnames[i]+' = '+strtrim(string(key),2) endif else begin if flat eq 0 then stringout[i]=tnames[i]+' = '+strtrim(string(key),2) endelse ; if flat eq 1 then begin ; if tnames[i] eq 'NAXIS' then stringout[i]=tnames[i]+' = 2' ; endif endif else begin stringout[i]=tnames[i]+' = array or structure did not save' print,stringout[i] endelse count=count+1 endfor stringout[count]='END ' stringout=stringout[where(stringout ne '')] end