Right justification on screen

From Ninerpedia
Revision as of 21:12, 5 January 2015 by Stephen Shaw (talk | contribs) (add links to ExBas and TI Basic)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Right justification on screen when printing variables which have a different length.

In Extended BASIC you would use the extended command PRINT USING but in TI BASIC you need to carry out the formatting yourself.

Here is a quick routine for right justification (useful when using columns of numbers).

The variable to be printed is in the string variable A$

To convert numbers to strings use eg STR$(42)

Place the value of the rightmost column to be used in variable RC:

           X=RC-LEN(A$)
           FOR C=1 TO X
           A$=" "&A$     (this adds one space in front of A$)
           NEXT C
           PRINT A$