Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Correct Delphi layout/design

Posted on 2006-04-20
5
Medium Priority
?
736 Views
Last Modified: 2012-08-14
Hi there

I've been using Delphi for many years and always thought of the correct layout.

Exmaple for If statements I use

If 1 = 1 then
  Begin
    { stagement }
  end
else
  Beigin
    If 2 = 2 then
      begin
        {statement}
      end;
  end;

--------

case i of
  1 : something
  2 : something else
  3 : begin something end;
else
end;

----

For i := 0 to count-1 do
  begin
    {statement}
  end;

---

So baically all the begin/end get tabed one in, and the statements get a further tab.

I find that is good for me, but is it 'proper'.

Your comments :)
0
Comment
Question by:wildzero
5 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 16502867
there will be war :)
for me proper is

If 1 = 1 then
   Begin
   { stagement }
   end
else
   Beigin
   If 2 = 2 then
      begin
      {statement}
      end;
  end;
0
 
LVL 4

Accepted Solution

by:
JDSkinner earned 600 total points
ID: 16502965
Your block of if/else statements should read :-
if i = 1 then
begin
    < stagement >
end
else if i = 2 then
begin
    <statement>
end;

The case statement block does the same as the 'IF' construct but is a much neater structure.
You can use the Code Templates by pressing Ctrl + J when using the code editor to insert code methods.
0
 
LVL 13

Assisted Solution

by:BlackTigerX
BlackTigerX earned 400 total points
ID: 16503191
the recommended standard is how JDSkinner suggests, you put the begin on the next line and same column, and then TAB 2 spaces for the statements
0
 
LVL 13

Assisted Solution

by:BlackTigerX
BlackTigerX earned 400 total points
ID: 16503197
just look at how the Delphi code is written, Ctrl+Click in (most) Delphi types like TForm, etc and check how the code is written and follow that
0
 
LVL 10

Author Comment

by:wildzero
ID: 16504173
Sweet, thanks :D
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

577 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