COMPILE ROUTINE PackReactStatusWin(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE Send_Dyn,Send_Info
DECLARE FUNCTION Get_Status, Set_Printer



OPEN 'SYSREPOSWINS' TO RWFile ELSE GOTO Bail



BaseX = 92		;* Final position
BaseY = 82

*BaseX =102		;* Expanded position
*BaseY = 92



WindowName = 'REACT_STATUS_EVEN'	; ReactNo = 20

GOSUB Main


WindowName = 'REACT_STATUS_ODD'	; ReactNo = 21

GOSUB Main


GOTO Bail

* * * * * * *
Main:
* * * * * * *

READ WinStruct FROM RWFile,'LSL2**':WindowName ELSE
	GOTO Bail
END

Size = FIELD(Winstruct,@RM,1)
Win = FIELD(Winstruct,@RM,2)
Ctrls = FIELD(Winstruct,@RM,3)
Menu = FIELD(Winstruct,@RM,4)




ReactNos = ''

RModes = ''
RWOs = ''
RCusts = ''
Tims = ''
Escs = ''
RPanels = ''

Row = 1
FOR RNo = 1 TO 30
	Col = MOD(RNo,5)
	IF Col = 0 THEN Col = 5
	
	
	PanelX = ((Col - 1)*BaseX)
	PanelY = ((Row - 1)*BaseY)
	
	RModeX	= PanelX + 8	; RModey	= PanelY + 29
	RWoX	= PanelX + 12	; RWoY		= PanelY + 14
	RCustX	= PanelX + 11	; RCustY	= PanelY + 62
	TimX	= PanelX + 45	; TimY		= PanelY + 30
	EscX	= PanelX + 45	; EscY		= PanelY + 48
	
	LOCATE ReactNo IN ReactNos BY 'AR' USING @FM SETTING Pos ELSE
		ReactNos	= INSERT(ReactNos,Pos,0,0,ReactNo)
		RModes		= INSERT(RModes,Pos,1,0,RModeX:@VM:RModeY)
		RWOs		= INSERT(RWOs,Pos,1,0,RWoX:@VM:RWoY)
		RCusts		= INSERT(RCusts,Pos,1,0,RCustX:@VM:RCustY)
		Tims		= INSERT(Tims,Pos,1,0,TimX:@VM:TimY)
		Escs		= INSERT(Escs,Pos,1,0,EscX:@VM:EscY)
		RPanels		= INSERT(RPanels,Pos,1,0,PanelX:@VM:PanelY)
	END
		
	
	ReactNo += 2
	
	IF Col = 5 THEN Row += 1

NEXT RNo


OrgCtrls = Ctrls

CtrlCnt = COUNT(Ctrls,@FM) 

FOR I = 1 TO CtrlCnt
	Ctrl = Ctrls<I>
	
	Name	= Ctrl<1,1>
	BaseName = Name
	Reactor = BaseName[-2,2]
	
	LOCATE Reactor IN ReactNos USING @FM SETTING Offset ELSE
		NULL
	END
	
	BaseName[-2,2] = ''
	BEGIN CASE
		CASE BaseName = 'RPANEL'	; CalcPos = RPanels<Offset>	
		CASE BaseName = 'RMODE'		; CalcPos = RModes<Offset> 
		CASE BaseName = 'RWO'		; CalcPos = RWOs<Offset>
		CASE BaseName = 'RCUST'		; CalcPos = RCusts<Offset>
		CASE BaseName = 'TIM'		; CalcPos = Tims<Offset>
		CASE BaseName = 'ESC'		; CalcPos = Escs<Offset>
		CASE 1						; CalcPos = 'WTFO'
	END CASE
	
	SWAP @VM WITH ',' IN CalcPos
	
	X		= Ctrl<1,5>
	Y		= Ctrl<1,6>
	
	Send_Dyn(Name:' (':X:',':Y:') (':CalcPos:')')
	Ctrls<I,5> = CalcPos[1,',']
	Ctrls<I,6> = CalcPos[COL2()+1,',']
	IF BaseName NE 'RPANEL' THEN
		Ctrls<I,9> = Name
	END
	
NEXT I

Winstruct = FIELDSTORE(Winstruct,@RM,3,0,Ctrls)

WRITE WinStruct ON RWFile,'LSL2**':WindowName ELSE
	GOTO Bail
END


RETURN


* * * * * * * 
Bail:
* * * * * * *


END
