
! script name: turbopost.d/manualhole
! topic: input X,Y coordinates in TurboPost without creating geometry

!A
!A NAME:
!A
!A 	MANUAL
!A
!A DESCRIPTION:
!A
!A 	This script allows the user to input the X and Y point coordinates in
!A 	TurboPost, without creating geometry, to be used by the command file.
!A 	The picktypes, which are set in the users command file for a particular
!A 	post, are "X" and "x".  "X" allows multiple XY coordinate input, and
!A 	"x" allows only a single XY coordinate to be input.
!A
!B INSTRUCTIONS:
!B
!B 	INPUT ABS X,Y: Enter the X,Y coordinates of the point to be used by
!B 		the command file.  To return to the command menu, enter the
!B 		coordinates of the last point twice.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: manual ")

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


DeActivateUndo
Delta=0.001
First=1

Stat=MakeActiveCurr

Stat=CurrActionName(Command$)
Command_type=CurrActionTyp
Its_a_lathe=((Command_type=TpLathePoint)+(Command_type=TpLathePoints)+(Command_type=TpLatheHole)+(Command_type=TpLatheHoles))
Stat=SetXyzInput(WsXyzInput)
IF Its_a_lathe THEN Stat=SetXyzInput(WsLatheInput)

Pick_loop:!
Stat=SetPickMask(WsPickAll)
Stat=SetInputFormat("a6",",P,MZ,S,N,CANCEL,")
Pt=XyzInput("INPUT",WsXyOnly)
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"
END SELECT

X=XPointValue(Pt)
Y=YPointValue(Pt)
Z=ZPointValue(Pt)
Stat=DeleteEntity(Pt)
IF NOT First THEN
	Dist=ABS(X-Xr)+ABS(Y-Yr)+ABS(Z-Zr)
	IF (Dist<Delta) THEN New_command
END IF
Xr=X
Yr=Y
Zr=Z
First=0

X= PROUND(X,-4)
Y= PROUND(Y,-4)
Z= PROUND(Z,-4)

IF POS(Command$,"MACRO:") OR POS(Command$,"TEMPLATE:") THEN
	IF Its_a_lathe THEN
		A$="ASSIGN:"&" Zstart= "&VAL$(X)&";"&" Xstart= "&VAL$(Y)&";"
	ELSE
		A$="ASSIGN:"&" Xstart= "&VAL$(X)&";"&" Ystart= "&VAL$(Y)&";"
	END IF
ELSE
	IF Its_a_lathe THEN
		A$="ASSIGN:"&" Z= "&VAL$(X)&";"&" X= "&VAL$(Y)&";"
	ELSE
		A$="ASSIGN:"&" X= "&VAL$(X)&";"&" Y= "&VAL$(Y)&";"
	END IF
END IF
Stat=OutputCmdBuff(A$,0)
Stat=OutputCmdBuff(Command$,0)

IF (Command_type=TpMillxypoint) OR (Command_type=TpLathePoint) THEN New_command
IF Command_type=TpMillxyzpoint THEN New_command
IF (Command_type=TpMillHole) OR (Command_type=TpLatheHole) 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
