What are the difference between TP and delphi?

[b][red]This message was edited by gadda at 2005-10-9 8:7:59[/red][/b][hr]
When i first use delphi, i am confused.
Everyone says that it just likes TP, but i find it is not easy to handle, maybe i am a new user.
Can anyone give me some example,
1. what is the pattern of writing a program
2. Some basic functions
3. Websites about it

thanks,

Comments

  • : [b][red]This message was edited by gadda at 2005-10-9 8:7:59[/red][/b][hr]
    : When i first use delphi, i am confused.
    : Everyone says that it just likes TP, but i find it is not easy to handle, maybe i am a new user.
    : Can anyone give me some example,
    : 1. what is the pattern of writing a program
    : 2. Some basic functions
    : 3. Websites about it
    :
    : thanks,
    :
    In TP you mostly write traditional programs, while in Delphi you write event driven programs. This was the biggest hurdle for me when I switched.
    In a normal TP program The flow is much like this:
    [code]
    Initialize/read some variables
    Process the data
    Output the results
    (with possibly a loop)
    [/code]
    For most TP programs you write something like this:
    [code]
    Global variable/type declarations

    function/procedure Declarations

    begin
    Call Procedure
    Call Procedure
    Call Procedure
    Call Procedure
    etc.
    with possible some loop
    end.
    [/code]

    In Delphi however the flow is like this:
    [code]
    Initialize some variables
    repeat
    if UserCommand or WindowsCommand then
    begin
    Find out which command is given
    Call appropriate event procedure
    end;
    until EndProgram
    [/code]

    Delphi programmers only write specialized event procedures:
    [code]
    Global variable/type declarations

    Event Declarations
    [/code]
    The whole supporting program flow is written by the compiler and the user-interface comes directly from resources.
    Nearly all of these event declarations can be called at any moment in the flow of the program, and must thus be protected against wrong or none existing data.

    Also Delphi is highly object-orientated, more so than TP. If you don't know how to write and use objects, it is best that you use that first with TP.

    As for the basic functions, these are very similar to TP; but play less and less a role in Delphi, because many of their functions are augmented by using the objects. For example, suppose you want to display a text file. In TP this would be (no variables):
    [code]
    Assign();
    Reset();
    while not eof() do
    begin
    Readln()
    Writeln();
    end;
    Close();
    [/code]
    In Delphi it becomes:
    [code]
    Memo1.Lines.LoadFromFile('somefile.txt');
    [/code]
    This is because the TStrings object already can read an entire text file, and the TMemo object has a property to store lines of text.
    Because Delphi already has hundreds (if not thousands) of objects defined in itelf, the set of "basic" functions is huge to say the least. The set of reserved words remains more or less the same, so things like "for-do", "while-do" loops, "if-then", "case-of" statements are the same.

    As for websites, I don't know any which are really good, because I learned Delphi from the Help files and later on from the "Delphi Developer's Guide" by Teixeira and Pacheco.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion