Solved

Many Simple Questions

Posted on 2004-10-31
160 Views
Last Modified: 2010-04-05
what is exit For in delphi
(how to skip the for loop)
what is exit sub in delphi
(skip all the sub)
how to totally exit all the application?(not just one form)
how to Unload a form not just hide it?

how to know all the procedures of a specific component.
Like Forum, if you click (dblclick) you will get
procedure TForm1.FormCreate(Sender: TObject);

but how to get
procedure TForm1.FormDestroy(Sender: TObject);
and other things?

and what is Text1_KeyPress? and what is the ENTER BUTTOM
ie. how to lanch a procedure when someone clicks enter in a edit box?

whats the difference between Complie Project1, and Build Project1.

And what are these in Delphi:
App.Path = STRING
App.TaskVisible = Boolean
app.Title = STRING

In VB I used to creat a model and put the public subs and functions I creat there, where should I put the public subs and functions?
0
Question by:deathman5
    13 Comments
     
    LVL 7

    Assisted Solution

    by:sftweng
    --------------------------
     what is exit For in delphi
    (how to skip the for loop)
    Break (Continue skips within the for loop to the next iteration)
    --------------------------
    what is exit sub in delphi
    (skip all the sub)
    Exit
    ---------------------------
    how to totally exit all the application?(not just one form)
    In addition to displaying the exception message, which happens by default, the following code shuts down the application when an exception is not caught and handled.

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Application.OnException := AppException;

    end;

    procedure TForm1.AppException(Sender: TObject; E: Exception);

    begin
      Application.ShowException(E);
      Application.Terminate;
    end;
    ----------------------------------
    how to Unload a form not just hide it?
    Closes the form.

    procedure Close;

    Description

    Call Close to close a form.

    Attempts to close a form can be aborted by the CloseQuery event dispatcher or the OnCloseQuery event handler.

    Note:      When the main form of the application closes, the application terminates.
    ---------------------------------------
    how to know all the procedures of a specific component.
    Like Forum, if you click (dblclick) you will get
    procedure TForm1.FormCreate(Sender: TObject);

    but how to get
    procedure TForm1.FormDestroy(Sender: TObject);
    and other things?

    The Object Inspector Events tab allows you to double-click to create event handlers for the form.

    Otherwise, look at Delphi Help for TForm for the Properties, Methods and Events
    ----------------------------------------
    and what is Text1_KeyPress? and what is the ENTER BUTTOM
    ie. how to lanch a procedure when someone clicks enter in a edit box?
    Again, look at the Object Inspector Events and help for TEdit
    --------------------------------------------
    whats the difference between Complie Project1, and Build Project1.
    Compile does only the changed units while build does all.
    -------------------------------------------
    And what are these in Delphi:
    App.Path = STRING
    App.TaskVisible = Boolean
    app.Title = STRING
    See help for "Application" and "TApplication"
    --------------------------------------------

    In VB I used to creat a model and put the public subs and functions I creat there, where should I put the public subs and functions?

    Each class has "Private", "Protected", "Public" and "Published" sections.

    non-class-related procedures and functions can just be declared inline in the code for a unit.
    0
     
    LVL 12

    Accepted Solution

    by:
    1) Calling Exit; you will quit the CURRENT routine.
        If you want to skip a loop - user break;
        Application.Terminate; terminates to application
        Form1.Free; or FreeAndNil(Form1) will unload the form.

    2) Click on the component - form, button or ... whatever you have. Press F11 and you will see the Object inspector. There you have properties and Events. Events are what you need.

    3)
    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if Key = #13 then
        begin
          // ENTER was pressed
          // .....
        end;
    end;

    4) Application.ExeName
        App.TaskVisible = Boolean  <- I am not sure about this, but is seems Application.ShowMainForm to me
        Application.Title

    5)
      TForm1 = class(TForm)
        Edit1: TEdit;
        procedure Edit1KeyPress(Sender: TObject; var Key: Char);
      private
        procedure PrivateProcedure;   // PRIVATE
      public
        procedure PublicProcedure;    // PUBLIC
      end;
    0
     
    LVL 17

    Assisted Solution

    by:Wim ten Brink
    Okay, I'm going to be nasty. Sorry... I'm a perfectionist with Delphi and some things annoyed me.
    ------------------------------------
    what is exit For in delphi
    (how to skip the for loop)

    That would be the Break command but if you would be using this and you'd be working for me, I'd tell you to go find another job. Sorry, but in Pascal the use of Break is quite easy to avoid and just makes the code more unreadable. My advise: DON'T use it...
    ------------------------------------
    what is exit sub in delphi
    (skip all the sub)

    This is the exit command but again, this command would get you fired if I was your boss. This command can easily be avoided in Pascal too, just by writing more structured code.
    ------------------------------------
    how to totally exit all the application?(not just one form)

    Normally, you would close the mainform or call Application.Terminate. And no comments about the use of these commands. You can also use the command Halt() which allows you to return a number to the process that called your application.
    ------------------------------------
    how to Unload a form not just hide it?

    Call the Close method, or the Release method of the form, not the Free method. Thus: Form2.Release;
    When you call Release, Delphi will allow the form to handle some messages if there are still a few reserved for the form. Otherwise, those messages might end up doing nothing. Remember that the form variable will be invalid after you released it. You would have to create the form again to get it back. Form2 := TForm2.Create(Application);
    If you use the Close() method then you must assign caFree to the Action parameter of the OnClose event of the form, else it's just hidden, not closed.
    ------------------------------------
    how to know all the procedures of a specific component.
    Like Forum, if you click (dblclick) you will get
    procedure TForm1.FormCreate(Sender: TObject);
    but how to get
    procedure TForm1.FormDestroy(Sender: TObject);
    and other things?

    When you're in the object inspector that displays those events, just double-click on one of them and it will create the template code for you. Then all you need to do is fill it in before you save it.
    ------------------------------------
    and what is Text1_KeyPress? and what is the ENTER BUTTOM
    ie. how to lanch a procedure when someone clicks enter in a edit box?

    Delphi has three events: OnKeyDown and OnKeyUp that respond when a key is pressed or released and finally the OnKeyPress which is called whenever a key is pressed and a character is generated that must be acted upon. TheOnKeyPress is closest to Text1_KeyPress in functionality.
    To set a button to respond to the <Enter> key, go to the properties of the button and set the "Default" property to True. For a default cancel button that responds on the <Escape> key, set the "Cancel" property to true. But remember, a form can have only one key responding to <Enter> and one key responding to <Escape>, although this could be the same key. Otherwise, it is unclear which button will be activated.
    ------------------------------------
    whats the difference between Complie Project1, and Build Project1.
    When you compile a project, Delphi just compiles any unit that is affected by the changes you've made. If all you did was move a button on your main form, then this generally means that Delphi only compiles your main form and the project *.dpr file. When you build the project, Delphi will compile ALL units used by your project (except the VCL units) no matter if they have been altered or not. If you replace a unit source in your project with an older copy of the source then Delphi won't notice the change on a compile, but the build will force it to compile the unit anyway.
    ------------------------------------
    And what are these in Delphi:
    App.Path = STRING
    App.TaskVisible = Boolean
    app.Title = STRING

    App.Path = Application.ExeName which equals ParamStr(0). App.Title would be Application.Title and App.TaskVisible might not have a Delphi equavalent. It could be Application.Active but I'm not sure.
    ------------------------------------
    In VB I used to creat a model and put the public subs and functions I creat there, where should I put the public subs and functions?

    Well, if those procedures and stuff aren't related to a form, frame or datamodule then you can just create a new unit for your project. (File/New/Unit) This generates something like this:

    unit Unit2;
    interface
    // Type here your types and function headers and perhaps global variables.
    implementation
    // Type here the definitions for the stuff defined in your interface part.
    end.

    As I can see, you need to learn quite a lot. Find a good Delphi book to help you, because that might be easier than just wait here until some expert finally decided to answer... :-)
    0
     

    Author Comment

    by:deathman5
    This is not working... why? I want when enter is pressed in Edit2, the

    procedure of Button1Click to be lanched.

    procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
    begin
      if Key = #13 then
        begin
          // ENTER was pressed
          TForm1.Button1Click;
        end;
    end;
    -----------------------------------------------

    you still didnt get me
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    these are for declarations only right? I want to put a public sub/procedure
    like this one

    procedure DoYourJob(Delimiter: Char; S: string; const SS: TStrings);
    begin
    // Job
    // More Job
    //MessageBox
    //ShowMessage
    //AssignFile
    //Kill
    // If statments
    //Many More Commands
    //Just Like Any Procedure
    end;

    where and how to put it???
    0
     
    LVL 7

    Expert Comment

    by:sftweng
    Double-click on the OnKeyPress event for the TEdit, while designing. This will create the declarations and the event handler code skeleton.
    0
     
    LVL 26

    Expert Comment

    by:EddieShipman
    If you're too cheap to get a Delphi book, read the help file, Everyone of those questions
    are simple first day of class type of stuff that even casual perusing of the help file will give
    you answers to.
    0
     
    LVL 12

    Assisted Solution

    by:Ivanov_G
    procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
    begin
      if Key = #13 then
        begin
          Button1Click(Sender);
        end;
    end;

    --------------------------------------------------------------------------------------------------------------------

      TForm1 = class(TForm)
      private
      public
         procedure DoYourJob(Delimiter: Char; S: string; const SS: TStrings);
      end;

      implementation

      procedure TForm1.DoYourJob(Delimiter: Char; S: string; const SS: TStrings);
      begin
        // Job
        // More Job
        //MessageBox
        //ShowMessage
        //AssignFile
        //Kill
        // If statments
        //Many More Commands
        //Just Like Any Procedure
      end;
    0
     

    Author Comment

    by:deathman5
    Thank You All For Everything.
    Sorry if my questions where silly, but even if they were, you are getting points to answer arent you?
    ;-)
    thanks agian.
    0
     
    LVL 17

    Expert Comment

    by:Wim ten Brink
    I've answered sillier questions than these ones. :-)
    0
     
    LVL 12

    Expert Comment

    by:Ivanov_G
    :))) Me too. deathman5 don't worry, we are here to help each other. If I understood correctly, you are migrating to Delphi, so have time to catch up with us. Good luck :)
    0
     
    LVL 17

    Expert Comment

    by:Wim ten Brink
    Catch up with us? I have 20 years of Pascal experience, of which the last 10 are focused on Delphi. It would take him a lot of effords before he finally catches up... ;-)
    0
     
    LVL 7

    Expert Comment

    by:sftweng
    Time spent doesn't equal capability. :-)

    I've been working with the Pascal family of languages since about 1978, a few more than you, and I have always enjoyed hiring people whose prowess quickly supassed mine. Of course, I'm not just a programmer, so I don't over-specialize.

    0
     
    LVL 12

    Expert Comment

    by:Ivanov_G
    Guys, you are really old .... :)))))) I am only 22. Registered here from April this year, total programming experience - 10+, professional 4+. Correct me if I am wrong, but I think the new guy can become middle level developer in Delphi for 2 years.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Product Review - Android Remix

    Come along for the ride with our Senior Product Manager, Brian Matis, as he reviews the Android Remix.

    Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

    931 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now