 
! script name: amo.d/cmmdelete

!A
!A NAME:
!A
!A 	DELETE FROM CMM
!A
!A DESCRIPTION:
!A
!A 	NO HELP AVAILABLE AT THIS TIME
!A
!B INSTRUCTIONS:
!B
!B 	questions with brief description
!B
!B OPTIONS:
!B 	
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: delete from amo ")

DIM Answer$[256]
DIM Destination$[256]
DIM D_label$[64]
DIM Choice$[64]
DIM Namelist$[16000]
DIM Operations$[16000]
DIM Oper2$[16000]
DIM Name$[128]

DeActivateUndo
WsEventData= 12345

Oper_grp= FindNamedGrp("CMM TASKS")
IF NOT ValidGeometry(Oper_grp) THEN Leave

Operations$=""
Number= GroupCount(Oper_grp)
FOR I= 1 TO Number
	E1= GroupElement(Oper_grp,I)
	Stat= GetUserDataName(E1,Name$)
	Operations$= Operations$&Name$&","
NEXT I

List_box:!

D_label$= "TASKS LIST"
Choice$= "TASK TO DELETE"
Stat= GeneralListBox(D_label$,Choice$,Operations$)

Stat=SetInputFormat("a99","")
Stat=GetValue("CHOOSE TASK TO DELETE",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="CANCEL" THEN Leave

E1= FindUserData(Answer$,WsCMMProbeData)
IF NOT ValidGeometry(E1) THEN
	E1= FindUserData(Answer$,WsEventData)
	IF NOT ValidGeometry(E1) THEN List_box
END IF
Grp_pos= ElementGrpNum(Oper_grp,E1)
Stat= RemoveFromGrp(Oper_grp,Grp_pos)
Stat= RemoveFromList(Answer$,Operations$,Oper2$)
Operations$= Oper2$

Number= GroupCount(Oper_grp)
IF NOT Number THEN
	Stat= DeleteEntity(Oper_grp)
	GOTO Leave
END IF

GOTO List_box

Leave:!

LowerSelectBox
IF (NOT LEN(Destination$)) THEN
         LOAD "typecontrol"
ELSE
         LOAD Destination$
END IF
END
