--- title: "Attr Table" id: 54562 type: "computer_media" slug: "attr-table" url: "http://localhost/computer_media/attr-table/" markdown_url: "http://localhost/computer_media/attr-table.md" published_at: "2024-06-02T17:36:24+00:00" modified_at: "2026-03-30T21:40:59+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2019/02/20230809-041332.jpg" excerpt: "A handy on-screen reference table renders all 64 paper and ink color combinations, showing their attribute byte values styled in the actual colors they represent." 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 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Roger Valentine" slug: "roger-valentine" taxonomy: "indiv" url: "http://localhost/indiv/roger-valentine/" genre: - name: "Utility" slug: "utility" taxonomy: "genre" url: "http://localhost/type/utility/" media_contents: - id: 51214 title: "CATS Library Tape 8" type: "computer_media" url: "http://localhost/computer_media/cats-library-tape-8/" - id: 55923 title: "Timex Sinclair Public Domain Library Tape 2003" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-2003/" media_type: "Program" programmers: - name: "Roger Valentine" slug: "roger-valentine" taxonomy: "indiv" url: "http://localhost/indiv/roger-valentine/" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/06/SCR-20240714-emsn.png" related_content: - id: 20956 title: "The Timex Sinclair 2068: what can you do with it?" type: "book" url: "http://localhost/book/the-timex-sinclair-2068-what-can-you-do-with-it/" media_type_tags: "Utility" --- # Attr Table This program displays a visual reference table of all 64 paper/ink color attribute combinations available on the Timex 2068. It uses nested FOR loops to iterate through all eight paper colors (outer loop, variable j) and all eight ink colors (inner loop, variable k), printing the two-digit attribute byte value (8*j+k) styled with the corresponding PAPER and INK colors at calculated screen positions. The column headers show color swatches for paper colors across the top and down the left side using CHR$ 32 (space) filled with the appropriate paper color. The attribute value string is right-aligned to two characters using STR$ and a leading space inserted when the value is a single digit. Entered from [Roger Valentine’s book The Timex Sinclair 2068](http://localhost/book/the-timex-sinclair-2068-what-can-you-do-with-it/). *** ## Program Analysis ### Program Structure The program is a short display utility organized into three logical phases: 1. **Setup (lines 15):** Sets BRIGHT mode, clears the screen, and prints a header row with “PAPER”, “INK” labels and color swatches. 2. **Main table generation (lines 20–90):** Two nested `FOR` loops render color swatches along the axes and the attribute byte values in all 64 paper/ink combinations. 3. **Termination and save (lines 100, 9998–9999):** Halts execution normally; the high-numbered lines handle saving and verifying the program. ### Screen Layout Logic The outer loop variable `j` (0–7) represents the paper color and drives the column index. The inner loop variable `k` (0–7) represents the ink color and drives the row index. Each cell is positioned using `AT k*2+5, j*3+6`, placing rows at every other screen row (starting at row 5) and columns at every third character position (starting at column 6). This spacing ensures each two-character attribute value fits without overlap. Lines 30 and 40 draw the axis labels: line 30 prints two space characters (`CHR$ 32`) with the appropriate paper color at the top of each column, and line 40 prints a single paper-colored space on the left side of each row, forming a simple color-coded axis. ### Key BASIC Idioms - **Attribute byte calculation:** The formula `8*j+k` correctly computes the attribute byte value for a given paper (`j`) and ink (`k`) combination, since paper occupies bits 3–5 (multiplied by 8) and ink occupies bits 0–2. - **String right-alignment:** Line 60 uses `STR$` to convert the numeric value to a string, then prepends a space if the length is 1, ensuring all values display as two characters for clean column alignment. - **BRIGHT 0 override:** Each `PRINT` statement explicitly sets `BRIGHT 0` to suppress the global `BRIGHT 1` set at line 15, preventing bright attribute colors from interfering with the displayed swatches. - **CHR$ 32 for colored blocks:** Rather than printing a visible character, `CHR$ 32` (space) is printed with a specific `PAPER` color to render a solid color swatch without any foreground glyph. ### Variable Summary | Variable | Role | | --- | --- | | `j` | Outer loop counter; paper color index (0–7) | | `k` | Inner loop counter; ink color index (0–7) | | `a$` | Formatted two-character string of the attribute byte value | ### Notable Techniques The header line at line 15 uses embedded block graphic characters (the `'''''''''"I"''"N"''"K"` sequence) as a visual separator or decorative element alongside the “PAPER” and “INK” labels. The use of `TAB 15` centers the header approximately over the table columns. The `SAVE "ATTR TABLE" LINE 10` at line 9998 stores the program with an auto-run start address of line 10, bypassing the REM comment header lines and jumping directly into the display initialization at line 15 (since line 10 does not exist and execution falls through to the next available line). ### Bugs and Anomalies There are no significant bugs. The `STOP` at line 100 cleanly halts the program after the table is drawn, which is appropriate since there is no user interaction loop. The program faithfully implements its stated purpose as a printed reference tool from the book *The Timex Sinclair 2068* by Roger Valentine. ## Source Code ``` 1 REM 2 REM 3 REM ATTRIBUTES TABLE 4 REM FOR THE TIMEX 2068 6 REM TAKEN FROM THE BOOK 7 REM "THE TIMEX 9 REM SINCLAIR 2068" 10 REM 11 REM BY ROGER VALENTINE 12 REM ENTERED BY 13 REM G.F. CHAMBERS 14 REM 15 BRIGHT 1: CLS : PRINT TAB 15;" PAPER "'''''''''"I"''"N"''"K" 20 FOR j=0 TO 7 30 PRINT AT 2,j*3+6; PAPER j; BRIGHT 0;CHR$ 32;CHR$ 32 40 PRINT AT j*2+5,2; PAPER j; BRIGHT 0;CHR$ 32 50 FOR k=0 TO 7 60 LET a$=STR$ (8*j+k): IF LEN a$=1 THEN LET a$=CHR$ 32+a$ 70 PRINT PAPER j; INK k; BRIGHT 0;AT k*2+5,j*3+6;a$ 80 NEXT k 90 NEXT j 100 STOP 9998 SAVE "ATTR TABLE" LINE 10 9999 VERIFY "" ```