
! script name: operations.d/standardoper
! topic: read operation

!A
!A NAME:
!A
!A 	General Operation Control
!A
!A DESCRIPTION:
!A	
!A	Hole Operations are the non-variational version of Hole Features.
!A	They are used for multiple tool operations at a single point.
!A	Unlike hole features they do not have parameters or variables
!A	to change. Operations are totally controled by an ASCII file.
!A	Operations files are located in:
!A		C:/usr/weber/util/tooldata/operations2_in or _mm
!A	They may be customized by the user or users may contract
!A	Weber systems to build custom operations.
!A	
!A~ image location - images/holefeature_tap.jpg
!A~ image location - images/holefeature_lp.jpg
!A
!A	This script will call the necessary scripts to load the operation
!A 	information from a certain directory.  The operation directory is
!A	passed directly into the script as ARGV(1).
!A	A particular operation name may be selected via ARGV(3).
!A	ARGV(2) controls variational design.
!A

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

COM /Ops_var_design/ Use_variational
DIM Description$[256],Destination$[256],Answer$[256],Dir$[1024]
DIM File_name$[256],Tldir$[1024],Ques$[256],Mask$[256]
DIM Namelist$[32000],Op_names$[512]
DIM Current_op$[256]
DIM Namelist2$[32000],Check_flexops$[32000]

DeActivateUndo
Stat=NamedVarStr("current operation",WsSystemVars,"",Current_op$)
IF Current_op$="" THEN Current_op$="OPERATION DATA"
IF ARGC<2 THEN LOAD "operations.d/operationctrl"

IF ARGC<3 THEN
	IF ARGV(1)="user_defined" THEN LOAD "operations.d/operationctrl:0,"&ARGV(1)
	Use_variational= 0
ELSE
	IF ARGV(1)="user_defined" THEN LOAD "operations.d/operationctrl:"&ARGV(2)&","&ARGV(1)
	Use_variational= VAL(ARGV(2))
END IF

Stat=SetInputFormat("a99","")
Material=FindUserData("MATERIAL",WsMaterial)
IF NOT ValidGeometry(Material) THEN
        Stat= NamedVarStr("material dir",WsSystemVars,"/usr/weber/util/tooldata/materials/",Dir$)
        Stat=DirectoryNames(Dir$,"*",Namelist$)
        Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
	Stat=GeneralListBox("MATERIALS DIRECTORY","MATERIALS SELECTED",Namelist2$)
        Stat=GetValue("INPUT MATERIAL FILE NAME",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
        File_name$= FileNameString(Dir$,Answer$)
        Material=ReadUserData(WsMaterial,"MATERIAL",File_name$)
END IF
LowerSelectBox

Stat= NamedVarStr("operations dir",WsSystemVars,"/usr/weber/util/tooldata/operations2_in/",Dir$)
Dir$= FileNameString(Dir$,ARGV(1))
IF NOT DoesFileExist(Dir$) THEN Leave

Pick_direct:!
IF ARGC<4 THEN
	Stat=DirectoryNames(Dir$,"*",Namelist$)
	Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
	Stat=GeneralListBox("OPERATIONS","OPERATION SELECTED",Namelist2$)

	Stat=GetValue("INPUT OPERATION ",Answer$)
	IF ExitScript(Destination$) OR Answer$="CANCEL" THEN Leave
	LowerSelectBox
ELSE
	Answer$=ARGV(3)
END IF
 
Misc_group=GrpFindUserData("MISCELLANEOUS DATA TRANSFER",WsMiscData)
IF ValidGeometry(Misc_group) THEN Stat= DeleteGroup(Misc_group,1)

Op_group=GrpFindUserData("OPERATION DATA",WsOperation)
IF ValidGeometry(Op_group) THEN Stat= DeleteGroup(Op_group,1)

MiscData=ReadUserData(WsMiscData,"MISCELLANEOUS DATA TRANSFER",FileNameString(Dir$,Answer$))
IF NOT ValidGeometry(MiscData) THEN Leave

Stat=SetInputFormat("n4","")
Stat=UserDataString(MiscData,Check_flexops$)
IF POS(Check_flexops$,"SELECT") THEN
	LOAD "scenarios.d/checkselects:operations.d/loadoperdata"
ELSE
	LOAD "operations.d/loadoperdata"
END IF

Leave:!
LowerSelectBox
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END

