 
! script name: amo.d/amodelete

!A
!A NAME:
!A
!A 	DELETE FROM AMO
!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$[32000]
DIM Operations$[32000]
DIM Oper2$[32000]
DIM Name$[128]

DeActivateUndo
WsEventData= 12345

Task_ent= FindUserData("AMO OPERATIONS",WsTaskPacket)
IF ValidGeometry(Task_ent) THEN
	Stat= MessageStringBox("CANNOT CREATE A LIST USING THIS FUNCTION"&CHR$(10)&" A VARIATIONALLY SORTED TASK LIST ALREADY EXISTS.","INCORRECT USAGE ERROR")
	GOTO Leave
END IF

Oper_grp= FindNamedGrp("AMO OPERATIONS")
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$= "OPERATIONS LIST"
Choice$= "OPERATION TO DELETE"
Stat= GeneralListBox(D_label$,Choice$,Operations$)

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

E1= FindUserData(Answer$,WsToolData)
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
