% The "Convert" Program
% This creates some widgets and does alot with them!
import GUI in "%oot/lib/GUI"
View.Set ("graphics:680;460,nobuttonbar,title:Degrees and Radians and Gradients!")
Window.Set (defWinID, "title:Degrees and Radians and Gradients!")
var degreesTextField, radiansTextField, gradientsTextField, degreesTextField_G, GradientsTextField, GradientsTextField_D : int
var RadiansTextField_G, gradientsTextField_G, GradientsTextField_R, gradientsTextField_R : int
const pi := 3.1415926535
const grad := 1.1111111111
%DEGREES TO RADIANS
%------------------------------------------------------------
%------------------------------------------------------------
proc DegreesToRadians
var degrees : string := GUI.GetText (degreesTextField)
if strrealok (degrees) then
var radians : real := (strreal (degrees) * pi / 180)
GUI.SetText (radiansTextField, realstr (radians, 1))
end if
end DegreesToRadians
proc DegreesToRadians1 (dummy : string)
DegreesToRadians
end DegreesToRadians1
%RADIANS TO DEGREES
%------------------------------------------------------------
%------------------------------------------------------------
proc RadiansToDegrees
var radians : string := GUI.GetText (radiansTextField)
if strrealok (radians) then
var degrees : real := ((strreal (radians)) * 180 / pi)
GUI.SetText (degreesTextField, realstr (degrees, 1))
end if
end RadiansToDegrees
proc RadiansToDegrees1 (dummy2 : string)
RadiansToDegrees
end RadiansToDegrees1
%DEGREES TO GRADIENTS
%------------------------------------------------------------
%------------------------------------------------------------
proc DegreesToGradients
var degrees1 : string := GUI.GetText (degreesTextField_G)
if strrealok (degrees1) then
var gradients := (strreal (degrees1) * 100 / 90)
GUI.SetText (GradientsTextField_D, realstr (gradients, 1))
end if
end DegreesToGradients
proc DegreesToGradients1 (dummy3 : string)
DegreesToGradients
end DegreesToGradients1
%GRADIENTS TO DEGREES
%------------------------------------------------------------
%------------------------------------------------------------
proc GradientsToDegrees
var gradients : string := GUI.GetText (GradientsTextField_D)
if strrealok (gradients) then
var degrees1 : real := ((strreal (gradients)) * 90 / 100)
GUI.SetText (degreesTextField_G, realstr (degrees1, 1))
end if
end GradientsToDegrees
proc GradientsToDegrees1 (dummy4 : string)
GradientsToDegrees
end GradientsToDegrees1
%RADIANS TO GRADIENTS
%------------------------------------------------------------
%------------------------------------------------------------
proc RadiansToGradients
var Radians : string := GUI.GetText (RadiansTextField_G)
if strrealok (Radians) then
var gradients2 : real := ((strreal (Radians) * 180 / pi) * 100 / 90)
GUI.SetText (RadiansTextField_G, realstr (gradients2, 1))
end if
end RadiansToGradients
proc RadiansToGradients1 (dummy5 : string)
RadiansToGradients
end RadiansToGradients1
%GRADIENTS TO RADIANS
%------------------------------------------------------------
%------------------------------------------------------------
proc GradientsToRadians
var gradients4 : string := GUI.GetText (GradientsTextField_R)
if strrealok (gradients4) then
var radians2 : real := (((strreal (gradients4)) * 90 / 100) * pi / 180)
GUI.SetText (GradientsTextField_R, realstr (radians2, 1))
end if
end GradientsToRadians
proc GradientsToRadians1 (dummy6 : string)
GradientsToRadians
end GradientsToRadians1
%****************************************************************
%************************** Seperation **************************
%****************************************************************
%----------------------------------------------------------------
%------------------------ Radian Section ------------------------
%----------------------------------------------------------------
%Textfield for degrees reading
degreesTextField := GUI.CreateTextFieldFull (15, 330, 75, "",
DegreesToRadians1, GUI.INDENT, 0, 0)
%Create label for degrees field
var da1 : real := GUI.CreateLabelFull (25, 335 +
GUI.GetHeight (degreesTextField),
"Degrees", 50, 0, GUI.CENTER, 0)
%------------------------------------------------------------
%Create a text field for the radians reading
radiansTextField := GUI.CreateTextFieldFull (215, 330, 75, "",
RadiansToDegrees1, GUI.INDENT, 0, 0)
%Create a label for the radians field
var da2 : real := GUI.CreateLabelFull (225, 335 +
GUI.GetHeight (degreesTextField),
"Radians", 50, 0, GUI.CENTER, 0)
%------------------------------------------------------------
%Create a text field for the fahrenheight reading to degrees
var ToRadians := GUI.CreateButton (105, 340, 95, "Convert ->",
DegreesToRadians)
%Create a text field for the degrees reading to radians
var ToDegrees := GUI.CreateButton (105, 310, 95, "<- Convert",
RadiansToDegrees)
%--------------------------------------------------------------
%------------------- Gradient Section -------------------------
%--------------------------------------------------------------
%Textfield for Degrees/Gradients reading
degreesTextField_G := GUI.CreateTextFieldFull (15, 230, 75, "",
DegreesToGradients1, GUI.INDENT, 0, 0)
%Create label for degrees field
var ea1 : real := GUI.CreateLabelFull (25, 235 +
GUI.GetHeight (degreesTextField),
"Degrees", 50, 0, GUI.CENTER, 0)
%------------------------------------------------------------
%Create a text field for the gradients reading
GradientsTextField_D := GUI.CreateTextFieldFull (215, 230, 75, "",
DegreesToGradients1, GUI.INDENT, 0, 0)
%Create a label for the gradients field
var ea2 : real := GUI.CreateLabelFull (225, 235 +
GUI.GetHeight (degreesTextField),
"Gradients", 50, 0, GUI.CENTER, 0)
%------------------------------------------------------------
%Create a text field for the fahrenheight reading to degrees
var ToGradients_D := GUI.CreateButton (105, 240, 95, "Convert ->",
DegreesToGradients)
%Create a text field for the degrees reading to gradients
var ToDegrees_G := GUI.CreateButton (105, 210, 95, "<- Convert",
GradientsToDegrees)
%----------------------------------------------------------------
%----------------------- Rad/Grad Section -----------------------
%----------------------------------------------------------------
%Textfield for Radian/Gradients reading
RadiansTextField_G := GUI.CreateTextFieldFull (15, 130, 75, "",
RadiansToGradients1, GUI.INDENT, 0, 0)
%Create label for degrees field
var fa1 : real := GUI.CreateLabelFull (25, 135 +
GUI.GetHeight (degreesTextField),
"Radians", 50, 0, GUI.CENTER, 0)
%------------------------------------------------------------
%Create a text field for the gradients reading
GradientsTextField_R := GUI.CreateTextFieldFull (215, 130, 75, "",
GradientsToRadians1, GUI.INDENT, 0, 0)
%Create a label for the gradients field
var fa2 : real := GUI.CreateLabelFull (225, 135 +
GUI.GetHeight (degreesTextField),
"Gradients", 50, 0, GUI.CENTER, 0)
%------------------------------------------------------------
%Create a text field for the fahrenheight reading to degrees
var ToGradients_R := GUI.CreateButton (105, 140, 95, "Convert ->",
GradientsToRadians)
%Create a text field for the degrees reading to gradients
var ToRadians_G := GUI.CreateButton (105, 110, 95, "<- Convert",
RadiansToGradients)
%----------------------------------------------------------------
%------------------------ Final touches! ------------------------
%----------------------------------------------------------------
GUI.SetBackgroundColour (grey)
%Text label at the top (instruction)
var toptext1 : real := GUI.CreateLabelFull (150, 400 +
GUI.GetHeight (degreesTextField),
"This converts degrees, radians, and gradients, into each other!", 50, 0, GUI.CENTER, 0)
loop
exit when GUI.ProcessEvent
end loop
|