TAB Function Programming Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'This example uses the TAB function with the PRINT and PRINT USING statements
'to center a text string and position a page number at a particular location
'on an 80-column screen.
CLS
INPUT "What is your full name "; Name$
PRINT
PRINT "Do you want the page number <C>entered or <R>ight-justified? "
DO
Answer$ = UCASE$(INKEY$)
LOOP UNTIL Answer$ = "C" OR Answer$ = "R"
CLS
PageNumber% = INT(RND * 10)
'Divide the length of Name$ by 2 and subtract from screen center point.
PRINT TAB(40 - (LEN(Name$) \ 2)); Name$
LOCATE 23, 1
IF Answer$ = "C" THEN
PRINT TAB(35); USING "Page ##"; PageNumber%
ELSE
PRINT TAB(72); USING "Page ##"; PageNumber%
END IF
END