qb45advr.hlp (Topic list)
STR$ Function Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
STR$ Function Programming Example
 
The following example uses the STR$ function to convert a number to its
string representation and strips out the leading and trailing blanks that
BASIC ordinarily prints with numeric output.
 
'*** STR$ function programming example ***
CLS                            ' clear the screen
PRINT "Enter 0 to end."
DO
    INPUT "Find cosine of: ",Num
    IF Num = 0 THEN EXIT DO
    X$ = STR$(Num)
    NumRemBlanks$ = LTRIM$(RTRIM$(X$))
    PRINT "COS(" NumRemBlanks$ ") = " COS(Num)
LOOP
 
Sample Output
 
Enter 0 to end.
Find cosine of: 3.1
COS(3.1) = -.9991351
Find cosine of: 0