Grafit

This file is part of and Synchro-Sette April 1983. Download the collection to get this file.
Date: April 1983
Type: Program
Platform(s): TS 1000
Tags: Business

This program collects monthly sales figures for 12 months, storing three-character month abbreviations in a string array and numeric values in a numeric array, then renders a horizontal bar chart on screen. Each bar is drawn using CHR$ 128 (a block graphic separator) followed by repeated CHR$ 134 characters (a solid block graphic) scaled so the highest value fills 22 columns. After the chart, total and average sales figures are printed. The SCROLL calls during input keep the display tidy on the 32-column screen, and the fractional STEP (B/22) in the FOR loop controls bar length proportionally to the peak value.


Program Analysis

Program Structure

The program is divided into two clear phases. Lines 90009160 handle data entry: two parallel arrays (A$(12,3) for month names and A(12) for sales values) are populated via INPUT, with the peak value tracked in B. Lines 91709270 render the bar chart and summary. Line 9997 stops execution; line 9998 saves the program; line 9999 loops back to redraw — allowing the chart to be redrawn without re-entering data.

Array Design

DIM A$(12,3) declares a 12-element string array where each element is exactly 3 characters, enforcing the “first 3 characters” prompt. DIM A(12) holds the corresponding numeric sales figures. The parallel-array approach is idiomatic for this dialect, which lacks record or struct types.

Bar Chart Rendering

Each bar is drawn on a single PRINT line. The month name and value are printed left-aligned, then TAB 9 positions the cursor before the bar. CHR$ 128 (block graphic ▝ or similar solid block, used as a visual separator) precedes the bar body. The bar itself consists of repeated CHR$ 134 characters printed by the inner FOR C loop.

Scaling Technique

Bar length is controlled by iterating FOR C=.01 TO A(N) STEP B/22. Dividing the peak value B by 22 sets the step size so the largest bar prints exactly 22 block characters, while all others are proportionally shorter. Starting at .01 rather than 0 or 1 means the loop always executes at least once for any positive sales value, ensuring every month gets at least one character.

Display Management

Four SCROLL calls (lines 9050, 9090, 9130, 9140) during data entry scroll the display upward before and after each prompt/response pair, keeping the screen uncluttered during the 12-iteration input loop. CLS at line 9170 clears the screen before chart rendering.

Summary Output

Lines 92609270 print total and average sales below the chart. The comma separators in PRINT ,,,,"TOTAL SALES = $";T advance the print position by four tab columns, indenting the summary to approximate centre-screen alignment on a 32-column display.

Notable Anomalies

  • LET T=0 appears at both line 9020 and line 9175. The accumulator is reset a second time just before the chart loop, which is redundant but harmless; it may reflect an edit where the chart loop was intended to be re-enterable from 9999 without re-accumulating.
  • If any sales value is zero, B remains zero after all entries and STEP B/22 becomes STEP 0, which would cause an infinite loop. The program assumes at least one non-zero entry.
  • B is initialised to 0 but never reset before the chart phase; if GOTO 9999 is reached after a prior run with different data, B correctly retains the peak from the most recent input session.

Line Reference Summary

LinesPurpose
9000–9030Array and variable initialisation
9040–916012-month data entry loop, peak tracking
9170–9175Screen clear, accumulator reset
9180–9250Bar chart rendering loop
9260–9270Total and average summary
9997STOP
9998SAVE program
9999Redraw loop entry point

Content

Appears On

Cassette to accompany the April 1983 issue of Synchro-Sette.

Related Products

Related Articles

Related Content

Image Gallery

Source Code

 9000 DIM A$(12,3)
 9010 DIM A(12)
 9020 LET T=0
 9030 LET B=0
 9040 FOR N=1 TO 12
 9050 SCROLL 
 9060 PRINT "MONTH (1ST 3 CHAR)? ";
 9070 INPUT A$(N)
 9080 PRINT A$(N)
 9090 SCROLL 
 9100 PRINT "SALES? ";
 9110 INPUT A(N)
 9120 PRINT A(N)
 9130 SCROLL 
 9140 SCROLL 
 9150 IF A(N)>B THEN LET B=A(N)
 9160 NEXT N
 9170 CLS 
 9175 LET T=0
 9180 FOR N=1 TO 12
 9190 PRINT A$(N);" ";A(N);TAB 9;CHR$ 128;
 9200 LET T=T+A(N)
 9210 FOR C=.01 TO A(N) STEP B/22
 9220 PRINT CHR$ 134;
 9230 NEXT C
 9240 PRINT 
 9250 NEXT N
 9260 PRINT ,,,,"TOTAL SALES = $";T
 9270 PRINT ,,"AVERAGE MONTH = $";T/12
 9997 STOP 
 9998 SAVE "GRAFI%T"
 9999 GOTO 9170

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top