Delphi

Back       

Delphi is based on the programming language structure of Pascal which had existed for many years since the late 80's.    Codes here-in are tested to be working, as follows:

 

Basic Floating Display


syntax: 

  FloatToStrF (variable, display type, Size, Precision);


ex.: 

  FloatToStrF(CDSXYXAmount.value, ffnumber, 15, 2);


{ Close the current active window }


procedure TForm1.Button6Click(Sender: TObject);

begin

  Close;

end;


{ test to dermine IF the Edit Text field is empty or not EmptyStr is a  

  reserved command }


procedure TForm1.Edit1Change(Sender: TObject);

begin

   if Edit1.Text = EmptyStr then

      Button1.Enabled := false

   else

      Button1.Enabled := true;

end;


{ Add's the content of the Edit Text field to the Memo control }


procedure TForm1.Button1Click(Sender: TObject);

begin

   { add the text - appended at the end of the memo }

   Memo1.Lines.Add(Edit1.Text);


   { clear out the edit control text and move focus }

   Edit1.Clear;

   Edit1.SetFocus;

end;


{ load a text file to the Memo control }


procedure TForm1.Button3Click(Sender: TObject);

begin

    Memo1.Lines.LoadFromFile('chap15.txt');

end;


{ write the current content of the Memo control to the Text file }


procedure TForm1.Button4Click(Sender: TObject);

begin

   Memo1.Lines.SaveToFile('chap15.txt');

end;




{ Sorting a string list and dumping it to a Memo Control }


procedure TForm1.Button2Click(Sender: TObject);

var

   MemoStringList : TStringList;

begin

{ Sorting the lines in the memo control is almost as easy as  

  loading and saving to a text file...


  The Memo control's Lines property is an object of type  

   TStrings (like memo, combo boxes, radio group, etc.,)

}


        { create a TStringList object }

        MemoStringList := TStringList.create;

        try

        { add the contents of the memo to the NEW     

          TStringList object }

         MemoStringList.AddStrings(Memo1.Lines);

        { sort the string, clear the memo, and replace with the             sorted strings }

         MemoStringList.Sort;

         Memo1.Lines.Clear;

         Memo1.Lines.AddStrings(MemoStringList);

        finally

        { release the memory allocated for the string list }

         MemoStringList.Free;

        end;

end;


{ drop a Font dialog component to the current form and the     code below will access it  }


procedure TForm1.Button5Click(Sender: TObject);

begin

   { Dialog is active }

   if FontDialog1.Execute then

      Memo1.Font := FontDialog1.Font;

end;