--- title: "Salesman Commission" id: 56989 type: "computer_media" slug: "salesman-commission" url: "http://localhost/computer_media/salesman-commission/" markdown_url: "http://localhost/computer_media/salesman-commission.md" published_at: "2024-10-02T01:19:44+00:00" modified_at: "2026-03-30T21:20:26+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/14_Sales.png" excerpt: "A commission calculator that mirrors every result to a printer in inverse video, with a tight input loop and some intriguing unreachable code at the end." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Business" slug: "business" taxonomy: "genre" url: "http://localhost/type/business/" media_contents: - id: 56732 title: "Timex Sinclair Public Domain Library Tape 1001" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1001/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/14_Sales.png" media_type_tags: "Business" --- # Salesman Commission 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 | 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`/`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. ## 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 ```