|
-
Sep 25th, 2000, 08:57 PM
#1
Thread Starter
Hyperactive Member
Hi,
Can I set the IDE to automatically print separators (line) between functions/subs? It shows the lines, but how can I print them? I found myself doing this manually for all subs so they look more readable.
Thanks
-
Sep 26th, 2000, 06:47 AM
#2
Thread Starter
Hyperactive Member
-
Sep 26th, 2000, 08:36 AM
#3
Guru
You don't need any lines to make it readable.
Just follow a few rules and you won't ever have readability problems again. 
Rule #1: Always have at least one empty line between procedures.
Code:
' Unreadable:
Sub Proc1()
' Stuff
End Sub
Sub Proc2()
' Stuff
End Sub
Sub Proc3()
' Stuff
End Sub
' Readable:
Sub Proc1()
' Stuff
End Sub
Sub Proc2()
' Stuff
End Sub
Sub Proc3()
' Stuff
End Sub
Rule #2: Do not use variable-declaration symbols. They're ugly.
Code:
' Unreadable:
Dim X%, Y&, Z!, A@, B$, C#
' Readable:
Dim X As Integer, Y As Long, Z As Single, A As Currency, B As String, C As Double
' If you have many variables of the same type, you can use a shortcut:
' Instead of:
Dim A As Long, B As Long, C As Long, D As Long
Dim E As String, F As String, G As String, H As String
Dim I As Double, J As Double, K As Double, L As Double
Dim M As Boolean, N As Boolean, O As Boolean, P As Boolean
' You can use:
DefLng A-D
DefStr E-H
DefDbl I-L
DefBool M-P
Dim A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P
Rule #3: Always indent the code depending on the context. Also, it is good to leave empty lines between lines of code. For example, I always separate the Dim lines from the other lines, etc.
Code:
' Unreadable:
Sub MySub()
Dim X As Integer, Y As Integer, Z As Integer
For X = 1 To 10
For Y = 1 To 10
For Z = 1 To 10
Debug.Print "(" & X & ", " & Y & ", " & Z & ")"
Next Z
Next Y
Next X
End Sub
' Readable:
Sub MySub()
Dim X As Integer, Y As Integer, Z As Integer
For X = 1 To 10
For Y = 1 To 10
For Z = 1 To 10
Debug.Print "(" & X & ", " & Y & ", " & Z & ")"
Next Z
Next Y
Next X
End Sub
Rule #4: Do not use the : (colon) operator. It looks ugly. Also, try to put several Dim lines depending on the data type.
Code:
' Unreadable:
Dim DoIt As Boolean, X As Integer, Y As Integer, Z As Integer
Function MyProc() As Integer
If DoIt Then Y = 27: Z = 3: DoIt = False: Call SomeOtherProc: X = SomeFunction: MyProc = X + Y
End Sub
' Readable:
Dim DoIt As Boolean
Dim X As Integer, Y As Integer, Z As Integer
Function MyProc() As Integer
If DoIt Then
Y = 27
Z = 3
DoIt = False
Call SomeOtherProc
X = SomeFunction
MyProc = X + Y
End If
End Function
' Also readable:
Dim DoIt As Boolean
Dim X As Integer, Y As Integer, Z As Integer
Function MyProc() As Integer
If Not DoIt Then Exit Function
Y = 27
Z = 3
DoIt = False
Call SomeOtherProc
X = SomeFunction
MyProc = X + Y
End Function
If you still absolutely must print the lines... Do it manually.
-
Sep 26th, 2000, 09:51 AM
#4
transcendental analytic
10 points to Yonatan!
Code:
' You can use:
DefLng A-D
DefStr E-H
DefDbl I-L
DefBool M-P
Because that helps me alot
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|