Formatting rules while coding HMG4

Moderator: Rathinagiri

Post Reply
User avatar
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Formatting rules while coding HMG4

Post by concentra » Tue Mar 29, 2011 1:53 pm

Didn´t find a specific topic about formatting rules while coding HMG4.
Please review what I found searching the forum:

1. Indentation is three spaces and not tab.

2. Variable names should start with the type (c,n,l,d,a,x,o,q as the case may be) as mentioned below in smaller case letter and name of the variable would start with an uppercase letter.
cName - variable name 'cName' which is a character type.
nNumber - 'nNumber' variable which is a number type.
lYesNo - 'lYesNo' variable which is a logical type.
dToday - 'dToday' variable which is a date type.
aObjects - 'aObjects' variable which is an array type.
xValue - 'xValue' variable the type of which is not known now and may be known at run time.
oDataObject - 'oDataObject' variable which is an object type.
qPrinter - 'qPrinter' variable which is a QT object type.

3. When calling a QT method/function, the first word is started with a smaller case and next words are uppercase.
qTreeWidget:indexFromItem( qTreeWidgetItem )

4. A space is necessary between starting and ending parenthesis of function names and the parameters. Please see the example.
qTreeWidget.collapseItem(qTreeWidgetItem) - Wronge
qTreeWidget.collapseItem( qTreeWidgetItem ) - Right

5. All Harbour keywords must be uppercase: DO CASE IF ENDIF ELSE CASE FOR NEXT etc.

6. Only FUNCTION/METHOD Name must be starting at column 1, rest of the lines including RETURN
must be indented.

7. No short names as FUNC PROC be used, all complete ones.

8. SWTCH and DO CASE and its CASE statements must be on same indent:
...CASE 4
...CASE 5

9. Function call must be like: MyFunc( n, n1, ... ), no space between function name and opening parenthesis.

10. No comments starting with * (star). Only ANSI compatible // some comment OR preferably /* some comment */.

11. Every function body must be separated by a blank line and seperator. Seperator line must be uniform as I have used.

12. HMG library source must be compilable with -w3 switch. It helps to detect the wrong code soon.

13. No LOCAL variable assignment with NIL. It is neither needed not oprimized.
[[]] Mauricio Ventura Faria

User avatar
Posts: 5105
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 95 times
Been thanked: 107 times

Post by Rathinagiri » Tue Mar 29, 2011 4:22 pm

I made this useful topic sticky.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest