COMPILE FUNCTION Comm_RDS_Test_Prop(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)

/*
	Commuter module for RDS_Prop (Product Specification Property) window
	
	10/1/2012 - John C. Henry, J.C. Henry & Co., Inc.
	
*/

DECLARE SUBROUTINE Set_Property,  Set_Status, ErrMsg, Set_Property, obj_AppWindow, Security_Err_Msg, Forward_Event
DECLARE SUBROUTINE Send_Event
DECLARE FUNCTION Get_Property, Get_Status, Popup, Send_Message, Msg, Security_Check, obj_Popup

$INSERT POPUP_EQUATES
$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT PRS_LAYER_EQU
$INSERT PRS_PROP_EQUATES
$INSERT SECURITY_RIGHTS_EQU

EQU CRLF$	TO \0D0A\

ErrTitle = 'Error in Comm_RDS_Test_Prop'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CLEAR'			; GOSUB Clear
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Close
			CASE Event = 'DELETE'			; GOSUB Delete
			CASE Event = 'READ'				; GOSUB Read
			CASE Event = 'WRITE'			; GOSUB Write
			CASE Event = 'QBFRUN'			; GOSUB Read			;* triggers SetConversion same as the Read event does
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
	
	CASE EntID = @WINDOW:'.RAW_MIN'			AND Event = 'LOSTFOCUS'	; GOSUB MinLF
	CASE EntID = @WINDOW:'.RAW_MAX'			AND Event = 'LOSTFOCUS'	; GOSUB MaxLF
	
	CASE EntID = @WINDOW:'.LU_PROPERTY' 		AND	Event = 'CLICK'	; GOSUB LUProperty
	
	
	
	CASE 1
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		ErrMsg(ErrorMsg)
		
END CASE

IF ErrorMsg NE '' THEN
	ErrMsg(ErrTitle:@SVM:ErrorMsg)
END

RETURN Result


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

obj_Appwindow('Create',@WINDOW)

GOSUB Refresh

RETURN


* * * * * * *
Read:
* * * * * * *

GOSUB SetConversion
GOSUB Refresh


RETURN


* * * * * * *
Write:
* * * * * * *



*GOTO Close

RETURN


* * * * * * *
Clear:
* * * * * * *

Set_Property(@WINDOW,'@MIN_MAX_ICONV','')
Set_Property(@WINDOW,'@MIN_MAX_OCONV','')


GOTO Refresh

RETURN

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

obj_Appwindow('DetailReturn')

RETURN


* * * * * * *
Delete:
* * * * * * *

IF Security_Check('Prod Spec Property',Delete$) THEN
	IF Msg(@WINDOW,'','PRE_DELETE') THEN
		Result = 1
	END ELSE
		Result = 0		;* Stop event chain user bailed
	END
END ELSE
	Security_Err_Msg('Prod Spec Property',Delete$)
	Result = 0			;* Stop event chain user not worthy
END

RETURN


* * * * * * *
MinLF:
* * * * * * *


RETURN


* * * * * * *
MaxLF:
* * * * * * *


RETURN



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


* QBF buttons

Ctrls  = @WINDOW:'.QBF_FIRST_FIX':@RM		; Props  = 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_PREV_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_ABS_FIX':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_NEXT_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_LAST_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_STOP_FIX'			; Props := 'ENABLED'

IF Get_Property(@WINDOW,'QBFLIST') = '' THEN
	Vals = 0:@RM:0:@RM:0:@RM:0:@RM:0:@RM:0
END ELSE
	Vals = 1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1
END

Set_Property(Ctrls,Props,Vals)


RETURN


* * * * * * *
SetConversion:
* * * * * * *


* *  This section sets ICONV (VALID) and OCONV properties on the window controls based on the 
* *  Property Code for the record being read

PropCd = Get_Property(@WINDOW:'.PROP_CD','TEXT')

Conv = '[MET_PROP_CONV,':PropCd:']'

Ctrls  = @WINDOW:'.SPEC_RAW_MIN':@RM
Ctrls := @WINDOW:'.SPEC_RAW_TARGET':@RM			
Ctrls := @WINDOW:'.SPEC_RAW_MAX':@RM
Ctrls := @WINDOW:'.PROP_READING'

Set_Property(Ctrls,'CONV',Conv)
Set_Property(Ctrls,'VALID',Conv)

Ctrls = FIELD(Ctrls,@RM,1,3)

Vals = Get_Property(Ctrls,'TEXT')

IF NOT(INDEX(Vals,'.',1)) THEN

	* No decimal in display -> OCONV data being displayed
	
	Vals = OCONV(Vals,Conv)
	Set_Property(Ctrls,'TEXT',Vals)

	ReadArray = Get_Property(@WINDOW:'.PROP_READING','ARRAY')

	TestArray = ReadArray
	CONVERT @VM TO '' in TestArray

	IF TestArray NE '' THEN
		ReadArray = OCONV(ReadArray,Conv)
		Set_Property(@WINDOW:'.PROP_READING','ARRAY',ReadArray)
	END
END	;* End of check for displayed data in internal format


RETURN


* * * * * * *
LUProperty:
* * * * * * *

SelVal = Popup(@WINDOW,TypeOver,'MET_PROPERTY')

IF SelVal = CHAR(27) THEN RETURN


IF SelVal NE '' THEN
	obj_Appwindow('LUValReturn',SelVal:@RM:@WINDOW:'.PROP_CD':@RM:'')
END

RETURN
