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.
STRING$ Function Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the STRING$ function to generate a bar graph.
 
CLS
PRINT TAB(7);"Daily Mean Temperature in Seattle"
PRINT
'Get data for each month and graph.
FOR Month = 1 TO 12 STEP 2
    READ Month$, Temp
    'Print Temp-35 stars.
    PRINT Month$;" +"; STRING$(Temp-35,"*")
    PRINT "    |"
NEXT Month
 
'Print horizontal line.
PRINT "    +";
FOR X = 1 TO 7
    PRINT "----+";
NEXT X
PRINT
 
'Print temperature labels.
FOR X = 4 TO 39 STEP 5
    PRINT TAB(X); X+31;
NEXT X
PRINT
 
DATA Jan, 40, Mar, 46, May, 56
DATA Jul, 66, Sep, 61, Nov, 46
 
'Sample Output
'
'Daily Mean Temperature in Seattle
'
'Jan +*****
'    |
'Mar +***********
'    |
'May +*********************
'    |
'Jul +*******************************
'    |
'Sep +**************************
'    |
'Nov +***********
'    |
'    +----+----+----+----+----+----+----+
'    35   40   45   50   55   60   65   70