
! script name: turbopost.d/pickholegrp
! topic: select predefined group of holes for TurboPost canned cycle operation

!A
!A NAME:
!A
!A 	GROUP (PICK HOLE GROUP)
!A
!A DESCRIPTION:
!A
!A 	This script allows a predefined group of holes to be selected for a
!A 	canned cycle operation by picking one of the holes in the group.  This
!A 	script is accessed by selecting the "Group" option when it appears.
!A
!B INSTRUCTIONS:
!B
!B 	PICK HOLE GROUP, Proceed: Pick a hole that is a member of a defined
!B 		group.  All holes that are a member of the picked group will
!B 		be used in the order they appear in the group.
!B
!# see also - htdocs/help.d/millturbo.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: group (pick hole group) ")

DIM Destination$[256]
DIM Answer$[256]
DIM Command$[256]
DIM A$[256]
DIM Name$[256]


DeActivateUndo
Pick_loop:!

Stat=MakeActiveCurr

Stat=CurrActionName(Command$)
Command_type=CurrActionTyp

Stat=SetInputFormat("a6=",",P,CANCEL,")
Stat=SetEqualsValue(0,"P")
Hole_group=PickGroupEnt("PICK HOLE GROUP, Proceed",0,Answer$)
IF (ExitScript(Destination$)) THEN Leave

SELECT Answer$
CASE "CANCEL"
	LOAD "turbopost.d/turbocmd"
CASE "P","p"
	GOTO New_command
END SELECT
IF NOT ValidGeometry(Hole_group) THEN Pick_loop

Stat=Highlight(Hole_group,WsPickPen,WsDirArrowOff)

Output_group:!
Stat=GroupName(Hole_group,Name$)
A$="ASSIGN: Group_name= "&CHR$(34)&Name$&CHR$(34)&";"
Stat=OutputCmdBuff(A$,0)
A$="ASSIGN: Groupon"
Stat=OutputCmdBuff(A$,0)
IF (POS(Command$,"MACRO:")) OR (POS(Command$,"TEMPLATE:")) THEN
	Start_hole= 1
	End_hole= GroupCount(Hole_group)
        Istep=(End_hole>=Start_hole)-(Start_hole>End_hole)
        FOR I=Start_hole TO End_hole STEP Istep
                A$="ASSIGN:"&"   Start_hole= "&VAL$(I)&";"&"   Holestartpt"
                Stat=OutputCmdBuff(A$,0)
                Stat=OutputCmdBuff(Command$,0)
        NEXT I
ELSE
	A$= Command$&"   Allholes"
	Stat=OutputCmdBuff(A$,0)
END IF
Did_something= 1

IF Command_type=TpHoleGroup THEN New_command
GOTO Pick_loop


New_command:!
IF Did_something THEN
	A$="ASSIGN: Groupoff"
	Stat=OutputCmdBuff(A$,0)
END IF

UpdateCmdFile
Stat=SetPickMask(WsPickAll)
Stat=SetInputFormat("n4=","")
LOAD "turbopost.d/turbocmd"

Leave:!
IF (NOT LEN(Destination$)) THEN
	  LOAD "typecontrol"
ELSE
	  LOAD Destination$
END IF
END
