--- title: "PRINTUSING" type: "article" slug: "printusing" url: "http://localhost/article/printusing/" markdown_url: "http://localhost/article/printusing.md" published_at: "2022-09-14T02:43:06+00:00" modified_at: "2026-07-28T00:03:55+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "This is an updated version of Dick Wagner's PRINTUSING routine, wrapped in a demonstration that takes a set of numbers, prints them as BASIC prints them, and then prints the same numbers again formatted to a ######.## template. The formatter itself is the subroutine at 2000–2170; everything below 300 is the demo around it. BASIC…" category: - name: "The Plotter" slug: "the-plotter" taxonomy: "category" url: "http://localhost/category/periodicals/the-plotter/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Jack Armstrong" slug: "armstrong-jack" taxonomy: "indiv" url: "http://localhost/indiv/armstrong-jack/" publication_r: id: 21216 title: "The Plotter" type: "periodical" url: "http://localhost/periodical/the-plotter/" authors: "Jack Armstrong" authors_r: - name: "Jack Armstrong" slug: "armstrong-jack" taxonomy: "indiv" url: "http://localhost/indiv/armstrong-jack/" volume: "5" issue: "10" issues_articles: - id: 39451 title: "The Plotter v5 n10" type: "issue" url: "http://localhost/issue/the-plotter-v5-n10/" pages: "7" pubdate: "October 1987" related_articles: - id: 43232 title: "Print Using" type: "article" url: "http://localhost/article/print-using/" archive_link: false --- This is an updated version of Dick Wagner’s [PRINTUSING](http://localhost/article/print-using/) routine, wrapped in a demonstration that takes a set of numbers, prints them as BASIC prints them, and then prints the same numbers again formatted to a `######.##` template. The formatter itself is the subroutine at 2000–2170; everything below 300 is the demo around it. ### BASIC Listing ``` 5 REM This is an updated version of Dick Wagners PRINTUSING routine showing a demo of how itwill change your input and print it out in an orderly fashion for a neat appearance. It shows how ordinary input prints, then will print the same material in formatted fashion. Revisions are by Jack Armstrong, 8-87. 6 REM 10 INK 0: PAPER 6: BORDER 5: CLS 20 PRINT '" THIS PROGRAM WILL INTAKE YOUR NUMBERS AND PRINT THEM OUT IN A ""PRINTUSING"" FORMAT EVEN IF THEY HAVE NO LEADING DIGIT AND EVEN IF THEY HAVE NO DECIMAL; IT WILL HANDLE NUMBERS UP TO 9 CHARACTERS LONG (INCLUDING THE DECIMAL POINT.)" 30 PRINT INK 1;'" PRESS A KEY TO START...": PAUSE 0: CLS 40 PRINT '"How many numbers will we use?": INPUT many: PRINT ' INK 2;many;" numbers" 50 PRINT '"How long is the longest number? (long=total characters includingthe decimal point if it has one)": INPUT long: PRINT ' INK 2;"Longest #:";long 60 POKE 23658,8: INPUT "Clear the screen? Y/N "; LINE z$: IF z$="Y" THEN CLS 70 LET tot=0: DIM m(many): LET i$="######.##" 80 FOR l=1 TO many 90 INPUT ("INPUT #";l;" of ";many);" ";m(l) 100 LET tot=tot+m(l): NEXT l 110 PRINT '' 120 FOR l=1 TO many 130 PRINT INK 2;m(l);TAB 3+long;("Old format" AND l=1) 140 NEXT l 150 PRINT ' 160 FOR l=1 TO many 170 LET xi=m(l) 180 GO SUB 2000 190 PRINT INK 1;x$;TAB 3+long;("PrintUsing format" AND l=1) 200 NEXT l 210 PRINT "---------": PRINT INK 1;TAB 9-long;tot 300 STOP 2000 REM 2010 LET il=LEN i$ 2020 LET id=0 2030 FOR j=1 TO il 2040 LET j$=i$(j) 2050 IF j$=CHR$ 46 THEN LET id=LEN i$-j 2060 NEXT j 2070 LET x$=STR$ INT (ABS xi*10↑id) 2080 LET xd=LEN x$-id 2090 FOR j=0 TO -xd 2100 LET x$="0"+x$ 2110 NEXT j 2120 LET xd=LEN x$-id 2130 IF id>0 THEN LET x$=x$( TO xd)+"."+x$(xd+1 TO ) 2140 FOR j=1 TO il-LEN x$ 2150 LET x$=CHR$ 32+x$ 2160 NEXT j 2170 RETURN 3000 SAVE "pusing" LINE 10 ``` ### How the formatter works The template lives in `i$` at line 70. Line 2010 takes its total width and lines 2030–2060 walk it looking for `CHR$ 46`, the decimal point, so that `id` ends up holding the number of places to the right of it — two, for `######.##`. Line 2070 does the real work: `ABS xi*10↑id` shifts the value left by that many places and `INT` throws away what is left, so `x$` becomes the digits with no point in them. Lines 2080–2120 prepend zeros when there are fewer digits than the template needs on the right — this is what lets a value like .5 print as 0.50 rather than losing its leading digit. Line 2130 pushes the point back in at the right offset, and 2140–2160 pad the front with `CHR$ 32` until the string matches the template width, which is what makes a column of them line up. Two consequences worth knowing before you type it in. The `ABS` at 2070 discards the sign, so negative values print as positive. And the `TAB 9-long` at line 210 goes negative if you answer the “How long is the longest number?” prompt with anything above 9 — the program’s own opening screen says it handles up to 9 characters, and it means it.