Ok, crashcourse on indenting:
In Blitz there are single commands, and commands that define a scope. Examples of a single command are Print, End, Plot, Rect, Line, LoadImage etc.
Examples of scope commands are:
For-Next
If(-Else)-Endif
Select-End Select
Function-End Function
etc.
Key rule: you should indent the scope/area of each scope-command. As an extra bonus you might want to have an empty line around scopes.
Based on personal taste: I also indent drawing/actions on a canvas or image between changing the drawing buffer and the flipping, but that's personal.
One might even indent creating menuitems in a menu.
As long as things belong together for a limited area in your code, you may indent them.
So, to apply this on your function:
and with dots to show how an end-scope matches a begin-scope:
Note that the Case command defines a scope, but since it doesn't have an 'End Case' command, I couldn't really draw dots here, or at least: it would look a bit weird compared to the rest.
btw, while we're checking code anyway:
Wiped a few lines. If your blah would've been 1 then it would've ended, if not it would notify, and you wouldn't need an 'Else' nor would you need to check on blah<>1 because it HAS to be <>1 in order to get at the line in the first place. (if it was 1, then the program would've ended!)
It's like a factory where they make blue and red paint. At one point/junction one sends blue paint to hall 1 and red paint to hall 2, would it be practical to have other employees standing in halls 1 & 2 to check whether the colors are correctly chosen, after it was already correctly re-routed at that first junction?
In Blitz there are single commands, and commands that define a scope. Examples of a single command are Print, End, Plot, Rect, Line, LoadImage etc.
Examples of scope commands are:
For-Next
If(-Else)-Endif
Select-End Select
Function-End Function
etc.
Key rule: you should indent the scope/area of each scope-command. As an extra bonus you might want to have an empty line around scopes.
Based on personal taste: I also indent drawing/actions on a canvas or image between changing the drawing buffer and the flipping, but that's personal.
One might even indent creating menuitems in a menu.
As long as things belong together for a limited area in your code, you may indent them.
So, to apply this on your function:
Function StartEruP() MainMenu=CreateWindow("Main Menu",300,300,400,500,main,15) Ev=WaitEvent() Es=EventSource() Repeat Select Es Case MainMenu If Ev=$803 Then Blah=Proceed("Do you really want to quit?") If Blah=1 Then End Else If Blah<>1 Then Notify("Find out what you want next time") (EndIf ; according to b32) EndIf EndIf End Select Until KeyDown(1) End End Function StartERuP() End
and with dots to show how an end-scope matches a begin-scope:
Function StartEruP() . . MainMenu=CreateWindow("Main Menu",300,300,400,500,main,15) . . Ev=WaitEvent() . Es=EventSource() . . Repeat . : . : Select Es . : . . : . Case MainMenu . : . . : . If Ev=$803 Then . : . : . : . : Blah=Proceed("Do you really want to quit?") . : . : . : . : If Blah=1 Then . : . : . End . : . : Else . : . : . If Blah<>1 Then . : . : . : Notify("Find out what you want next time") . : . : . (EndIf ; according to b32) . : . : EndIf . : . : . : . EndIf . : . . : End Select . : . Until KeyDown(1) . . End . End Function StartERuP() End
Note that the Case command defines a scope, but since it doesn't have an 'End Case' command, I couldn't really draw dots here, or at least: it would look a bit weird compared to the rest.
btw, while we're checking code anyway:
Function StartEruP() MainMenu=CreateWindow("Main Menu",300,300,400,500,main,15) Ev=WaitEvent() Es=EventSource() Repeat Select Es Case MainMenu If Ev=$803 Then If Proceed("Do you really want to quit?") Then End Notify("Find out what you want next time") EndIf End Select Until KeyDown(1) End End Function
Wiped a few lines. If your blah would've been 1 then it would've ended, if not it would notify, and you wouldn't need an 'Else' nor would you need to check on blah<>1 because it HAS to be <>1 in order to get at the line in the first place. (if it was 1, then the program would've ended!)
It's like a factory where they make blue and red paint. At one point/junction one sends blue paint to hall 1 and red paint to hall 2, would it be practical to have other employees standing in halls 1 & 2 to check whether the colors are correctly chosen, after it was already correctly re-routed at that first junction?