// initcom2.sr
// shur
// October 4, 1976  12:55 AM


get "bravo1.df"
get "com.df"
get "msg.df"
get "rn1.df"
get "doc.df"
get "char.df"
get "display.df"
get "st.df"
get "vm.df"


// incoming procedures

external	[
	CdInit
	CsAppend
	substcom
	CiCloseCd
	yescom
	owindowcommands
	findjumpcoms
	olcompcs
	remarkcom
	timecom
	FCalcNum
	FCalc
	CalcOpt
	Bracket
	EncBracket
// 	HorizScroll
	Spy
	AbNoRepUndo
	MoveWwSys;
	]


// incoming statics

external	[
	mpchci
	vcinorepeat
	]


// outgoing procedures

external	[
	InitCom2
	]


// outgoing statics

// external


// local statics

// static


let InitCom2() be 
[

let cs = nil
let cd = vec lcdmax
let rgrid = vec 25

// Substitute
cd = CdInit(cd, 8, 69, rinil, true, false, 0)
rgrid ! 0 = 8;	rgrid ! 1 = 50
CsAppend(cd, "MN", "", lv substcom, 0, rgrid, 2)
CiCloseCd(cd, $s)

// Yes
cd = CdInit(cd, 11, rinil, rinil, true, false, 0)
rgrid ! 0 = 11;	rgrid ! 1 = 50
rgrid ! 2 = 83;	rgrid ! 3 = 50
rgrid ! 4 = 82;	rgrid ! 5 = 50
rgrid ! 6 = 39;	rgrid ! 7 = 50
rgrid ! 8 = 81;	rgrid ! 9 = 50
rgrid ! 10 = 49;	rgrid ! 11 = 50
CsAppend(cd, "N", "", lv yescom, 0, rgrid, 12)
CiCloseCd(cd, $y)

// K -(destroy)
cd = CdInit(cd, 22, rinil, rinil, true, false, 0)
rgrid ! 0 = 105;	rgrid ! 1 = 50
rgrid ! 2 = 108;	rgrid ! 3 = 50
rgrid ! 4 = 109;	rgrid ! 5 = 50
rgrid ! 6 = 110;	rgrid ! 7 = 50
rgrid ! 8 = 111;	rgrid ! 9 = 50
rgrid ! 10 = 213;	rgrid ! 11 = 50
rgrid ! 12 = 214;	rgrid ! 11 = 50
CsAppend(cd, "BO", "BO", lv owindowcommands, maxcdcb*dcbl+50,
	rgrid, 14)
CiCloseCd(cd, $k)

// Window
cd = CdInit(cd, 14, 48, rinil, true, false, 0)
rgrid ! 0 = 105;	rgrid ! 1 = 50
rgrid ! 2 = 108;	rgrid ! 3 = 50
rgrid ! 4 = 109;	rgrid ! 5 = 50
rgrid ! 6 = 110;	rgrid ! 7 = 50
rgrid ! 8 = 111;	rgrid ! 9 = 50
rgrid ! 10 = 213;	rgrid ! 11 = 50
rgrid ! 12 = 214;	rgrid ! 11 = 50
CsAppend(cd, "BO", "BO", lv owindowcommands, maxcdcb*dcbl+50, 
	rgrid, 14)
CiCloseCd(cd, $w)

// MoveWwSys
// cd = CdInit(cd, 233, rinil, rinil, true, false, 0)
// CsAppend(cd, "BO", "BO", lv MoveWwSys, maxcdcb*dcbl+50, 
// 	0, 0)
// CiCloseCd(cd, #200+$r)

// Find
cd = CdInit(cd, 6, 68, rinil, true, false, 0)
rgrid ! 0 = 6;	rgrid ! 1 = 50
rgrid ! 2 = 83;	rgrid ! 3 = 50
rgrid ! 4 = 82;	rgrid ! 5 = 50
rgrid ! 6 = 39;	rgrid ! 7 = 50
rgrid ! 8 = 81;	rgrid ! 9 = 50
rgrid ! 10 = 49;	rgrid ! 11 = 50
CsAppend(cd, "MN", "", lv findjumpcoms, 0, rgrid, 12)
CiCloseCd(cd, $f)

// Jump
cd = CdInit(cd, 7, 68, rinil, true, false, 0)
rgrid ! 0 = 7;	rgrid ! 1 = 50
rgrid ! 2 = 83;	rgrid ! 3 = 50
rgrid ! 4 = 82;	rgrid ! 5 = 50
rgrid ! 6 = 39;	rgrid ! 7 = 50
rgrid ! 8 = 81;	rgrid ! 9 = 50
rgrid ! 10 = 49;	rgrid ! 11 = 50
CsAppend(cd, "MN", "", lv findjumpcoms, 0, rgrid, 12)
CiCloseCd(cd, $j)

// Look
cd = CdInit(cd, 20, 21, rinil, true, true, $l)
rgrid ! 0 = 39;   rgrid ! 1 = 50
rgrid ! 2 = 125;  rgrid ! 3 = 50
rgrid ! 4 = 126;	rgrid ! 5 = 50
rgrid ! 6 = 127;	rgrid ! 7 = 50
rgrid ! 8 = 148;	rgrid ! 9 = 50	// "No default available - "
rgrid ! 10 = 20;	rgrid ! 11 = 50
rgrid ! 12 = 218;	rgrid ! 13 = 50
CsAppend(cd, "BMP", "B", lv olcompcs, 150, rgrid, 14)
CiCloseCd(cd, $l)

// Z -(remark)
cd = CdInit(cd, 84, 72, rinil, false, false, 0)
CsAppend(cd, "MS", "S", lv remarkcom, 0, 0, 0)
CiCloseCd(cd, $z)

// Time
cd = CdInit(cd, 203, rinil, rinil, true, true,  $d, true )
CsAppend(cd, "MK", "K", lv timecom, 0, 0, 0)
CiCloseCd(cd, $t)

//calculator commands
// # -(number)
cd = CdInit(cd, 55, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalcNum, 0, rgrid, 8)
CiCloseCd(cd, $#)

// 0-9 and . same as #
let tci = mpchci ! $#
mpchci ! $0 = tci
mpchci ! $1 = tci
mpchci ! $2 = tci
mpchci ! $3 = tci
mpchci ! $4 = tci
mpchci ! $5 = tci
mpchci ! $6 = tci
mpchci ! $7 = tci
mpchci ! $8 = tci
mpchci ! $9 = tci
mpchci ! $. = tci


// +
cd = CdInit(cd, 56, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalc, 0, rgrid, 8)
CiCloseCd(cd, $+)

// = same as +
mpchci ! $= = mpchci ! $+

// -
cd = CdInit(cd, 64, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalc, 0, rgrid, 8)
CiCloseCd(cd, $-)

// *
cd = CdInit(cd, 58, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalc, 0, rgrid, 8)
CiCloseCd(cd, $**)

// . same as *
mpchci ! $← = mpchci ! $**

//  /
cd = CdInit(cd, 59, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalc, 0, rgrid, 8)
CiCloseCd(cd, $/)

//  %
cd = CdInit(cd, 63, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalc, 0, rgrid, 8)
CiCloseCd(cd, $%)


//  \ -(enter)
cd = CdInit(cd, 60, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalc, 0, rgrid, 8)
CiCloseCd(cd, $\)

//  ~ -(exchange)
cd = CdInit(cd, 62, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalc, 0, rgrid, 8)
CiCloseCd(cd, $~)

//  ↑ -(cycle)
cd = CdInit(cd, 61, rinil, rinil, true, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv FCalc, 0, rgrid, 8)
CiCloseCd(cd, $↑)

//  c - (calculator options)
cd = CdInit(cd, 188, rinil, rinil, false, false, 0)
rgrid ! 0 = 114;  rgrid ! 1 = 50
rgrid ! 2 = 115;  rgrid ! 3 = 50
rgrid ! 4 = 116;	rgrid ! 5 = 50
rgrid ! 6 = 117;	rgrid ! 7 = 50
CsAppend(cd, "Mf", "", lv CalcOpt, 0, rgrid, 8)
CiCloseCd(cd, $c)



//  [ -(bracket)
cd = CdInit(cd, 187, rinil, rinil, true, true, $[)
CsAppend(cd, "MN", "", lv Bracket, 0, 0, 0)
CiCloseCd(cd, $[)
let tci = mpchci ! $[
mpchci ! ${ = tci
mpchci ! $( = tci
mpchci ! $< = tci
mpchci ! $' = tci
mpchci ! $" = tci

// ] (Enclosing Brackets)
cd = CdInit(cd, 210, rinil, rinil, true, true, $])
CsAppend(cd, "MN", "", lv EncBracket, 0, 0, 0)
CiCloseCd(cd, $])
//rgrid ! 0 = 212;	rgrid ! 1 = 50
//rgrid ! 2 = 25;	rgrid ! 3 = 210
//rgrid ! 4 = 25;	rgrid ! 5 = 211
let tci = mpchci ! $]
mpchci ! $} = tci
mpchci ! $> = tci
mpchci ! $) = tci

// X (spy)
cd = CdInit(cd, 226, rinil, rinil, false, false, 0)
CsAppend(cd, "BN", "BN", lv Spy, #4000, 0, 0)
CiCloseCd(cd, $x)


//  cinorepeat
cd = CdInit(cd, rinil, rinil, rinil, false, false, 0)
CsAppend(cd, "", "", lv AbNoRepUndo, 0, 0, 0)
vcinorepeat = CiCloseCd(cd, $u)

]