
! script name: operations.d/tools_holder

!A
!A NAME:
!A
!A 	Operation Tool Control
!A
!A DESCRIPTION:
!A
!A	This script will call the necessary scripts
!A	to load the operations tool information.
!A

stat=ChangeLabelStr("ScriptNameStatus","Function: operation tool control")

COM /Ops_var_design/ Use_variational
DIM Destination$[256],Answer$[256]
DIM File_name$[256]
DIM Dir$[256],Title$[256],Label$[256],Mask$[256]
DIM Toolid$[256]
DIM Namelist$[32000],Namelist2$[32000],Loadstr$[32000]
DIM Tool_type$[256],Tool_name$[256],Tool_grp$[256]
DIM Group_name$[256]
DIM Current_op$[256]

DeActivateUndo
Stat=NamedVarStr("current operation",WsSystemVars,"",Current_op$)
OperData=FindUserData(Current_op$,WsOperation)
IF NOT ValidGeometry(OperData) THEN Leave

Stat= DisplayMessage("RETRIEVING TOOL DATA ")

Curr_tool= 0
IF CheckUserField(OperData,Toolid$&"Current tool:",1) THEN
	Curr_tool=GetUserValue(OperData,"Current tool:")
END IF
Num_tools= GetUserValue(OperData,"Number tools:")

IF Num_tools AND Curr_tool<Num_tools THEN
	Curr_tool= Curr_tool+1
	Tool_group=FindNamedGrp("OPER TOOLS")
        Number= GroupCount(Tool_group)
        IF ValidGeometry(Tool_group) THEN
                FOR K= Curr_tool TO Number
                        Stat= RemoveFromGrp(Tool_group,K)
                NEXT K
        END IF
	
	Load_udata=FindUserData("OPER LOADER",WsGeneralString)
	IF ValidGeometry(Load_udata) THEN Stat= DeleteEntity(Load_udata)
	Loadstr$= "     OPERATION LOADER"&CHR$(10)&CHR$(10)
	Loadstr$= Loadstr$&"Which load: 1"&CHR$(10)
	Stat= GetUserString(OperData,"Tool "&VAL$(Curr_tool)&":",Toolid$)
	Stat= GetUserString(OperData,Toolid$&" script:",Destination$)
	Stat= PutUserValue(OperData,"Current tool:",Curr_tool)
	Cnt_load= 1
	FOR Tcount= Curr_tool+1 TO Num_tools
		Stat= GetUserString(OperData,"Tool "&VAL$(Tcount)&":",Toolid$)
		IF CheckUserField(OperData,Toolid$&" script:",1) THEN
			Stat= GetUserString(OperData,Toolid$&" script:",Answer$)
		ELSE
			Stat= GetUserString(OperData,Toolid$&" probe script:",Answer$)
		END IF
		Loadstr$= Loadstr$&"Load "&VAL$(Cnt_load)&": "&Answer$&CHR$(10)
		Cnt_load= Cnt_load+1
	NEXT Which_load
	Loadstr$= Loadstr$&"Load "&VAL$(Cnt_load)&": operations.d/maketool"
	Loader=ReadUserData(WsGeneralString,"OPER LOADER",Loadstr$)
	LOAD Destination$
END IF

Load_udata=FindUserData("OPER LOADER",WsGeneralString)
IF ValidGeometry(Load_udata) THEN Stat= DeleteEntity(Load_udata)
LOAD "operations.d/toolholder"

Leave:!
LowerSelectBox
Load_udata=FindUserData("OPER LOADER",WsGeneralString)
IF ValidGeometry(Load_udata) THEN Stat= DeleteEntity(Load_udata)
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END

