; $Id: dcs_reduction_stratagems.pro,v 1.5 2005/02/14 17:50:14 azuah Exp $
; Written by J.R.D. Copley.
;************************************************************************************************
;###############################################################################
;
; LICENSE:
;  The software in this file is written by an employee of 
;  National Institute of Standards and Technology 
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used or if the code in this file is
;  included in another product.
;
;###############################################################################
pro dcs_reduction_stratagems,filename=filename,strategy,button_tags,modifiable,n_stratagems,$
	n_skipped_stratagems
;************************************************************************************************
; This procedure reads lines of information from a file, one per stratagem. Each line includes the
; name of the stratagem, a phrase that describes the stratagem, and a flag which describes
; whether or not the stratagem is checked and whether or not it can be modified by the user.
;
compile_opt strictarr
;
; Open the file.
openr,unit,filename,/get_lun
;
; Read the total number of strategems and the number of stratagems skipped if working with
; summed files.
readf,unit,n_stratagems,n_skipped_stratagems
sname=strarr(n_stratagems)
button_tags=strarr(n_stratagems)
modifiable=intarr(n_stratagems)
chars=""
;
; Read information for each stratagem.
for i=0,n_stratagems-1 do begin
	readf,unit,chars
	a=strsplit(chars," {2,}",/extract,/regex)
	if (n_elements(a) ne 4) then stop,"Error reading the file ",filename
	sname[i]=a[0]; this array is used to construct the structure "strategy".
	button_tags[i]=a[1]; this array is returned.
	modifiable[i]=fix(a[2]); this array is returned.
endfor
;
; Close the file.
free_lun,unit
;
; Construct a command that creates the structure named "strategy".
com="strategy={"
for i=0,n_stratagems-1 do begin
	com=com+sname[i]+":0"
	if (i lt n_stratagems-1) then com=com+"," else com=com+"}"
endfor
;
; Execute the command.
result=execute(com)
;
end