
! script name: parasolids.d/savesolidsfile
! solids: save a parasolids file

!A
!A NAME:
!A
!A 	Save Solid File
!A
!A DESCRIPTION:
!A
!A	This function will save the parasolid model contained
!A	in the current synergy session into a file with the suffix .X_T.
!A
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function:  save parasolids file ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[512]
DIM Dir$[512]
DIM Dir1$[512]
DIM Default$[512]
DIM D_label$[256],Sub_label$[256],F_label$[256],Choice$[256]
DIM Mask$[256],Space$[256],Jobname$[256]



Default$= "C:/usr/weber/ST/solids/"
Stat= NamedVarStr("solid file dir",WsSystemVars,Default$,Dir$)


Question:!
D_label$="DIRECTORY"
Sub_label$="SUB DIRECTORIES"
F_label$="FILES"
Choice$="FILE TO SAVE"
!   Mask$="[A-Za-z0-9]*"
Mask$= "Parasolid Files (*.x_t)|*.x_t||"
Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$,"Synergy")
Ques2:!
Stat=SetInputFormat("a99","")
Stat=GetValue("SAVE JOB AS: "&Space$,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NamedVarVal("save dirs",WsSystemVars,0) THEN V1=CreateVariable("solid file dir",WsSystemvars,PathNameDirectory(Answer$))

!  IF POS(Answer$," ") THEN
!           Space$= " (NO SPACES) "
!           GOTO Ques2
!  ELSE
!          Space$= " "
!  END IF
IF NOT POS(Answer$,"/") THEN
        Jobname$= FileNameString(Dir$,Answer$)
ELSE
        Testposr=1
        REPEAT
            Testpos=POS(Answer$[Testposr],"/")
            Testposr=Testposr+Testpos
        UNTIL (NOT Testpos)
        Namelen=LEN(Answer$)-Testposr+1

        IF NOT Namelen THEN Ques2
        Jobname$= Answer$
END IF
LowerFileBox


Name$= Jobname$
n1= POS(Name$,".x_t")
IF N1 THEN Name$= Name$[1,n1-1]
n1= POS(Name$,".X_T")
IF N1 THEN Name$= Name$[1,n1-1]


Stat= WPKSaveFile(Name$)


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