• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

Many Simple Questions

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
deathman5
Asked:
deathman5
  • 4
  • 3
  • 3
  • +2
4 Solutions
 
sftwengCommented:
--------------------------
 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
 
Ivanov_GCommented:
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
 
Wim ten BrinkSelf-employed developerCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
deathman5Author Commented:
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
 
sftwengCommented:
Double-click on the OnKeyPress event for the TEdit, while designing. This will create the declarations and the event handler code skeleton.
0
 
Eddie ShipmanAll-around developerCommented:
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
 
Ivanov_GCommented:
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
 
deathman5Author Commented:
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
 
Wim ten BrinkSelf-employed developerCommented:
I've answered sillier questions than these ones. :-)
0
 
Ivanov_GCommented:
:))) 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
 
Wim ten BrinkSelf-employed developerCommented:
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
 
sftwengCommented:
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
 
Ivanov_GCommented:
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now