// pressHardcopy.sr
// last modified September 16, 1977  5:55 PM
// RML November 4, 1977  2:53 PM fix PrintedBy problem
// RML January 4, 1978  1:20 PM defer PrintedBy processing
// Last modified October 25, 1979  12:25 PM by Taft

get "BRAVO1.DF";
get "ALTOFILESYS.D";
get "Q.DF";
get "PRESS.DF";
get "ST.DF";
get "DISPLAY.DF";
get "HO.DF"

// Incoming Procedures

external	[
	createsbtime
	PutWds
	sbToDl
	vsbToDl
	ReadCalendar
	readsel
	WritePressBufs
	];


// Incoming Statics

external	[
	Dl
	UserName
	fillInDA
	rgmaccp
	mpWwWwd
	dnbp
	dcpendofdoc
	vpep
	vslPrintBy
	];


// Outgoing Procedures

external	[
	pressDocumentDirectory
	]

// statics - outgoing
external	[
	macfsn
	]

// local statics - obscure !

static	[
	macfsn
	]


// P R E S S D O C U M E N T D I R E C T O R Y
//
let pressDocumentDirectory(pages,ho,
			noTrunc,beginPd,nRecsPd,ww) be
[
PutWds(pressPassWord,Dl)
	// next, total # records -- not record number !
PutWds((lv vpep>>PRESS.acfaCur)>>CFA.fa.pageNumber,Dl)

PutWds(pages+1,Dl)
PutWds(beginPd,Dl)	// beginning record, Part Directory
PutWds(nRecsPd,Dl)	// # records in Pd
PutWds(0,Dl)

let now = vec 2; ReadCalendar(now)
PutWds(now!0,Dl)
PutWds(now!1,Dl)
PutWds(1,Dl)		// first copy
PutWds(ho>>HO.ccopy,Dl)	// last copy

for i = 10 to 177b do PutWds(-1,Dl)	// not used

pressPageBreak(ww, ho)
	// That should do it !
WritePressBufs(Dl,vpep,noTrunc)
]

// P R E S S P A G E B R E A K
//
and pressPageBreak(ww, ho) be
[
let todcur = vec lntod;
ReadCalendar(todcur);

//get filename from black window
let wwgroup= (mpWwWwd!ww)>>WWD.wwgroup
let doc= (mpWwWwd!wwgroup)>>WWD.doc
let cpfirst= 0
let cplast= rgmaccp!doc - dcpendofdoc
let sbfname= vec maxLengthFnInWords
readsel(sbfname,doc,cpfirst,cplast,maxLengthFn)

test sbfname ne 0 ifso	// File Name
	[	// doctor cch to strip off control-A !
	sbfname>>SB.cch = sbfname>>SB.cch-1
	sbToDl(sbfname,52)
	]
ifnot	sbToDl("Unknown",52)

let tsl = vec 50
ExpandPrintby(tsl, lv ho>>HO.aslPrintBy)
vsbToDl(tsl, 32)

test todcur ne 0 ifso
	[
	let tsbtime = vec maxsbtime;
	tsbtime ! 0 = 0;
	createsbtime(tsbtime, todcur);
	sbToDl(tsbtime,40);
	]
ifnot  sbToDl("Unknown",40)
]

// E X P A N D  P R I N T  B Y
//
and ExpandPrintby(slDest, slSrc) be
[
slDest>>SL.cch = 0;
for tichSrc = 0 to slSrc>>SL.cch-1 do
	[ let tch = slSrc>>SL.ch↑tichSrc;
	test tch eq $$ ifso
		for tichUser = 0 to UserName>>SB.cch-1 do
			[ slDest>>SL.ch↑(slDest>>SL.cch) = UserName>>SB.ch↑tichUser;
			slDest>>SL.cch = slDest>>SL.cch+1;
			]
	ifnot
		[ slDest>>SL.ch↑(slDest>>SL.cch) = tch;
		slDest>>SL.cch = slDest>>SL.cch+1;
		];
	];
]

// The END of pressHardcopy.sr