
! script name: vconics.d/parabola_equation
! var_topic: create parabola defined by the standard equation

!A
!A NAME:
!A
!A 	Parabola by standard equation   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script creates a parabola using the formula for a parabola:
!A
!A 		Y= AX^2+ BX+ C
!A
!A	This is a parabola with its axis parallel to the Y axis.
!A	The vertex is at X= -B/(2A) , Y= (4AC-B^2)/(4A)
!A
!B INSTRUCTIONS:
!B
!B 	A: Enter the value to be used for the A constant.
!B
!B 	B: Enter the value to be used for the B constant.
!B
!B 	C: Enter the value to be used for the C constant.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: parabola equation ) ")

DIM Answer$[256]
DIM Destination$[256]
DIM A_var$[256]
DIM B_var$[256]
DIM C_var$[256]
DIM Length_var$[256]
DIM Name$[256]
DEG


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

Length= 5.0

ActivateUndo
Parabola_loop:!
Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(A)
A=GetValue("A COEFFICIENT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_a_var= LastVariableInput(A_var$)

Stat=SetEqualsValue(B)
B=GetValue("B COEFFICIENT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_b_var= LastVariableInput(B_var$)

Stat=SetEqualsValue(C)
C=GetValue("C COEFFICIENT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_c_var= LastVariableInput(C_var$)

Stat=SetEqualsValue(Length)
Stat=SetInputFormat("n4=","")
Length=GetValue("LENGTH ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_len_var= LastVariableInput(Length_var$)
IF Length< 0.0001 THEN Leave


Stat= GenerateVarName(WsBSplineEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("PARABOLA: equation")
Stat= SetRecDelLastExec
IF No_a_var THEN
        V2= FreeParameter("A value",A)
ELSE
        V2= FreeParameter("A value",A_var$)
END IF
IF No_b_var THEN
        V3= FreeParameter("B value",B)
ELSE
        V3= FreeParameter("B value",B_var$)
END IF
IF No_c_var THEN
        V4= FreeParameter("C value",C)
ELSE
        V4= FreeParameter("C value",C_var$)
END IF
IF No_len_var THEN
	V1= FreeParameter("Length",Length)
ELSE
	V1= FreeParameter("Length",Length_var$)
END IF
E1=Parabola(V2,V3,V4,V1)
Stat= NameEntity(E1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("parabola")
Stat= AddItemToUndo(WsUBCreateMode,E1)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Parabola_loop

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