
! script name: turbopost.d/nonseqholes
! topic: TurboPost non-sequential holes

!A
!A NAME:
!A
!A 	Non-sequential holes
!A
!A DESCRIPTION:
!A
!A 	This script allows holes to be picked in any order (non-sequential),
!A 	regardless of how they were defined.
!A
!B INSTRUCTIONS:
!B
!B 	PICK HOLE, Sequential, Group, Manual, Proceed: Pick the holes in the
!B 		order in which they are to be used.  NOTE: The following
!B 		options exit from this script and load the appropriate script
!B 		to execute the selected option.
!B
!B 		S - Sequential allows the first and last holes of a sequence
!B 		    to be picked.  The canned cycle command file will use the
!B 		    holes picked and all holes that were defined between the
!B 		    two selected holes in the order 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.
!B 		    This option does not appear in the input line, the "MZ"
!B 		    must be entered manually.
!B 		P - Proceed returns to the command menu for another selection
!B 		    to be made.
!B
!# see also - htdocs/help.d/millturbo.htm

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

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


DeActivateUndo
First=1
Pick_loop:!

Stat=MakeActiveCurr

Stat=CurrActionName(Command$)
Command_type=CurrActionTyp

Stat=SetPickMask(WsPickHoles)
Stat=SetInputFormat("a6",",P,M,S,G,MZ,CANCEL,")
Hs=PickEntity("PICK HOLE, 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 "S","s"
	  LOAD "turbopost.d/seqholes"
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

IF NOT First THEN
	IF Start_hole=Last_hole THEN New_command
END IF
Last_hole=Start_hole
First=0

IF POS(Command$,"MACRO:") OR POS(Command$,"TEMPLATE:") THEN
	A$="ASSIGN:"&"   Start_hole= "&VAL$(Start_hole)&";"&"   Holestartpt"
	Stat=OutputCmdBuff(A$,0)
	Stat=OutputCmdBuff(Command$,0)
ELSE

	A$=Command$&" Start_hole="&VAL$(Start_hole)&";"
	Stat=OutputCmdBuff(A$,0)

END IF
IF Command_type=TpMillHole THEN New_command
IF Command_type=TpLatheHole THEN New_command
IF Command_type=Tpxypoint THEN New_command
IF Command_type=Tpxyzpoint 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
