
! script name: ShapeCorp.d/shape_strategies
! topic: calls shape strategies

!A
!A NAME:
!A
!A 	Calls Shape Corp Turning strategies
!A
!A DESCRIPTION:
!A	
!A	This script will call the selected turning strategy
!A
!B INSTRUCTIONS:
!B
!B	CNC PROGRAM NUMBER:  This is the number of the cnc program.
!B			     If the number 5 is answered then
!B			     the cnc program file will be named O0005.
!B		             If a non-numeric answer is given then
!B			     that will be used for the name.
!B
!B
!# see also - htdocs/help.d/shape_help.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: calls shape strategies")

DIM Answer$[256]
DIM A$[256]
DIM B$[256]
DIM Prog_name$[256]
DIM Dir$[256]
DIM Destination$[256]
DIM Strategy_name$[256]

DEG
Strategy_name$= "Shape_ex_1_2"
IF ARGC>1 THEN
        Strategy_name$= ARGV(1)
END IF

Start:!
Turn_off_objects:!
Object_group= GrpByEntType(WsVarObjectEnt)
FOR I=1 TO GroupCount(Object_group)
Var_object= GroupElement(Object_group,I)
Stat= ObjectCalcToggle(Var_object,WsFalse)
NEXT I

Stat= RemoveFile("command_buffer")
Stat= RemoveFile("tapelist")
Stat= RemoveFile("timefile")
Stat= RemoveDirFiles("./","*","command_file")
Stat= RemoveDirFiles("./","*","notepad")
Stat= RemoveDirFiles("./","*","tapefile")
Stat= RemoveDirFiles("./","*","tapefil")

Ask_program_number:!
   Vcode_num= FindNamedVar("Cnc_code_number",WsVariationVars)
   IF ValidGeometry(Vcode_num) THEN
        Cnc_code_number= VariableValue(Vcode_num)+1
   ELSE
        Vcode_num= NumericVariable("Cnc_code_number",WsVariationVars,1.0)
        Cnc_code_number= 1
   END IF
Ask_number:   Stat=SetInputFormat("a99=","")
   A$=VAL$(Cnc_code_number)                                   
   Stat=SetEqualsValue(Cnc_code_number,A$)
   Stat=GetValue("CNC PROGRAM #",Answer$)
   IF (ExitScript(Destination$)) THEN Leave
   IF IsStringNumeric(Answer$) THEN
	Cnc_code_number=VAL(Answer$)
	IF Cnc_code_number<1 OR Cnc_code_number>7999 THEN Ask_number
	Prog_name$= VAL$(10000+Cnc_code_number)
	Prog_name$[1,1]="O"
   ELSE
	A$= TRIM$(Answer$)
	IF NOT LEN(A$) THEN Ask_number
	Prog_name$=A$
   END IF
   Vcode_num= NumericVariable("Cnc_code_number",WsVariationVars,Cnc_code_number)
   Vcode_num= CreateVariable("Cnc_program_name",WsVariationVars,Prog_name$)
`

Dir$="/usr/weber/database/strategies/shape.d/"
Name$="MATERIAL"
Material= FindUserData(Name$,WsMaterial)
IF NOT ValidGeometry(Material) THEN
  A$= "ShapeCorp.d/startpass:"&Dir$&Strategy_name$
  LOAD A$
  GOTO Leave
ELSE
   A$= UserDataStr(Material,"Material id name:")
   IF POS(A$,"(Hard)") THEN
      V1= NumericVariable("Hard_material",WsVariationVars,1)
   ELSE
      V1= NumericVariable("Hard_material",WsVariationVars,0)
   END IF
END IF

A$= "vstrategy.d/strategytools:"&Dir$&Strategy_name$
LOAD A$


Leave:!
LowerFileBox
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
