[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
QbasicFAQ_Modular
What is modular programming?
Back to QBasic FAQ Main Page.
Modular programming involves building a program in such a way as to create it in specific sections; modules. This can be done using SUB declarations, GOSUBS, and FUNCTIONS. Using modular structure is preferred because, elements that need to be repeated can be created once, than invoked repeatedly. Good programming practice will also allow you to "transport" SUB modules for inclusion in other programs you create.
A good example:
The above example allows the programmer to call the SUB Center() any time he wishes to print centered text to the screen.
Now in the QB environment, the SUB would not be shown in the main edit window until it was chosen from the menu. Keeping the SUBs separated like this makes it easier to concentrate on the task at hand, and moves the coding to it's own separate "page" so to speak.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
QbasicFAQ_Modular
What is modular programming?
Back to QBasic FAQ Main Page.
Modular programming involves building a program in such a way as to create it in specific sections; modules. This can be done using SUB declarations, GOSUBS, and FUNCTIONS. Using modular structure is preferred because, elements that need to be repeated can be created once, than invoked repeatedly. Good programming practice will also allow you to "transport" SUB modules for inclusion in other programs you create.
A good example:
DECLARE SUB Center(RowPosition, Text$) ' Center 12, "This text is centered." Center 13, "So is this text example." END '------------------------------------ SUB Center (RowPosition,Text$) Column = 40 - INT(LEN(Text$)/2) LOCATE RowPosition, Column PRINT Text$; END SUB
The above example allows the programmer to call the SUB Center() any time he wishes to print centered text to the screen.
Now in the QB environment, the SUB would not be shown in the main edit window until it was chosen from the menu. Keeping the SUBs separated like this makes it easier to concentrate on the task at hand, and moves the coding to it's own separate "page" so to speak.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
