--- title: "TS2068 BASIC Tutor" type: "article" slug: "ts2068-basic-tutor-5" url: "http://localhost/article/ts2068-basic-tutor-5/" markdown_url: "http://localhost/article/ts2068-basic-tutor-5.md" published_at: "2026-07-28T21:52:01+00:00" modified_at: "2026-07-29T05:51:41+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "ATTRIBUTES & PRINT POSITION In the last issue we discussed the limitations of SCREEN$ in detecting and/or recognizing the presence of a character in the PRINT POSITION. We further defined PRINT POSITION as that block on the 32 X 24 grid of the screen where the very next character will be printed. PRINT POSITION is…" category: - name: "Quarters" slug: "quarters" taxonomy: "category" url: "http://localhost/category/periodicals/quarters/" 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: "Warren Fricke" slug: "warren-fricke" taxonomy: "indiv" url: "http://localhost/indiv/warren-fricke/" publication: "QuarTerS" publication_r: id: 21505 title: "QuarTerS" type: "periodical" url: "http://localhost/periodical/quarters/" authors_r: - name: "Warren Fricke" slug: "warren-fricke" taxonomy: "indiv" url: "http://localhost/indiv/warren-fricke/" issues_articles: - id: 37930 title: "Quarters Fall 1985" type: "issue" url: "http://localhost/issue/quarters-fall-1985/" pages: "10-11" pubdate: "Fall 1985" archive_link: false --- ### ATTRIBUTES & PRINT POSITION In the last issue we discussed the limitations of `SCREEN$` in detecting and/or recognizing the presence of a character in the PRINT POSITION. We further defined PRINT POSITION as that block on the 32 X 24 grid of the screen where the very next character will be printed. PRINT POSITION is an important concept in many game programs written in BASIC. We introduced a short program called FOUR-DIRECTION MOVEMENT to demonstrate how `SCREEN$` could be used to detect the presence of various characters occupying, or not occupying, the position. As we found `SCREEN$` cannot recognize all characters, we will embark on a course introducing other methods that will. No one of these methods covers all situations, but collectively they virtually do. The second of these methods of PRINT POSITION detection that we will explore uses the ATTRIBUTES. So instead of looking for a target identified by a character code or symbol, we will look for one identified by its ATTRIBUTES. Before we go further, a short review of the ATTRIBUTES may be in order. Each of the 32 X 24 blocks of the screen is assigned an address from 22528 to 23295, inclusive. Each address is an 8-bit byte of memory that can hold a value from 0 to 255. These values in turn can completely describe the ATTRibute value of the block. We show this relationship in the following diagram: [![Image](http://localhost/wp-content/uploads/2026/07/fricke-attributes-1024x820.png)](http://localhost/wp-content/uploads/2026/07/fricke-attributes.png) We can summarize all of this by a formula that yields the ATTR value: ``` ATTR Value = 128(FLASH) + 64(BRIGHT) + 8(PAPER) + (INK) ``` The first two terms usually do not enter into print position determinations and can be considered to be OFF or 0 for our present purpose. This reduces the formula to: ``` ATTR Value = 8(PAPER) + (INK) ``` Or, as we might use the formula in a BASIC routine, to: ``` ATTR (L,C) = 8 * p + i ``` Let’s consider targets made up in PAPER color only. INK would have a default value of 0, which is BLACK. We can next revise our demonstration routine to look like FIGURE 1. Only three lines of the program are involved. Line 2 requests INPUT of the PAPER color of the target. Line 6 prints the randomly located targets in the designated color. Line 70 now looks at the ATTR value of the PRINT POSITION and takes action accordingly. RUN the program. For INPUT enter some PAPER color that can be seen well against the normal WHITE of the screen, say any value from 1, BLUE, to 6, YELLOW. Move the puck about as before and it now responds to the ATTR value of the PAPER color. ``` 2 INPUT p 4 FOR n=1 TO 35 6 PRINT AT 21*RND,31*RND; PAPER p;" " 8 NEXT n 10 LET L=10: LET C=15 30 LET LL=L: LET CC=C 40 LET L=L+(INKEY$="6" AND L<21)-(INKEY$="7" AND L>0) 50 LET C=C+(INKEY$="8" AND C<31)-(INKEY$="5" AND C>0) 60 PRINT AT L,C; 70 IF ATTR (L,C)=8*p+0 THEN BEEP .05,25 80 PRINT "*" 90 PRINT AT LL,CC;" " AND (LL<>L OR CC<>C) 100 GO TO 30 ``` We can have the entire screen in full color, and have the target made up of unique PAPER and INK colors. Such a program is shown in FIGURE 2. Compare the two programs line for line. Line 1 is an addition. It adds complete color to the screen. Line 2 adds an INPUT for INK. This is the target INK. Line 6 introduces a character for the target, versus a colored space alone. Line 70 now contains variables for both PAPER and INK colors. RUN the program and for INPUT of the colors, use 4 or 5 for PAPER and 1 or 2 for INK. Any values can be used but some combinations do not have enough contrast to see well. ``` 1 BORDER 1: PAPER 6: INK 2: CLS 2 INPUT p: INPUT i 4 FOR n=1 TO 35 6 PRINT AT 21*RND,31*RND; PAPER p; INK i;"O" 8 NEXT n 10 LET L=10: LET C=15 30 LET LL=L: LET CC=C 40 LET L=L+(INKEY$="6" AND L<21)-(INKEY$="7" AND L>0) 50 LET C=C+(INKEY$="8" AND C<31)-(INKEY$="5" AND C>0) 60 PRINT AT L,C; 70 IF ATTR (L,C)=8*p+i THEN BEEP .05,25 80 PRINT "*" 90 PRINT AT LL,CC;" " AND (LL<>L OR CC<>C) 100 GO TO 30 ``` PRINT POSITION determined by the use of ATTRibutes is perhaps the most versatile of all the methods available on the TS2068. Note that we could have used any character in the routine of figure 2 for a target, even a User Defined Graphic or chunky graphic. ATTRibutes also combine very well with the CODE of characters and the combination allows for some fancy detection. For example, consider a line reading: ``` 70 IF ATTR (L,C) = 34 AND CODE SCREEN$ (L,C) = 79 THEN... ``` Doesn’t this make the creative juices flow? ### ATTRIBUTES ADDRESSES For those who expect to do much work with the ATTRibutes, the following relationships may be useful: ``` A = 22528 + 32*L + C ``` And the converse: ``` L = INT((A - 22528)/32) C = A - (32*L + 22528) ``` Given here in the BASIC terminology where L is the screen line number and C is the column.