
! script name: turbopost.d/seqholes
! topic: TurboPost sequential holes

!A
!A NAME:
!A
!A 	SEQUENTIAL HOLES
!A
!A DESCRIPTION:
!A
!A 	This script allows holes to be picked sequentially for a TurboPost
!B 	canned cycle command.  For example, Drilling, Boring and Tapping.
!A
!B INSTRUCTIONS:
!B
!B 	PICK STARTING HOLE, Non-sequential, Group, Manual, Proceed: Pick the
!B 		first hole to be used for the specified canned cycle command.
!B 		NOTE: The following options exit from this script and load
!B 		the appropriate script to execute the selected option.
!B
!B 		N - Non-sequential allows the holes to be picked in any order,
!B 		    one at a time, other than the way the holes were defined.
!B 		G - Group allows a predefined group of holes to be selected
!B 		    to be used for the specified command.
!B 		M - Manual allows the user to input the X and Y point 
!B 		    coordinates in TurboPost without creating geometry.
!B 		MZ - This option allows the user to input the X,Y,Z point
!B 		    coordinates in TurboPost without creating geometry.  This
!B 		    option does not appear in the input line, the "MZ" must be
!B 		    entered manually.
!B 		P - Proceed returns to the command menu for another selection
!B 		    to be made.
!B
!B 	PICK ENDING HOLE: Pick the last hole to be used for the specified
!B 		canned cycle command.  This question only appears if a hole
!B 		was picked.  All holes that were defined between the first
!B 		hole selected and the last hole selected will be used in the
!B 		order they were defined for the specified canned cycle command.
!B
!# see also - htdocs/help.d/millturbo.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: sequential holes ")

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


DeActivateUndo
Pick_loop:!

Active=ActivePostName(Answer$)
IF NOT Active THEN Leave

Stat=MakeActiveCurr

Stat=CurrActionName(Command$)
Command_type=CurrActionTyp

Stat=SetPickMask(WsPickHoles)
Stat=SetInputFormat("a6",",P,M,N,MZ,G,CANCEL,")
Hs=PickEntity("PICK STARTING HOLE, Non-sequential, Group, Manual, Proceed",Answer$)
IF (ExitScript(Destination$)) THEN Leave

SELECT Answer$
CASE "CANCEL"
	LOAD "turbopost.d/turbocmd"
CASE "P","p"
	GOTO New_command
CASE "N","n"
	  LOAD "turbopost.d/nonseqholes"
CASE "M","m"
	  LOAD "turbopost.d/manualhole"
CASE "MZ","mz"
	  LOAD "turbopost.d/manualzhole"
CASE "G","g"
	  LOAD "turbopost.d/pickholegrp"
END SELECT

Start_hole=HoleNumber(Hs)
IF (Start_hole=0) THEN Pick_loop

Stat=SetPickMask(WsPickHoles)
Stat=SetInputFormat("a6",",CANCEL,")
He=PickEntity("PICK ENDING HOLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="CANCEL" THEN LOAD "turbopost.d/turbocmd"

End_hole=HoleNumber(He)
IF (End_hole=0) THEN Pick_loop
 
IF POS(Command$,"MACRO:") OR POS(Command$,"TEMPLATE:") THEN
	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$&" Start_hole="&VAL$(Start_hole)&";"
	A$=A$&" End_hole= "&VAL$(End_hole)&";"
	Stat=OutputCmdBuff(A$,0)

END IF
IF Command_type=TpMillHole THEN New_command
GOTO Pick_loop

New_command: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
