pro sav_string, string, infile, type=type, $
		path=path,  doc=doc,  refdata=refdata, nostrx=nostrx
;+
;   Name: sav_string
;
;   Purpose: save string to xdr file for Yohkoh !path, documentation, filemaps
;
;   Input Parameters:
;	infile -  filename of file to write
;  		  NOTE: by default, the extention .strx is forced
;	string - string variable to save
; 
;   Optional Keyword Parameters:
;	
;   Method: 
;       special files contain a single string (but the string may be long)
;	in XDR format for transporability 
;   
;   Calling Sequence: 
;	sav_string, string, infile [,type=type] [,/path] [,/doc] [,/refdata]
;
;   Categories:
;	swmaint, file i/o, gen, util
;
;   Notes: 
;	The pair of routines [sav_string/get_string] were developed to allow
;	saving and restoring of several yohkoh parameters (ex: !path) to help 
;	manage the Yohkoh idl environment but they are generic in nature and 
;	other uses may be considered.  They can be used in conjunction with 
;	arr2str and str2arr to allow storing of string 'arrays' 
;
;   History: slf, 30-July-92
;	     slf, 22-Jul-93	(use SITE instead of GEN)
;
;-
;  

extension='.strx'

types=['path','doc','refdata']
strfiles= concat_dir('$DIR_SITE_SETUPD', types + extension) ;predefined files
	  	
if n_elements(infile) eq 1 then file=infile else begin
   if n_elements(type) eq 0 then begin
      case 1 of
         keyword_set(path)    : type='path'
         keyword_set(doc)     : type='doc'
         keyword_set(refdata) : type='refdata'
      endcase
   endif
   which=where(type eq types,count)
   if count gt 0 then file=strfiles(which(0)) else $
      message,'Undefined strx file type'
endelse 
 
if not keyword_set(nostrx) then $	;force extention (.strx)
   if strpos(file,extension) ne strlen(file) - strlen(extension) then $
	file = file + extension      

openw,lun,/get_lun,/xdr,file
writeu,lun,string
free_lun,lun
;
return
end
;   
;
