BBS: Inland Empire Archive Date: 02-22-93 (12:02) Number: 373 From: TONY DAVIS Refer#: NONE To: ALL Recvd: NO Subj: How does this Work????? Conf: (2) Quik_Bas
I am taking a course in QuickBasic. All is going well until I found
the following code:
SUB PrintTriangle (char$)
' The PrintTriangle subprogram receives an argument from the main
' program and uses it to print an equilateral triangle. The Tab
' function moves the cursor to the correct column location.
CONST ROWS% = 10 ' set the number of rows to 10
left% = ROWS% ' use left% to build left side of triangle
right% = ROWS% + 1 ' use right% to build right side of triangle
char$ = "*"
FOR rowCount% = 1 TO ROWS% ' for each row in the triangle
FOR i% = left% TO ROWS%
PRINT TAB(i%); char$; ' display left side of row
NEXT i%
FOR i% = ROWS% + 1 TO right% - 1 ' display right side of row
PRINT TAB(i%); char$;
NEXT i%
PRINT ' print carriage return at end of row
left% = left% - 1 ' first character in next row will start one
right% = right% + 1 ' space closer to left margin and extend
NEXT rowCount% ' one space closer to the right margin
END SUB
I have stepped this through and watched it but I still have a hard time
getting a hold of what's happening. Can anybody explain this any better?
... OFFLINE 1.42 * Format another (Y/N)?
--- Maximus/2 2.01wb
* Origin: Terrapin Station OS/2 - Norfolk, VA 804-489-7450 (1:275/13)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET