Right justification on screen

From Ninerpedia
Revision as of 19:06, 16 September 2014 by Stephen Shaw (talk | contribs) (Short article on how to right justify a printout of variables in 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$