ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Lesson 7 Part 130 F-PC 3.5 Tutorial by Jack Brown º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Control Your Printer with CREATE ... DOES> ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Here is another application of CREATE ... DOES> . Remember that this idea of extending the compiler is new and unheard of in other languages. You will have to become familiar with all of the examples I have presented and then try to think of variations or application of the ideas to new areas. You just bought a fancy EPSON FX85+ printer (or one of the many clones). It comes with a manual 1.5 inches thick documenting all the features and the escape sequences necessary to activate them. Some of features require only one control code, some require 2 codes to be sent and yet others require more than 2 codes. Here is the defining word that will create printer extensions. We are using EPSON FX85 printer control sequences for the examples. Usage would be as follows: 1) Only one code to be sent. 15 1 FEATURE COMPRESSED \ 15 or ^O is the EPSON code for this mode. 2) Two codes must be sent. Note that the order of the codes is the reverse of the order they will be sent. 64 27 2 FEATURE EPSON-RESET \ 27 64 , or ESC @ will resets printer. 3) Three codes required. 49 78 27 3 FEATURE NEAR-LETTER-QUALITY \ 27 78 49 or ESC "x1" will put FX85+ into NLQ mode. k) If k codes were required you would follow the pattern below always with the codes in the reverse order from the manual. ie reverse polish notation! If you look at the definition you will see that since the top stack number is compiled first they will actually be compiled in the correct order in memory. n1 n2 ... nk k FEATURE \ Print feature defining word. : FEATURE ( n1 n2...nk k -- ) \ Below is the compile time routine. CREATE DUP C, \ Duplicate and compile the number of codes. 0 ?DO C, LOOP \ Compile k codes to be sent to the printer \ This is the run time routine. DOES> COUNT \ Fetch number of codes and increment address. 0 ?DO COUNT \ Fetch a code. (PRINT) \ Send code to printer only. LOOP ; \ Loop till all codes sent. Notes: 1) The word COUNT ( addr addr+1 char ) actually fetches the byte stored at addr and then increments addr by 1. Its definition would be : COUNT DUP 1+ SWAP C@ ; 2) (PRINT) is an F-PC word that emits or sends the character corresponding to the top stack number to the printer only. Now all you have to do is go through the control code reference card at the end of the manual and make words for each series of codes. You can even combine features. ASCII M 27 ASCII E 27 ASCII @ 27 6 FEATURE EMPHASIZED-ELITE This will reset the printer, put it in emphasized mode, and select elite pitch. ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· º Problem 7.10 º ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄĽ a) Test FEATURE and provide examples of several other commands. b) Make a version of FEATURE that can send ANSI codes to the console. To test your word you will have to turn off F-PC direct screen writes by using the command SLOW. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Please Move to Lesson 7 Part 140 ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ