Salesman Commission

This file is part of Timex Sinclair Public Domain Library Tape 1001 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Business

This program calculates and prints a salesman’s commission based on user-supplied gross sales and a commission percentage. It collects four inputs — a period-ending date, the salesman’s name, commission percentage, and gross sales — then computes the commission as the product of the rate and sales figure. Notably, it uses both PRINT and LPRINT statements in parallel, so results are displayed on screen and simultaneously sent to a printer, with the header line printed in inverse video on the hard copy. The main loop returns to line 10 via a busy-wait keypress check at line 600 using the INKEY$ polling idiom, and lines 625–700 (CLEAR, SAVE, RUN) are unreachable dead code placed after the unconditional GOTO at line 620.


Program Analysis

Program Structure

The program is organized into numbered blocks that loosely correspond to functional phases:

  1. Lines 5–50: Title display — screen heading and a 19-asterisk separator rule.
  2. Lines 100–121: Input and echo of the period-ending date.
  3. Lines 200–221: Input and echo of the salesman’s name.
  4. Lines 300–330: Input and echo of commission percentage; converts to decimal rate K = P * 0.01.
  5. Lines 400–430: Input and echo of gross sales; computes commission T = K * Q.
  6. Lines 450–530: Results display.
  7. Lines 600–620: Keypress wait loop, then CLS and restart.
  8. Lines 625–700: Dead code (CLEAR, SAVE, RUN — never reached).

Dual Output: Screen and Printer

Every significant value is output twice: once to the screen with PRINT and once to the printer with LPRINT. The header at line 11 uses the ZX81/TS1000 inverse-video escape sequence so the printed heading “%S%A%L%E%S%M%A%N% %C%O%M%M%I%S%S%I%O%N” appears in inverse characters on the thermal printout. The on-screen header at line 10 is plain text.

Key Variables

VariablePurpose
D$Period-ending date (string)
N$Salesman name (string)
PCommission percentage (e.g. 10 for 10%)
KDecimal commission rate (P * 0.01)
QGross sales figure
TComputed commission (K * Q)
LLoop counter for asterisk rule

INKEY$ Polling Loop

Line 600 uses the standard busy-wait idiom: IF INKEY$="" THEN GOTO 600. This continuously polls the keyboard and holds execution until any key is pressed, after which CLS clears the screen and the program jumps back to line 10 for the next entry.

Unreachable Dead Code

Lines 625–700 are never executed because line 620 performs an unconditional GOTO 10. The sequence 625 CLEAR, 630 SAVE "1001%4", 700 RUN would otherwise save the program (the inverse digit %4 in the filename encodes an auto-run flag) and restart it. This block appears to be a vestigial save/autostart stub left in from development that is now completely bypassed.

Notable Techniques and Anomalies

  • The FOR/NEXT loop at lines 20–40 prints exactly 19 asterisks with a trailing semicolon, suppressing the newline, followed by PRINT at line 50 to emit the line break — a common ZX81 formatting trick.
  • Commission percent is stored as a human-friendly whole number (P) and converted to a rate (K) separately, keeping the input natural and the arithmetic clean.
  • There is no input validation; non-numeric entries for P or Q would cause an error.
  • The LPRINT P and LPRINT Q statements print the raw numeric values without currency or percentage formatting, while the corresponding PRINT statements on screen add "$ " or label context.
  • Line numbering uses deliberate gaps (e.g., 100-series for date, 200-series for name) consistent with structured BASIC programming practice to allow easy insertion of additional lines.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Related Content

Image Gallery

Salesman Commission

Source Code

   5 REM *SALESMAN COMMISSION*
  10 PRINT "SALESMAN COMMISSION"
  11 LPRINT "%S%A%L%E%S%M%A%N% %C%O%M%M%I%S%S%I%O%N"
  20 FOR L=1 TO 19
  30 PRINT "*";
  40 NEXT L
  50 PRINT 
 100 PRINT "PERIOD ENDING DATE: ";
 110 INPUT D$
 120 PRINT D$
 121 LPRINT D$
 200 PRINT "SALESMAN NAME: ";
 210 INPUT N$
 220 PRINT N$
 221 LPRINT N$
 300 PRINT "COMMISSION PERCENT:  ";
 310 INPUT P
 320 PRINT P
 321 LPRINT P
 330 LET K=P*.01
 400 PRINT "GROSS SALES: ";
 410 INPUT Q
 412 LPRINT Q
 420 PRINT "$ ";Q
 430 LET T=K*Q
 450 PRINT 
 500 PRINT "COMMISSION: $ ";T
 501 LPRINT T
 510 PRINT 
 520 PRINT 
 530 PRINT "FOR MORE,PRESS ANY KEY"
 600 IF INKEY$="" THEN GOTO 600
 610 CLS 
 620 GOTO 10
 625 CLEAR 
 630 SAVE "1001%4"
 700 RUN 

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

People

No people associated with this content.

Scroll to Top