The user enters coefficients into input boxes on a form, called GetFunction
. Upon clicking an OK button on said form, the input is validated using TryStrToFloat. If all the input boxes are valid,
CreateGraphis called. As soon as an invalid input box is found,
CreateGraph` should not be called and the user should be able to fix their error.
procedure TfrmGetFunction.btnAddFunctionClick(Sender: TObject);
var
i : integer; // Loop counter.
begin
for i := 1 to 7 do
begin
CoefficientEdit[i].CoValid := CheckCoefficientBoxesValidInput(CoefficientEdit[i].CoEditBox);
if not CoefficientEdit[i].CoValid then // If any input box is invalid.
Exit;
end;
frmGraphingMode.CreateGraph; // Finally if all input boxes valid.
frmGetFunction.Visible := false;
frmGraphingMode.Visible := true;
end;
Any improvements that I could make? Perhaps removing the Exit may not be a bad idea?