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:
- Lines 5–50: Title display — screen heading and a 19-asterisk separator rule.
- Lines 100–121: Input and echo of the period-ending date.
- Lines 200–221: Input and echo of the salesman’s name.
- Lines 300–330: Input and echo of commission percentage; converts to decimal rate
K = P * 0.01. - Lines 400–430: Input and echo of gross sales; computes commission
T = K * Q. - Lines 450–530: Results display.
- Lines 600–620: Keypress wait loop, then CLS and restart.
- 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
| Variable | Purpose |
|---|---|
D$ | Period-ending date (string) |
N$ | Salesman name (string) |
P | Commission percentage (e.g. 10 for 10%) |
K | Decimal commission rate (P * 0.01) |
Q | Gross sales figure |
T | Computed commission (K * Q) |
L | Loop 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/NEXTloop at lines 20–40 prints exactly 19 asterisks with a trailing semicolon, suppressing the newline, followed byPRINTat 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
PorQwould cause an error. - The
LPRINT PandLPRINT Qstatements print the raw numeric values without currency or percentage formatting, while the correspondingPRINTstatements 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
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.
