COMPILE FUNCTION Program_Trace(CtrlEntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5,Parm6)

/* Commuter module for Program Trace window */

DECLARE SUBROUTINE Send_Event, Set_Property, obj_Appwindow, Set_Status, ErrMsg, Utility
DECLARE SUBROUTINE Btree.Extract, Send_Message
DECLARE FUNCTION Get_Property, Dialog_Box, Send_Message

$INSERT APPCOLORS


ReturnVal = ''

BEGIN CASE
	CASE Event = 'CREATE'												; GOSUB Create
	CASE CtrlEntID = @WINDOW:'.ON_OFF_BUTTON.ON' AND Event = 'CLICK'	; GOSUB OnClick
	CASE CtrlEntID = @WINDOW:'.ON_OFF_BUTTON.OFF' AND Event = 'CLICK'	; GOSUB OffClick
	CASE CtrlEntID = @WINDOW:'.VIEW_BUTTON' AND Event = 'CLICK'			; GOSUB View
	CASE CtrlEntID = @WINDOW:'.CLEAR_LOG' AND Event = 'CLICK'			; GOSUB ClearLog
	
	CASE 1	; DEBUG
	
END CASE


RETURN ReturnVal



* * * * * *
Create:
* * * * * *

obj_Appwindow('Create')		;* Setups up a statusline, centers the window and makes it visible


GOSUB Refresh

RETURN


* * * * * * *
Close:
* * * * * * *

							;* Stub for possible future routine
RETURN


* * * * * * *
OnClick:
* * * * * * *

OPEN 'PROGRAM_TRACE' TO FileIn THEN
	WRITE 1 ON FileIn,@STATION:'*FLAG' ELSE NULL
END

GOSUB Refresh

RETURN



* * * * * * *
OffClick:
* * * * * * *
OPEN 'PROGRAM_TRACE' TO FileIn THEN
	WRITE 0 ON FileIn,@STATION:'*FLAG' ELSE NULL
END

GOSUB Refresh

RETURN



* * * * * * *
View:
* * * * * * *

DEBUG


RETURN



* * * * * * *
Refresh:
* * * * * * *

CurrentStatus = XLATE('PROGRAM_TRACE',@STATION:'*FLAG','','X')

IF CurrentStatus = 1 THEN
	Set_Property(@WINDOW:'.TRACE_STATUS','TEXT','Tracing is On')
END ELSE
	Set_Property(@WINDOW:'.TRACE_STATUS','TEXT','Tracing is Off')
END

RETURN


* * * * * * *
ClearLog:
* * * * * * * 


OPEN 'PROGRAM_TRACE' TO FileIn THEN
	WRITE '' ON FileIn,@STATION:'*LOG' ELSE NULL
END

RETURN
