--- title: "Two Tips: Colors, VAL$" type: "article" slug: "two-tips-colors-val" url: "http://localhost/article/two-tips-colors-val/" markdown_url: "http://localhost/article/two-tips-colors-val.md" published_at: "2022-10-07T12:28:11+00:00" modified_at: "2026-08-08T22:40:03+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "First the Colors I modified Paul Banisik's \"Second display file initialization routine\" from the April RAMTOP (1985), and incorporated it into a BASIC program that would poke attribute values into the second display file. To access this display mode, type \"OUT 255,2\". In this mode, the computer looks at the first display file (D_File_1) for…" category: - name: "The RAMTOP" slug: "the-ramtop" taxonomy: "category" url: "http://localhost/category/periodicals/the-ramtop/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "Reference" slug: "reference" taxonomy: "post_tag" url: "http://localhost/tag/reference/" - 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: "Gabe Schaffer" slug: "gabe-schaffer" taxonomy: "indiv" url: "http://localhost/indiv/gabe-schaffer/" publication_r: id: 39272 title: "The RAMTOP" type: "periodical" url: "http://localhost/periodical/the-ramtop/" authors: "Gabe Schaffer" authors_r: - name: "Gabe Schaffer" slug: "gabe-schaffer" taxonomy: "indiv" url: "http://localhost/indiv/gabe-schaffer/" issues_articles: - id: 39861 title: "The RAMTOP Dec 1985" type: "issue" url: "http://localhost/issue/the-ramtop-dec-1985/" pages: "6" pubdate: "December 1985" archive_link: false --- # Two Tips: Colors, VAL$ ### First the Colors I modified Paul Banisik’s “Second display file initialization routine” from the April RAMTOP (1985), and incorporated it into a BASIC program that would poke attribute values into the second display file. To access this display mode, type “OUT 255,2”. In this mode, the computer looks at the first display file (D_File_1) for character bytes, which means that all you have to do to print a character on the screen is use a simple “PRINT” statement just as if you were in a regular display mode. But the computer looks at the second display file (D_FILE_2) for the attributes, which enables you to have 8 colors in one character (don’t forget that display file 2 is set up just like the first display file, 8 bytes per character, or in this case 8 colors per character). Also, don’t forget that all of the attributes have to be POKEd and that the characters can either be printed or POKEd. Notes: Do not start poking into the second display file until it is CLEARed using Paul’s initialize routine or the system may crash. When you first enter this display mode and the second display file has been cleared, you will see nothing on the screen because the display, or in this case the attribute file, contains zeros (black ink on black paper). ``` 10 CLEAR 55999: INPUT "Screen color ";s: IF s<0 OR s>255 OR s<>INTO s THEN GO TO 10 20 GO SUB 200: POKE 23624,s: RANDOMIZE USR 56000 30 DIM b(8): FOR a=1 TO 8 40 INPUT "Attribute byte#";(a);" ";b(a): IF b(a)<0 OR b(a)>255 OR b(a)<>INT b(a) THEN GO TO 40 50 NEXT a 60 INPUT "Row ";r: IF r<0 OR r>21 or r<>INT r THEN GO TO 60 70 INPUT "Column ";c: IF c<0 OR c>31 OR c<>INT c THEN GO TO 70 80 INPUT "1character,2bytes to character";ch: IF ch<>1 AND ch<>2 THEN GO TO 80 90 IF ch=1 THEN INPUT "Character ";a$: IF LEN a$<1 THEN GO TO 90 100 IF ch=2 THEN GO SUB 170 110 LET g=INT (r/8): LET rc=(2048*g+((r-(g*))*32))+c 120 OUT 255,2: LET i=1: FOR f=rc+24576 TO rc+24576+1792 STEP 256: POKE f,b(i): LET i=i+1: NEXT f 130 IF ch=1 THEN PRINT AT r,c;a$: GO TO 150 140 LET i=1: FOR f=rc+16384 TO rc+16384+1792 SETP 256: POKE f,h(i): LET i=i+1: NEXT f 150 GO TO 30 170 DIM h(8): FOR a=1 TO 8 180 INPUT "Character bytes#";(a);" ";h(a): IF h(a)<0 OR h(a)>255 OR h(a)<>INT h(a) THEN GO TO 180 190 NEXT a: RETURN 200 RESTORE: FOR a=56000 TO 56034: READ b: POKE a,b: NEXT a: RETURN 210 DATA 62,198,211,255,62,3,211,244,62, 6,205,142,14,62,2,211,255,62,0,211,244: REM Paul's CLEAR second display file routine 220 DATA 33,0,96,54,s,229,209,19,1,255, 23,237,176,201: REM Routine to POKE total second display file with number specified ``` ### Now for VAL$ This is really nothing but a string ($) version of VAL. Try this demo program. ``` 10 LET a$="SCREEN$ (0,0)": REM The "SCREEN$" must be the FUNCTION and NOT spelled out 20 PRINT AT 0,0; "A" 30 PRINT a$ 40 PRINT VAL$ a$ 50 PRINT VAL$ "SCREEN$ (0,0)" 60 PRINT VAL as ``` The results should be: ``` A SCREEN$ (0,0) A A ``` With error code C. The first “A” is from the first PRINT statement. The “SCREEN$ (0,0) ” is what you get from PRINting the contents of a$. The next “A” comes from printing the VALS of af or executing a$. The third “A” comes from executing the literal “SCREENS$ (0,0)” which is equal to the variable a$. The error code comes from PRINTing the VALue of a$ which doesn’t really have a value in our case but can be only printed or executed. So if the command has a “$” at the end, you use: VAL$. If the command does not have the “$”, use VAL. NOTE: With VAL, you may use any number, a number producing command (within quotes), or a variable. Whereas with the VAL$ function, you may use a plain string variable (within quotes) or a command that does NOT produce a number (within quotes).