Indentation
From CometWiki
(Difference between revisions)
(New page: == Indentation == Internet Basic statements may start at any position on the line. For more readable source code, you may indent instructions in order to highlight statement labels, illu...) |
|||
Line 1: | Line 1: | ||
- | |||
== Indentation == | == Indentation == | ||
Line 5: | Line 4: | ||
Example 1: | Example 1: | ||
- | Before FOR HALFS=0 TO 2 | + | Before FOR HALFS=0 TO 2 |
FOR QUARTERS=0 TO 4 | FOR QUARTERS=0 TO 4 | ||
FOR DIMES=0 TO 10 | FOR DIMES=0 TO 10 | ||
Line 19: | Line 18: | ||
- | After FOR HALFS=0 TO 2 | + | After FOR HALFS=0 TO 2 |
FOR QUARTERS=0 TO 4 | FOR QUARTERS=0 TO 4 | ||
FOR DIMES=0 TO 10 | FOR DIMES=0 TO 10 | ||
Line 35: | Line 34: | ||
Example 2: | Example 2: | ||
- | Before PRINT (0) (ET) | + | Before PRINT (0) (ET) |
LABEL: PRINT (0) "WELCOME TO THE PROGRAM." | LABEL: PRINT (0) "WELCOME TO THE PROGRAM." | ||
PRINT (0) "WHAT IS YOUR NAME?" | PRINT (0) "WHAT IS YOUR NAME?" | ||
Line 45: | Line 44: | ||
- | After PRINT (0) (ET) | + | After PRINT (0) (ET) |
LABEL: PRINT (0) "WELCOME TO THE PROGRAM." | LABEL: PRINT (0) "WELCOME TO THE PROGRAM." | ||
PRINT (0) "WHAT IS YOUR NAME?" | PRINT (0) "WHAT IS YOUR NAME?" | ||
Line 53: | Line 52: | ||
GOTO LABEL | GOTO LABEL | ||
- | + | Example 3: | |
- | Before IF ENTERLEVEL = 0 | + | Before IF ENTERLEVEL = 0 |
STOP | STOP | ||
ELSE | ELSE | ||
Line 62: | Line 61: | ||
- | After IF ENTERLEVEL = 0 | + | After IF ENTERLEVEL = 0 |
STOP | STOP | ||
ELSE | ELSE | ||
EXIT | EXIT | ||
ENDIF | ENDIF |
Latest revision as of 08:23, 31 May 2009
Indentation
Internet Basic statements may start at any position on the line. For more readable source code, you may indent instructions in order to highlight statement labels, illustrate loop constructs, show nested structures, etc. Example 1:
Before FOR HALFS=0 TO 2 FOR QUARTERS=0 TO 4 FOR DIMES=0 TO 10 FOR NICKELS=0 TO 20 FOR PENNIES=0 TO 100 TOTAL=HALFS*50+QUARTERS*25+DIMES*10+NICKELS*5+PENNIES IF TOTAL = 100 THEN PRINT (0,1000) NEXT PENNIES NEXT NICKELS NEXT DIMES NEXT QUARTERS NEXT HALFS
After FOR HALFS=0 TO 2 FOR QUARTERS=0 TO 4 FOR DIMES=0 TO 10 FOR NICKELS=0 TO 20 FOR PENNIES=0 TO 100 TOTAL=HALFS*50+QUARTERS*25+DIMES*10+NICKELS*5+PENNIES IF TOTAL = 100 THEN PRINT (0,1000) NEXT PENNIES NEXT NICKELS NEXT DIMES NEXT QUARTERS NEXT HALFS
Example 2:
Before PRINT (0) (ET) LABEL: PRINT (0) "WELCOME TO THE PROGRAM." PRINT (0) "WHAT IS YOUR NAME?" INPUT (0) NAME$ . . GOTO LABEL
After PRINT (0) (ET) LABEL: PRINT (0) "WELCOME TO THE PROGRAM." PRINT (0) "WHAT IS YOUR NAME?" INPUT (0) NAME$ . . GOTO LABEL
Example 3:
Before IF ENTERLEVEL = 0 STOP ELSE EXIT ENDIF
After IF ENTERLEVEL = 0 STOP ELSE EXIT ENDIF