@{ps||Format Destruction List  3/8/77|}

@{ns|/|@@{pk|0d0a}}`            	set the string "/" to RETURN LINE-FEED`

@{ns|NFL|{`                           	Next File List`
	@{ns|files|@@{rs|@@{/}FILES: }}
	@{ss|files| |  }@{ns|files|@@{files|,|,},}`         	file list can be blank or comma delimited`
	@{NF}
}}

@{ns|NF|{`                  	Next File`
	@{in|files|,|
		{
			@{ns|source|@@{@in}}
			@{ps|||Source: @@{source}   }
			@{of|@@{source}||`                	open the current input file`
				{
					@{ns|b|}`                    	b holds one record of the input file`
					@{rf|b|1}
					@{ns|sourcern|@@{rn}}
					@{ns|sink|@@{source}f}`         	NOTE: file sequence number must be less than 10`
					@{of|@@{sink}||{@{df}}}`             destroy a pre-existing output file`
					@{mf|@@{sink}||{@{ps|FULL DISKETTE.|}@{ex}}}
					@{ns|sinkrn|0}`               	preset the next output record number`
					@{ps|Sink: @@{sink}||}
					@{ns|f|}`   	f is formatted output`
					@{GD}
				}|
				{@{ps|No such file.|}@{NF}}
			}
		}|
		{@{NFL}}
	}
}}

@{ns|GD|{`                                  	Get Date of destruction from first line of file`
	@{in|b|@@{/}|
		{
			@{ns|d-date|@@{@in}}
			@{NL}
		}|
		{@{ps|The input file is empty.|}@{NF}}
	}
}}

@{ns|NL|{`                              	Next Line.  format:`
	@{in|b|@@{/}|`               	  <prefix>_<number><revision>;<copy><series>`
		{`                                	where <prefix> may be "." or "._"`
			@{ns|l|@@{@in}}`                   	and <revision> may be null or "_rv_<integer>`
			@{ns|d|@@{in|l|;}}`                     	  ("_" is a space)`
			@{eq|@@{d}|/|`           	test for new page  -  "/" in a line`
				{
					@{ps||||@@{pk|0c}|||@@{sink}||}
				}|
				{
					@{ND}
					@{NCL}
				}
			}
		}|
		{@{READ}}`                  	no more full lines in b`
	}
	@{NL}
}}

@{ns|READ|{`                           	Read the next record. (More output than input.)`
	@{ns|b|@@{@in}}`                          	save the number of the next record to be written`
	@{cf}`                      	and close the output file`
	@{of|@@{source}|@@{sourcern}}`                   	open the source and set the next input record number`
	@{rf|b|1||{@{ps|READ ERROR.|}@{ex}}}`              	read the next record`
	@{ns|sourcern|@@{rn}}`              	save the number of the next input record`
	@{cf}`                       	and close the input file`
	@{of|@@{sink}|@@{sinkrn}}`             	reopen the output file where it was`
}}

@{ns|ND|{`                      	Next Document (or end)`
	@{eq|@@{gc|d|5}|\end\|
		{@{end}}|
		{
			@{cr|d}
			@{eq|@@{gc|d|1}|.|
				{@{ns|d|@@{p} @@{in|d}}}|
				{@{cr|d}}
			}
			@{ns|p|@@{in|d| }}@{ss|p|-|/}
			@{ns|n|@@{in|d| }}@{ss|n|-|/|^|=|.}
			@{ns|x|@@{in|d}}@{eq|@@{x}|||{@{RF}}}`        	construct the reference field`
			@{eq|@@{gc|p|3}|aaa|{@{AAA}}}
			@{ns|p..|@@{p}              }`           	document prefix will be left justified in columns 1-14`
			@{ns|n..|@@{n}              }`            	document number will be left justified in 15-28`
			@{ns|d|@@{gc|p..|14}@@{gc|n..|14}}`           	assemble prefix, number`
		}
	}
}}

@{ns|RF|{`                           	reference field`
	@{ss|x|draft|rev|vol|i|ii|iii|iv}
	@{ns|x| @@{x|dr|rv|vl|1|2|3|4}}
}}

@{ns|AAA|{`                     	special checks for prints`
	@{ns|n|@@{in|p}@@{n}}@{ns|p|@@{@gc}}`       	handle, for example. aaa75 123456`
	@{ns|n1|@@{gc|n|8}}
	@{ns|q1|@@{gc|n|1}|q2|@@{gc|n|1}}
	@{eq|@@{in|n}|||{@{ps|The following print number has been truncated.|}}}
	@{eq|@@{q1}|o|
		{
			@{ns|q1|0}
			@{eq|@@{q2}|o|{@{ns|q2|0}}}`         	change revision "oo" to "00" and "oa" to "0a"`

		}|
		{
			@{eq|@@{q2}|0|{@{ns|q2|0}}}`           	also change "a0" to "ao"`

		}
	}
	@{ns|n|@@{n1}@@{q1}@@{q2}}`        	reassemble the print number`
}}

@{ns|p1|       |p2|      |p3|     |p4|    |p5|   |p6|  |p7| |p8|}`	pad for eight column field`

@{ns|NCL|{`                      	Next Lopy Loop`
	@{ns|c|@@{in|l|;}}
	@{eq|@@{c}|||{
		@{NC}@{NCL}
	}}
}}

@{ns|NC|{`                        	Next Copy`
	@{ge|@@{gc|c}|5|`                   	assume no series or foreign number if > 5 chars.`
		{@{ns|c|@@{c}@@{p@@{gc|c}}}}|`   	left justify in one eight column field`
		{
			@{ns|c-n|@@{c}}@{ss|c-n|/|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z}`  copy number: remove letters`
			@{ns|c-s|@@{c}}@{ss|c-s|/|0|1|2|3|4|5|6|7|8|9}`	copy series: remove digits`
			@{ns|c|@@{c-n}@@{c@@{gc|c-n}}@@{c-s}@@{c@@{gc|c-s}}}`	left justify in two four column fields`
		}
	}
	@{ns|r|@@{d} s@@{c}copd  @@{d-date}@@{x}}`            	assemble the document`
	@{ps|@@{r}||}
	@{ns|f|@@{in|f}@@{r}@@{/}}`            	append to the unwritten part of the string f`
	@{wf|f|||{@{ps|WRITE ERROR.|}@{end}}}`            	write it to the output file buffer`
	@{ns|sinkrn|@@{rn}}`                   	and save the next output record number`
	@{ns|#d|@@{ad|@@{#d}|1}}
}}

@{ns|c0|    |c1|   |c2|  |c3| |c4|}`               	pad for four column fields`

@{ns|end|{
	@{ns|f|@@{in|f}end of file.  @@{#d} documents in @@{sink}@@{/}}
	@{wf|f|@@{pk|1a}||{@{ps|WRITE ERROR!|}}}
	@{cf||{@{ps|CLOSE ERROR!|}}}
	@{ns|#df|@@{in|d|,}}
	@{ps||End of file. @@{#df} documents in @@{in|d}|}
	@{eq|@@{#d}|@@{#df}||{@{ps|ERROR: found @@{#d} documents.|}}}
	@{NF}
}}

@{dd|#d}

@{eq|@@{fn}||`                               	see if this program was loaded by "cdl"`
	{@{NFL}}|
	{@{ns|files|@@{fn},}@{NF}}
}
