
! script name: operations.d/lastop

!A
!A NAME:
!A
!A 	Repeat Last Operation
!A
!A DESCRIPTION:
!A
!A	This script will repeat the last operation
!A 	performed in the system.
!A

stat=ChangeLabelStr("ScriptNameStatus","Function: repeat last operation")

COM /Ops_var_design/ Use_variational
DIM Answer$[256]
DIM Current_op$[256]

DeActivateUndo
IF ARGC<2 THEN
	Use_variational= 0
ELSE
	Use_variational= VAL(ARGV(1))
END IF

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

Num_tools= GetUserValue(OperData,"Number tools:")
Tool_group=FindNamedGrp("OPER TOOLS")
IF ValidGeometry(Tool_group) THEN
	True_num=GroupCount(Tool_group)
	IF True_num<>Num_tools THEN
		Stat= PutUserValue(OperData,"Current tool:",0)
		Stat= DeleteEntity(Tool_group)
		Tool_group= CreateGroup("OPER TOOLS")
	END IF
ELSE
	Stat= PutUserValue(OperData,"Current tool:",0)
        Tool_group= CreateGroup("OPER TOOLS")
END IF

Stat= GetUserString(OperData,"Operation script:",Answer$)
IF LEN(Answer$)>3 THEN
	LOAD Answer$
END IF

Leave:!
	LOAD "typecontrol"
END
