bas7ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
STR$, RTRIM$ and LTRIM$ Functions Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the STR$ function to convert a number to its
'string representation and the LTRIM$ and RTRIM$ functions to strip out the
'leading and trailing blanks that BASIC ordinarily prints with numeric
'output.
 
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