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

/*
	Commuter module for PRS_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_PRS_Layer'
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[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 EntID = @WINDOW:'.LU_TOOL' 			AND	Event = 'CLICK'	; GOSUB DropDown
	CASE EntID = @WINDOW:'.LU_MET_WFR_TYPE' 	AND	Event = 'CLICK'	; GOSUB LUMetWfrType
	CASE EntID = @WINDOW:'.LU_RECIPE' 			AND	Event = 'CLICK'	; GOSUB DropDown
	CASE EntID = @WINDOW:'.LU_PATTERN'			AND	Event = 'CLICK'	; GOSUB LUPattern
	CASE EntID = @WINDOW:'.LU_PROVEIN_WFR_TYPE'	AND	Event = 'CLICK'	; GOSUB LUProveInWfrType
	CASE EntID = @WINDOW:'.LU_WAFER_TYPE'		AND	Event = 'CLICK'	; GOSUB DropDown
	
	
	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:
* * * * * * *

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

MinMaxIconv = obj_Popup('CodeDesc','MET_PROPERTY':@RM:PropCd:@RM:3)
MinMaxOconv = obj_Popup('CodeDesc','MET_PROPERTY':@RM:PropCd:@RM:4)

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


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:
* * * * * * *

Ctrls  = @WINDOW:@RM				; Props  = '@MIN_MAX_ICONV':@RM
Ctrls := @WINDOW:'.RAW_MIN':@RM		; Props := 'GOTFOCUS_VALUE':@RM
Ctrls := @WINDOW:'.RAW_MIN'			; Props := 'TEXT'

Vals = Get_Property(Ctrls,Props)

MinMaxIconv	= Vals[1,@RM]
GotFocusVal	= Vals[COL2()+1,@RM]
RawMin		= Vals[COL2()+1,@RM]

IF RawMin = GotFocusVal THEN RETURN

Min = ICONV(RawMin,MinMaxIconv)

IF Min = '' AND RawMin NE '' THEN
	ErrorMsg = QUOTE(RawMin):' is an invalid format.'
	ErrMsg(ErrorMsg)
END


IF Min NE GotFocusVal THEN
	Set_Property(@WINDOW:'.RAW_MIN','DEFPROP',Min)
	Send_Event(@WINDOW:'.MIN','CALCULATE')
END


RETURN


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

Ctrls  = @WINDOW:@RM				; Props  = '@MIN_MAX_ICONV':@RM
Ctrls := @WINDOW:'.RAW_MAX':@RM		; Props := 'GOTFOCUS_VALUE':@RM
Ctrls := @WINDOW:'.RAW_MAX'			; Props := 'TEXT'

Vals = Get_Property(Ctrls,Props)

MinMaxIconv		= Vals[1,@RM]
GotFocusValue	= Vals[COL2()+1,@RM]
RawMax			= Vals[COL2()+1,@RM]

IF GotFocusValue = RawMax THEN RETURN

Max = ICONV(RawMax,MinMaxIconv)

IF Max = '' AND RawMax NE '' THEN
	ErrorMsg = QUOTE(RawMax):' is an invalid format.'
	ErrMsg(ErrorMsg)
END

IF Max NE '' AND RawMax NE '' THEN
	Set_Property(@WINDOW:'.RAW_MAX','DEFPROP',Max)
	Send_Event(@WINDOW:'.MAX','CALCULATE')
END


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



* * * * * * *
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


* * * * * * *
LUPattern:
* * * * * * *

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

IF SelVal = CHAR(27) THEN RETURN

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

RETURN


* * * * * * *
LUMetWfrType:
* * * * * * * 

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

IF SelVal = CHAR(27) THEN RETURN

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

RETURN


* * * * * * *
LUUnits:
* * * * * * *

SelVal = Popup(@WINDOW,'','METROLOGY_UNITS')

IF SelVal = CHAR(27) THEN RETURN

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

RETURN


* * * * * * *
LUProveInWfrType:
* * * * * * *

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

IF SelVal = CHAR(27) THEN RETURN

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


RETURN


* * * * * * *
DropDown:
* * * * * * *


BEGIN CASE
	CASE EntID = @WINDOW:'.LU_TOOL'
		DisplayID = 'MEASURETOOL'
		Title	= 'Metrology Tools'
		RetCtrl	= 'TOOL'
		
	CASE EntID = @WINDOW:'.LU_TYPE'
		DisplayID = 'TYPE'
		Title	= 'Metrology ToolTypes'
		RetCtrl = 'TYPE'
		
	CASE EntID = @WINDOW:'.LU_RECIPE'
	
		Tool = Get_Property(@WINDOW:'.TOOL','DEFPROP')
		CONVERT @LOWER_CASE TO @UPPER_CASE IN Tool
		
		DisplayID = Tool:'_RECIPES'
		Title	= 'Metrology Tool Recipe'
		RetCtrl	= 'RECIPE'
	
		
	CASE EntID = @WINDOW:'.LU_WAFER_TYPE'
		DisplayID = 'PROVEIN'
		Title = 'ProveIn Wafer Types'
		RetCtrl = 'PROVEIN'
	
END CASE



**********************************

/*

ToolList = XLATE('LISTBOX_CONFIG',Type:'MEASURETOOL','','X')
CONVERT @VM TO @FM IN ToolList
Set_Property(@WINDOW:'.TOOL','LIST',ToolList)

Tool = Get_Property(@WINDOW:'.TOOL', 'TEXT' )
CONVERT @LOWER_CASE TO @UPPER_CASE IN Tool

RecipeList = XLATE( 'LISTBOX_CONFIG', Tool:'_RECIPES', '', 'X' )
CONVERT @VM To @FM IN RecipeList

IF RecipeList NE '' THEN
	Set_Property(@WINDOW:'.RECIPE','LIST',RecipeList)
END

RETURN 1

*/


********************

TypeOver = ''
TypeOver<PDISPLAY$> = XLATE('LISTBOX_CONFIG',DisplayID,1,'X')
TypeOVer<PTITLE$>	= Title

DEBUG

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

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