Home » Personal collection » Acorn DFS disks » dfs_box03_disk13_bcpl_calc.scp » EXCL2B
EXCL2B
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Personal collection » Acorn DFS disks » dfs_box03_disk13_bcpl_calc.scp |
Filename: | EXCL2B |
Read OK: | ✔ |
File size: | 1924 bytes |
Load address: | 21DFC |
Exec address: | 0006 |
File contents
SECTION "EXCL2B" // Floating/fixed point calculator - common procedures 2. // The calculation procedures used are // copyright Richards Computer Products Ltd. (C) 1983 // Written by C Jobson 19/04/83 // Contains GETCH and GETNUM. GET "LIBHDR" GET "FPHDR" GET "EXCLHDR" // GETCH is called to read the next keystroke. The character read is // stored in CH and its classification is stored in CHTYPE. For // convenience the result of the procedure is also CHTYPE. Invalid // keystrokes are ignored and ';' and ':' are converted to '+' and '*' // respectively. The swapping of functions by pressing f0 is handled // entirely within this procedure. LET GETCH() = VALOF $( CH := CAPCH(RDBIN()) // treat e and x like E and X SWITCHON CH INTO $( CASE 'X': // exit MODE(7) // to restore cursor STOP(0) CASE '=': CASE 13: // 13 is RETURN CHTYPE := T.EQUALS ENDCASE CASE ';': // convert ';' to '+' CH := '+' CASE '+': CHTYPE := T.OP ENDCASE CASE ':': // convert ':' to '*' CH := '**' CASE '**': CASE '/': CHTYPE := T.OP ENDCASE CASE 127: // 127 is delete CHTYPE := T.CLEAR ENDCASE CASE '-': CHTYPE := T.MINUS ENDCASE CASE '0': CASE '1': CASE '2': CASE '3': CASE '4': CASE '5': CASE '6': CASE '7': CASE '8': CASE '9': CASE 'E': CASE '.': CHTYPE := T.NUMCH ENDCASE CASE FIRSTFN: // f0 is always used to swap functions FNSET := (FNSET+1) REM (FNSETMAX+1) DISPFNS() // display new functions & update MAXFN LOOP // back for next character DEFAULT: TEST FIRSTFN+1 <= CH <= MAXFN THEN CHTYPE := INTERPFN() // if valid function key interpret it ELSE LOOP // invalid character - ignore it $) RESULTIS CHTYPE $) REPEAT // GETNUM is called to read a number. While a number is being read in // it is displayed as typed (rather than in a standard format). The // 'clear' function is handled entirely within this procedure. On // entry CH contains the first character of the number. On exit the // next character read should be the terminator of the number. AND GETNUM(NUM) BE $( LET COUNT = 0 // number of characters read LET NEG.VALID = STATE = S.NUM2 & (OP='**' | OP='/') // true if leading '-' is allowed (e.g. in // situations such as '123 * -456 =' LET NUMSTR = VEC NUMWIDTH/2 // holds the characters typed in (up to 17) LET NUMVEC = VEC FP.LEN $( SWITCHON CHTYPE INTO $( // Function like pi or e - overwrite any characters entered // already (but allow for cases like '123 * -pi') and return. CASE T.NUMOP: FUNCOP(NUM) // get the value IF COUNT=1 & NUMSTR%1 = '-' THEN FNEG(NUM, NUM) WRITENUM(NUM, 0) // display it RETURN // Effect of clear depends on whether any characters entered // yet - if so just cancel them - if not do a reset. CASE T.CLEAR: IF COUNT = 0 THEN RESET() // which LONGJUMPS back to START COUNT := 0 ENDCASE // Handle other cases. '-' entered as first character is a // special case - it may be valid (e.g. in '123 * -456'). If // it is not valid then it must be treated as an operator // entered when a number was expected. In such a case jump // back to START having first 'unread' the character so that // it can be processed in the normal way. DEFAULT: IF (CH = '-') & (COUNT = 0) & (NOT NEG.VALID) THEN $( UNRDCH() LONGJUMP(RES.LEV, RES.LAB) $) // Set up string of characters entered so far and see if // it forms a valid number. If this is the 18th character // it replaces the 17th provided that it is valid. FPEXCEP := 0 TEST COUNT = NUMWIDTH THEN $( LET OLDCH = NUMSTR%NUMWIDTH NUMSTR%NUMWIDTH := CH FLIT(NUMSTR, NUMVEC) // If invalid replace old 17th character else decrement // code so code below (which increments it) works. TEST FPEXCEP NE 0 THEN NUMSTR%NUMWIDTH := OLDCH ELSE COUNT := NUMWIDTH-1 $) ELSE $( NUMSTR%(COUNT+1) := CH NUMSTR%0 := COUNT+1 FLIT(NUMSTR, NUMVEC) $) // If string not a valid number but last character entered // is a numeric character (i.e. 0-9, E or '.') then just // ignore it. Otherwise treat the invalid character as // terminating the number so 'unread' it. If no // characters have been entered (or only '-' has been // entered) then LONGJUMP back to START as if this // procedure had never been called. Otherwise return the // number entered. IF FPEXCEP NE 0 THEN $( IF CHTYPE = T.NUMCH THEN ENDCASE // ignore invalid numeric characters UNRDCH() IF COUNT = 0 | (COUNT = 1 & NUMSTR%1 = '-') THEN LONGJUMP(RES.LEV, RES.LAB) NUMSTR%0 := COUNT // ignore latest character FLIT(NUMSTR, NUM) // set up NUM RETURN $) // Character valid so leave it in string. COUNT := COUNT+1 $) // Display string and go back to get next character (but display // an empty string as '0'). NUMPOS() // position cursor WRBIN(137) // cancel flashing FOR J = 1 TO (COUNT=0 -> NUMWIDTH-1, NUMWIDTH-COUNT) DO WRCH('*S') TEST COUNT = 0 THEN WRCH('0') ELSE FOR J = 1 TO COUNT DO WRCH(NUMSTR%J) COPYL1L2() // 2nd line of double height display GETCH() $) REPEAT $)
00000000 53 45 43 54 49 4f 4e 20 22 45 58 43 4c 32 42 22 |SECTION "EXCL2B"| 00000010 0d 0a 0d 0a 2f 2f 20 46 6c 6f 61 74 69 6e 67 2f |....// Floating/| 00000020 66 69 78 65 64 20 70 6f 69 6e 74 20 63 61 6c 63 |fixed point calc| 00000030 75 6c 61 74 6f 72 20 2d 20 63 6f 6d 6d 6f 6e 20 |ulator - common | 00000040 70 72 6f 63 65 64 75 72 65 73 20 32 2e 0d 0a 2f |procedures 2.../| 00000050 2f 20 54 68 65 20 63 61 6c 63 75 6c 61 74 69 6f |/ The calculatio| 00000060 6e 20 70 72 6f 63 65 64 75 72 65 73 20 75 73 65 |n procedures use| 00000070 64 20 61 72 65 0d 0a 2f 2f 20 63 6f 70 79 72 69 |d are..// copyri| 00000080 67 68 74 20 52 69 63 68 61 72 64 73 20 43 6f 6d |ght Richards Com| 00000090 70 75 74 65 72 20 50 72 6f 64 75 63 74 73 20 4c |puter Products L| 000000a0 74 64 2e 20 28 43 29 20 31 39 38 33 0d 0a 2f 2f |td. (C) 1983..//| 000000b0 20 57 72 69 74 74 65 6e 20 62 79 20 43 20 4a 6f | Written by C Jo| 000000c0 62 73 6f 6e 20 20 31 39 2f 30 34 2f 38 33 0d 0a |bson 19/04/83..| 000000d0 0d 0a 2f 2f 20 43 6f 6e 74 61 69 6e 73 20 47 45 |..// Contains GE| 000000e0 54 43 48 20 61 6e 64 20 47 45 54 4e 55 4d 2e 0d |TCH and GETNUM..| 000000f0 0a 0d 0a 47 45 54 20 22 4c 49 42 48 44 52 22 0d |...GET "LIBHDR".| 00000100 0a 47 45 54 20 22 46 50 48 44 52 22 0d 0a 47 45 |.GET "FPHDR"..GE| 00000110 54 20 22 45 58 43 4c 48 44 52 22 0d 0a 0d 0a 0d |T "EXCLHDR".....| 00000120 0a 2f 2f 20 47 45 54 43 48 20 69 73 20 63 61 6c |.// GETCH is cal| 00000130 6c 65 64 20 74 6f 20 72 65 61 64 20 74 68 65 20 |led to read the | 00000140 6e 65 78 74 20 6b 65 79 73 74 72 6f 6b 65 2e 20 |next keystroke. | 00000150 20 54 68 65 20 63 68 61 72 61 63 74 65 72 20 72 | The character r| 00000160 65 61 64 20 69 73 0d 0a 2f 2f 20 73 74 6f 72 65 |ead is..// store| 00000170 64 20 69 6e 20 43 48 20 61 6e 64 20 69 74 73 20 |d in CH and its | 00000180 63 6c 61 73 73 69 66 69 63 61 74 69 6f 6e 20 69 |classification i| 00000190 73 20 73 74 6f 72 65 64 20 69 6e 20 43 48 54 59 |s stored in CHTY| 000001a0 50 45 2e 20 20 46 6f 72 0d 0a 2f 2f 20 63 6f 6e |PE. For..// con| 000001b0 76 65 6e 69 65 6e 63 65 20 74 68 65 20 72 65 73 |venience the res| 000001c0 75 6c 74 20 6f 66 20 74 68 65 20 70 72 6f 63 65 |ult of the proce| 000001d0 64 75 72 65 20 69 73 20 61 6c 73 6f 20 43 48 54 |dure is also CHT| 000001e0 59 50 45 2e 20 20 49 6e 76 61 6c 69 64 0d 0a 2f |YPE. Invalid../| 000001f0 2f 20 6b 65 79 73 74 72 6f 6b 65 73 20 61 72 65 |/ keystrokes are| 00000200 20 69 67 6e 6f 72 65 64 20 61 6e 64 20 27 3b 27 | ignored and ';'| 00000210 20 61 6e 64 20 27 3a 27 20 61 72 65 20 63 6f 6e | and ':' are con| 00000220 76 65 72 74 65 64 20 74 6f 20 27 2b 27 20 61 6e |verted to '+' an| 00000230 64 20 27 2a 27 0d 0a 2f 2f 20 72 65 73 70 65 63 |d '*'..// respec| 00000240 74 69 76 65 6c 79 2e 20 20 54 68 65 20 73 77 61 |tively. The swa| 00000250 70 70 69 6e 67 20 6f 66 20 66 75 6e 63 74 69 6f |pping of functio| 00000260 6e 73 20 62 79 20 70 72 65 73 73 69 6e 67 20 66 |ns by pressing f| 00000270 30 20 69 73 20 68 61 6e 64 6c 65 64 0d 0a 2f 2f |0 is handled..//| 00000280 20 65 6e 74 69 72 65 6c 79 20 77 69 74 68 69 6e | entirely within| 00000290 20 74 68 69 73 20 70 72 6f 63 65 64 75 72 65 2e | this procedure.| 000002a0 0d 0a 0d 0a 4c 45 54 20 47 45 54 43 48 28 29 20 |....LET GETCH() | 000002b0 3d 20 56 41 4c 4f 46 0d 0a 24 28 20 43 48 20 3a |= VALOF..$( CH :| 000002c0 3d 20 43 41 50 43 48 28 52 44 42 49 4e 28 29 29 |= CAPCH(RDBIN())| 000002d0 20 20 20 20 2f 2f 20 74 72 65 61 74 20 65 20 61 | // treat e a| 000002e0 6e 64 20 78 20 6c 69 6b 65 20 45 20 61 6e 64 20 |nd x like E and | 000002f0 58 0d 0a 20 20 20 53 57 49 54 43 48 4f 4e 20 43 |X.. SWITCHON C| 00000300 48 20 49 4e 54 4f 0d 0a 20 20 20 24 28 20 43 41 |H INTO.. $( CA| 00000310 53 45 20 27 58 27 3a 20 20 20 20 20 20 20 20 20 |SE 'X': | 00000320 20 20 20 2f 2f 20 65 78 69 74 0d 0a 20 20 20 20 | // exit.. | 00000330 20 20 20 20 20 4d 4f 44 45 28 37 29 20 20 20 20 | MODE(7) | 00000340 20 20 20 20 20 20 20 2f 2f 20 74 6f 20 72 65 73 | // to res| 00000350 74 6f 72 65 20 63 75 72 73 6f 72 0d 0a 20 20 20 |tore cursor.. | 00000360 20 20 20 20 20 20 53 54 4f 50 28 30 29 0d 0a 0d | STOP(0)...| 00000370 0a 20 20 20 20 20 20 43 41 53 45 20 27 3d 27 3a |. CASE '=':| 00000380 20 43 41 53 45 20 31 33 3a 20 20 20 2f 2f 20 31 | CASE 13: // 1| 00000390 33 20 69 73 20 52 45 54 55 52 4e 0d 0a 20 20 20 |3 is RETURN.. | 000003a0 20 20 20 20 20 20 43 48 54 59 50 45 20 3a 3d 20 | CHTYPE := | 000003b0 54 2e 45 51 55 41 4c 53 0d 0a 20 20 20 20 20 20 |T.EQUALS.. | 000003c0 20 20 20 45 4e 44 43 41 53 45 0d 0a 0d 0a 20 20 | ENDCASE.... | 000003d0 20 20 20 20 43 41 53 45 20 27 3b 27 3a 20 20 20 | CASE ';': | 000003e0 20 20 20 20 20 20 20 20 20 2f 2f 20 63 6f 6e 76 | // conv| 000003f0 65 72 74 20 27 3b 27 20 74 6f 20 27 2b 27 0d 0a |ert ';' to '+'..| 00000400 20 20 20 20 20 20 20 20 20 43 48 20 3a 3d 20 27 | CH := '| 00000410 2b 27 0d 0a 20 20 20 20 20 20 43 41 53 45 20 27 |+'.. CASE '| 00000420 2b 27 3a 0d 0a 20 20 20 20 20 20 20 20 20 43 48 |+':.. CH| 00000430 54 59 50 45 20 3a 3d 20 54 2e 4f 50 0d 0a 20 20 |TYPE := T.OP.. | 00000440 20 20 20 20 20 20 20 45 4e 44 43 41 53 45 0d 0a | ENDCASE..| 00000450 0d 0a 20 20 20 20 20 20 43 41 53 45 20 27 3a 27 |.. CASE ':'| 00000460 3a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 |: // | 00000470 63 6f 6e 76 65 72 74 20 27 3a 27 20 74 6f 20 27 |convert ':' to '| 00000480 2a 27 0d 0a 20 20 20 20 20 20 20 20 20 43 48 20 |*'.. CH | 00000490 3a 3d 20 27 2a 2a 27 0d 0a 20 20 20 20 20 20 43 |:= '**'.. C| 000004a0 41 53 45 20 27 2a 2a 27 3a 20 43 41 53 45 20 27 |ASE '**': CASE '| 000004b0 2f 27 3a 0d 0a 20 20 20 20 20 20 20 20 20 43 48 |/':.. CH| 000004c0 54 59 50 45 20 3a 3d 20 54 2e 4f 50 0d 0a 20 20 |TYPE := T.OP.. | 000004d0 20 20 20 20 20 20 20 45 4e 44 43 41 53 45 0d 0a | ENDCASE..| 000004e0 0d 0a 20 20 20 20 20 20 43 41 53 45 20 31 32 37 |.. CASE 127| 000004f0 3a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 |: // | 00000500 31 32 37 20 69 73 20 64 65 6c 65 74 65 0d 0a 20 |127 is delete.. | 00000510 20 20 20 20 20 20 20 20 43 48 54 59 50 45 20 3a | CHTYPE :| 00000520 3d 20 54 2e 43 4c 45 41 52 0d 0a 20 20 20 20 20 |= T.CLEAR.. | 00000530 20 20 20 20 45 4e 44 43 41 53 45 0d 0a 0d 0a 20 | ENDCASE.... | 00000540 20 20 20 20 20 43 41 53 45 20 27 2d 27 3a 0d 0a | CASE '-':..| 00000550 20 20 20 20 20 20 20 20 20 43 48 54 59 50 45 20 | CHTYPE | 00000560 3a 3d 20 54 2e 4d 49 4e 55 53 0d 0a 20 20 20 20 |:= T.MINUS.. | 00000570 20 20 20 20 20 45 4e 44 43 41 53 45 0d 0a 0d 0a | ENDCASE....| 00000580 20 20 20 20 20 20 43 41 53 45 20 27 30 27 3a 20 | CASE '0': | 00000590 43 41 53 45 20 27 31 27 3a 20 43 41 53 45 20 27 |CASE '1': CASE '| 000005a0 32 27 3a 20 43 41 53 45 20 27 33 27 3a 20 43 41 |2': CASE '3': CA| 000005b0 53 45 20 27 34 27 3a 0d 0a 20 20 20 20 20 20 43 |SE '4':.. C| 000005c0 41 53 45 20 27 35 27 3a 20 43 41 53 45 20 27 36 |ASE '5': CASE '6| 000005d0 27 3a 20 43 41 53 45 20 27 37 27 3a 20 43 41 53 |': CASE '7': CAS| 000005e0 45 20 27 38 27 3a 20 43 41 53 45 20 27 39 27 3a |E '8': CASE '9':| 000005f0 0d 0a 20 20 20 20 20 20 43 41 53 45 20 27 45 27 |.. CASE 'E'| 00000600 3a 20 43 41 53 45 20 27 2e 27 3a 0d 0a 20 20 20 |: CASE '.':.. | 00000610 20 20 20 20 20 20 43 48 54 59 50 45 20 3a 3d 20 | CHTYPE := | 00000620 54 2e 4e 55 4d 43 48 0d 0a 20 20 20 20 20 20 20 |T.NUMCH.. | 00000630 20 20 45 4e 44 43 41 53 45 0d 0a 0d 0a 20 20 20 | ENDCASE.... | 00000640 20 20 20 43 41 53 45 20 46 49 52 53 54 46 4e 3a | CASE FIRSTFN:| 00000650 20 20 20 20 20 20 20 20 2f 2f 20 66 30 20 69 73 | // f0 is| 00000660 20 61 6c 77 61 79 73 20 75 73 65 64 20 74 6f 20 | always used to | 00000670 73 77 61 70 20 66 75 6e 63 74 69 6f 6e 73 0d 0a |swap functions..| 00000680 20 20 20 20 20 20 20 20 20 46 4e 53 45 54 20 3a | FNSET :| 00000690 3d 20 28 46 4e 53 45 54 2b 31 29 20 52 45 4d 20 |= (FNSET+1) REM | 000006a0 28 46 4e 53 45 54 4d 41 58 2b 31 29 0d 0a 20 20 |(FNSETMAX+1).. | 000006b0 20 20 20 20 20 20 20 44 49 53 50 46 4e 53 28 29 | DISPFNS()| 000006c0 20 20 20 20 20 20 20 20 20 2f 2f 20 64 69 73 70 | // disp| 000006d0 6c 61 79 20 6e 65 77 20 66 75 6e 63 74 69 6f 6e |lay new function| 000006e0 73 20 26 20 75 70 64 61 74 65 20 4d 41 58 46 4e |s & update MAXFN| 000006f0 0d 0a 20 20 20 20 20 20 20 20 20 4c 4f 4f 50 20 |.. LOOP | 00000700 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 | // | 00000710 62 61 63 6b 20 66 6f 72 20 6e 65 78 74 20 63 68 |back for next ch| 00000720 61 72 61 63 74 65 72 0d 0a 0d 0a 20 20 20 20 20 |aracter.... | 00000730 20 44 45 46 41 55 4c 54 3a 0d 0a 20 20 20 20 20 | DEFAULT:.. | 00000740 20 20 20 20 54 45 53 54 20 46 49 52 53 54 46 4e | TEST FIRSTFN| 00000750 2b 31 20 3c 3d 20 43 48 20 3c 3d 20 4d 41 58 46 |+1 <= CH <= MAXF| 00000760 4e 20 54 48 45 4e 0d 0a 20 20 20 20 20 20 20 20 |N THEN.. | 00000770 20 20 20 20 43 48 54 59 50 45 20 3a 3d 20 49 4e | CHTYPE := IN| 00000780 54 45 52 50 46 4e 28 29 20 2f 2f 20 69 66 20 76 |TERPFN() // if v| 00000790 61 6c 69 64 20 66 75 6e 63 74 69 6f 6e 20 6b 65 |alid function ke| 000007a0 79 20 69 6e 74 65 72 70 72 65 74 20 69 74 0d 0a |y interpret it..| 000007b0 20 20 20 20 20 20 20 20 20 45 4c 53 45 0d 0a 20 | ELSE.. | 000007c0 20 20 20 20 20 20 20 20 20 20 20 4c 4f 4f 50 20 | LOOP | 000007d0 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 6e 76 | // inv| 000007e0 61 6c 69 64 20 63 68 61 72 61 63 74 65 72 20 2d |alid character -| 000007f0 20 69 67 6e 6f 72 65 20 69 74 0d 0a 20 20 20 24 | ignore it.. $| 00000800 29 0d 0a 20 20 20 52 45 53 55 4c 54 49 53 20 43 |).. RESULTIS C| 00000810 48 54 59 50 45 0d 0a 24 29 20 52 45 50 45 41 54 |HTYPE..$) REPEAT| 00000820 0d 0a 0d 0a 0d 0a 2f 2f 20 47 45 54 4e 55 4d 20 |......// GETNUM | 00000830 69 73 20 63 61 6c 6c 65 64 20 74 6f 20 72 65 61 |is called to rea| 00000840 64 20 61 20 6e 75 6d 62 65 72 2e 20 20 57 68 69 |d a number. Whi| 00000850 6c 65 20 61 20 6e 75 6d 62 65 72 20 69 73 20 62 |le a number is b| 00000860 65 69 6e 67 20 72 65 61 64 20 69 6e 0d 0a 2f 2f |eing read in..//| 00000870 20 69 74 20 69 73 20 64 69 73 70 6c 61 79 65 64 | it is displayed| 00000880 20 61 73 20 74 79 70 65 64 20 28 72 61 74 68 65 | as typed (rathe| 00000890 72 20 74 68 61 6e 20 69 6e 20 61 20 73 74 61 6e |r than in a stan| 000008a0 64 61 72 64 20 66 6f 72 6d 61 74 29 2e 20 20 54 |dard format). T| 000008b0 68 65 0d 0a 2f 2f 20 27 63 6c 65 61 72 27 20 66 |he..// 'clear' f| 000008c0 75 6e 63 74 69 6f 6e 20 69 73 20 68 61 6e 64 6c |unction is handl| 000008d0 65 64 20 65 6e 74 69 72 65 6c 79 20 77 69 74 68 |ed entirely with| 000008e0 69 6e 20 74 68 69 73 20 70 72 6f 63 65 64 75 72 |in this procedur| 000008f0 65 2e 20 20 4f 6e 0d 0a 2f 2f 20 65 6e 74 72 79 |e. On..// entry| 00000900 20 43 48 20 63 6f 6e 74 61 69 6e 73 20 74 68 65 | CH contains the| 00000910 20 66 69 72 73 74 20 63 68 61 72 61 63 74 65 72 | first character| 00000920 20 6f 66 20 74 68 65 20 6e 75 6d 62 65 72 2e 20 | of the number. | 00000930 20 4f 6e 20 65 78 69 74 20 74 68 65 0d 0a 2f 2f | On exit the..//| 00000940 20 6e 65 78 74 20 63 68 61 72 61 63 74 65 72 20 | next character | 00000950 72 65 61 64 20 73 68 6f 75 6c 64 20 62 65 20 74 |read should be t| 00000960 68 65 20 74 65 72 6d 69 6e 61 74 6f 72 20 6f 66 |he terminator of| 00000970 20 74 68 65 20 6e 75 6d 62 65 72 2e 0d 0a 0d 0a | the number.....| 00000980 41 4e 44 20 47 45 54 4e 55 4d 28 4e 55 4d 29 20 |AND GETNUM(NUM) | 00000990 42 45 0d 0a 24 28 20 4c 45 54 20 43 4f 55 4e 54 |BE..$( LET COUNT| 000009a0 20 3d 20 30 20 20 20 20 20 2f 2f 20 6e 75 6d 62 | = 0 // numb| 000009b0 65 72 20 6f 66 20 63 68 61 72 61 63 74 65 72 73 |er of characters| 000009c0 20 72 65 61 64 0d 0a 20 20 20 4c 45 54 20 4e 45 | read.. LET NE| 000009d0 47 2e 56 41 4c 49 44 20 3d 20 53 54 41 54 45 20 |G.VALID = STATE | 000009e0 3d 20 53 2e 4e 55 4d 32 20 26 20 28 4f 50 3d 27 |= S.NUM2 & (OP='| 000009f0 2a 2a 27 20 7c 20 4f 50 3d 27 2f 27 29 0d 0a 20 |**' | OP='/').. | 00000a00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000a10 20 20 20 20 2f 2f 20 74 72 75 65 20 69 66 20 6c | // true if l| 00000a20 65 61 64 69 6e 67 20 27 2d 27 20 69 73 20 61 6c |eading '-' is al| 00000a30 6c 6f 77 65 64 20 28 65 2e 67 2e 20 69 6e 0d 0a |lowed (e.g. in..| 00000a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000a50 20 20 20 20 20 2f 2f 20 73 69 74 75 61 74 69 6f | // situatio| 00000a60 6e 73 20 73 75 63 68 20 61 73 20 27 31 32 33 20 |ns such as '123 | 00000a70 2a 20 2d 34 35 36 20 3d 27 0d 0a 20 20 20 4c 45 |* -456 ='.. LE| 00000a80 54 20 4e 55 4d 53 54 52 20 3d 20 56 45 43 20 4e |T NUMSTR = VEC N| 00000a90 55 4d 57 49 44 54 48 2f 32 0d 0a 20 20 20 20 20 |UMWIDTH/2.. | 00000aa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000ab0 2f 2f 20 68 6f 6c 64 73 20 74 68 65 20 63 68 61 |// holds the cha| 00000ac0 72 61 63 74 65 72 73 20 74 79 70 65 64 20 69 6e |racters typed in| 00000ad0 20 28 75 70 20 74 6f 20 31 37 29 0d 0a 20 20 20 | (up to 17).. | 00000ae0 4c 45 54 20 4e 55 4d 56 45 43 20 3d 20 56 45 43 |LET NUMVEC = VEC| 00000af0 20 46 50 2e 4c 45 4e 0d 0a 0d 0a 20 20 20 24 28 | FP.LEN.... $(| 00000b00 20 53 57 49 54 43 48 4f 4e 20 43 48 54 59 50 45 | SWITCHON CHTYPE| 00000b10 20 49 4e 54 4f 0d 0a 20 20 20 20 20 20 24 28 0d | INTO.. $(.| 00000b20 0a 20 20 20 20 20 20 20 20 20 2f 2f 20 46 75 6e |. // Fun| 00000b30 63 74 69 6f 6e 20 6c 69 6b 65 20 70 69 20 6f 72 |ction like pi or| 00000b40 20 65 20 2d 20 6f 76 65 72 77 72 69 74 65 20 61 | e - overwrite a| 00000b50 6e 79 20 63 68 61 72 61 63 74 65 72 73 20 65 6e |ny characters en| 00000b60 74 65 72 65 64 0d 0a 20 20 20 20 20 20 20 20 20 |tered.. | 00000b70 2f 2f 20 61 6c 72 65 61 64 79 20 28 62 75 74 20 |// already (but | 00000b80 61 6c 6c 6f 77 20 66 6f 72 20 63 61 73 65 73 20 |allow for cases | 00000b90 6c 69 6b 65 20 27 31 32 33 20 2a 20 2d 70 69 27 |like '123 * -pi'| 00000ba0 29 20 61 6e 64 20 72 65 74 75 72 6e 2e 0d 0a 0d |) and return....| 00000bb0 0a 20 20 20 20 20 20 20 20 20 43 41 53 45 20 54 |. CASE T| 00000bc0 2e 4e 55 4d 4f 50 3a 0d 0a 20 20 20 20 20 20 20 |.NUMOP:.. | 00000bd0 20 20 20 20 20 46 55 4e 43 4f 50 28 4e 55 4d 29 | FUNCOP(NUM)| 00000be0 20 20 20 20 2f 2f 20 67 65 74 20 74 68 65 20 76 | // get the v| 00000bf0 61 6c 75 65 0d 0a 20 20 20 20 20 20 20 20 20 20 |alue.. | 00000c00 20 20 49 46 20 43 4f 55 4e 54 3d 31 20 26 20 4e | IF COUNT=1 & N| 00000c10 55 4d 53 54 52 25 31 20 3d 20 27 2d 27 20 54 48 |UMSTR%1 = '-' TH| 00000c20 45 4e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 |EN.. | 00000c30 20 20 20 46 4e 45 47 28 4e 55 4d 2c 20 4e 55 4d | FNEG(NUM, NUM| 00000c40 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 57 |).. W| 00000c50 52 49 54 45 4e 55 4d 28 4e 55 4d 2c 20 30 29 20 |RITENUM(NUM, 0) | 00000c60 20 20 2f 2f 20 64 69 73 70 6c 61 79 20 69 74 0d | // display it.| 00000c70 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 45 54 |. RET| 00000c80 55 52 4e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 |URN.... | 00000c90 2f 2f 20 45 66 66 65 63 74 20 6f 66 20 63 6c 65 |// Effect of cle| 00000ca0 61 72 20 64 65 70 65 6e 64 73 20 6f 6e 20 77 68 |ar depends on wh| 00000cb0 65 74 68 65 72 20 61 6e 79 20 63 68 61 72 61 63 |ether any charac| 00000cc0 74 65 72 73 20 65 6e 74 65 72 65 64 0d 0a 20 20 |ters entered.. | 00000cd0 20 20 20 20 20 20 20 2f 2f 20 79 65 74 20 2d 20 | // yet - | 00000ce0 69 66 20 73 6f 20 6a 75 73 74 20 63 61 6e 63 65 |if so just cance| 00000cf0 6c 20 74 68 65 6d 20 2d 20 69 66 20 6e 6f 74 20 |l them - if not | 00000d00 64 6f 20 61 20 72 65 73 65 74 2e 0d 0a 0d 0a 20 |do a reset..... | 00000d10 20 20 20 20 20 20 20 20 43 41 53 45 20 54 2e 43 | CASE T.C| 00000d20 4c 45 41 52 3a 0d 0a 20 20 20 20 20 20 20 20 20 |LEAR:.. | 00000d30 20 20 20 49 46 20 43 4f 55 4e 54 20 3d 20 30 20 | IF COUNT = 0 | 00000d40 54 48 45 4e 0d 0a 20 20 20 20 20 20 20 20 20 20 |THEN.. | 00000d50 20 20 20 20 20 52 45 53 45 54 28 29 20 20 2f 2f | RESET() //| 00000d60 20 77 68 69 63 68 20 4c 4f 4e 47 4a 55 4d 50 53 | which LONGJUMPS| 00000d70 20 62 61 63 6b 20 74 6f 20 53 54 41 52 54 0d 0a | back to START..| 00000d80 20 20 20 20 20 20 20 20 20 20 20 20 43 4f 55 4e | COUN| 00000d90 54 20 3a 3d 20 30 0d 0a 20 20 20 20 20 20 20 20 |T := 0.. | 00000da0 20 20 20 20 45 4e 44 43 41 53 45 0d 0a 0d 0a 20 | ENDCASE.... | 00000db0 20 20 20 20 20 20 20 20 2f 2f 20 48 61 6e 64 6c | // Handl| 00000dc0 65 20 6f 74 68 65 72 20 63 61 73 65 73 2e 20 20 |e other cases. | 00000dd0 27 2d 27 20 65 6e 74 65 72 65 64 20 61 73 20 66 |'-' entered as f| 00000de0 69 72 73 74 20 63 68 61 72 61 63 74 65 72 20 69 |irst character i| 00000df0 73 20 61 0d 0a 20 20 20 20 20 20 20 20 20 2f 2f |s a.. //| 00000e00 20 73 70 65 63 69 61 6c 20 63 61 73 65 20 2d 20 | special case - | 00000e10 69 74 20 6d 61 79 20 62 65 20 76 61 6c 69 64 20 |it may be valid | 00000e20 28 65 2e 67 2e 20 69 6e 20 27 31 32 33 20 2a 20 |(e.g. in '123 * | 00000e30 2d 34 35 36 27 29 2e 20 20 49 66 0d 0a 20 20 20 |-456'). If.. | 00000e40 20 20 20 20 20 20 2f 2f 20 69 74 20 69 73 20 6e | // it is n| 00000e50 6f 74 20 76 61 6c 69 64 20 74 68 65 6e 20 69 74 |ot valid then it| 00000e60 20 6d 75 73 74 20 62 65 20 74 72 65 61 74 65 64 | must be treated| 00000e70 20 61 73 20 61 6e 20 6f 70 65 72 61 74 6f 72 0d | as an operator.| 00000e80 0a 20 20 20 20 20 20 20 20 20 2f 2f 20 65 6e 74 |. // ent| 00000e90 65 72 65 64 20 77 68 65 6e 20 61 20 6e 75 6d 62 |ered when a numb| 00000ea0 65 72 20 77 61 73 20 65 78 70 65 63 74 65 64 2e |er was expected.| 00000eb0 20 20 49 6e 20 73 75 63 68 20 61 20 63 61 73 65 | In such a case| 00000ec0 20 6a 75 6d 70 0d 0a 20 20 20 20 20 20 20 20 20 | jump.. | 00000ed0 2f 2f 20 62 61 63 6b 20 74 6f 20 53 54 41 52 54 |// back to START| 00000ee0 20 68 61 76 69 6e 67 20 66 69 72 73 74 20 27 75 | having first 'u| 00000ef0 6e 72 65 61 64 27 20 74 68 65 20 63 68 61 72 61 |nread' the chara| 00000f00 63 74 65 72 20 73 6f 20 74 68 61 74 0d 0a 20 20 |cter so that.. | 00000f10 20 20 20 20 20 20 20 2f 2f 20 69 74 20 63 61 6e | // it can| 00000f20 20 62 65 20 70 72 6f 63 65 73 73 65 64 20 69 6e | be processed in| 00000f30 20 74 68 65 20 6e 6f 72 6d 61 6c 20 77 61 79 2e | the normal way.| 00000f40 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 44 45 46 |.... DEF| 00000f50 41 55 4c 54 3a 0d 0a 20 20 20 20 20 20 20 20 20 |AULT:.. | 00000f60 20 20 20 49 46 20 28 43 48 20 3d 20 27 2d 27 29 | IF (CH = '-')| 00000f70 20 26 20 28 43 4f 55 4e 54 20 3d 20 30 29 20 26 | & (COUNT = 0) &| 00000f80 20 28 4e 4f 54 20 4e 45 47 2e 56 41 4c 49 44 29 | (NOT NEG.VALID)| 00000f90 20 54 48 45 4e 0d 0a 20 20 20 20 20 20 20 20 20 | THEN.. | 00000fa0 20 20 20 24 28 20 55 4e 52 44 43 48 28 29 0d 0a | $( UNRDCH()..| 00000fb0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4c | L| 00000fc0 4f 4e 47 4a 55 4d 50 28 52 45 53 2e 4c 45 56 2c |ONGJUMP(RES.LEV,| 00000fd0 20 52 45 53 2e 4c 41 42 29 0d 0a 20 20 20 20 20 | RES.LAB).. | 00000fe0 20 20 20 20 20 20 20 24 29 0d 0a 0d 0a 20 20 20 | $).... | 00000ff0 20 20 20 20 20 20 20 20 20 2f 2f 20 53 65 74 20 | // Set | 00001000 75 70 20 73 74 72 69 6e 67 20 6f 66 20 63 68 61 |up string of cha| 00001010 72 61 63 74 65 72 73 20 65 6e 74 65 72 65 64 20 |racters entered | 00001020 73 6f 20 66 61 72 20 61 6e 64 20 73 65 65 20 69 |so far and see i| 00001030 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f |f.. /| 00001040 2f 20 69 74 20 66 6f 72 6d 73 20 61 20 76 61 6c |/ it forms a val| 00001050 69 64 20 6e 75 6d 62 65 72 2e 20 20 49 66 20 74 |id number. If t| 00001060 68 69 73 20 69 73 20 74 68 65 20 31 38 74 68 20 |his is the 18th | 00001070 63 68 61 72 61 63 74 65 72 0d 0a 20 20 20 20 20 |character.. | 00001080 20 20 20 20 20 20 20 2f 2f 20 69 74 20 72 65 70 | // it rep| 00001090 6c 61 63 65 73 20 74 68 65 20 31 37 74 68 20 70 |laces the 17th p| 000010a0 72 6f 76 69 64 65 64 20 74 68 61 74 20 69 74 20 |rovided that it | 000010b0 69 73 20 76 61 6c 69 64 2e 0d 0a 0d 0a 20 20 20 |is valid..... | 000010c0 20 20 20 20 20 20 20 20 20 46 50 45 58 43 45 50 | FPEXCEP| 000010d0 20 3a 3d 20 30 0d 0a 20 20 20 20 20 20 20 20 20 | := 0.. | 000010e0 20 20 20 54 45 53 54 20 43 4f 55 4e 54 20 3d 20 | TEST COUNT = | 000010f0 4e 55 4d 57 49 44 54 48 20 54 48 45 4e 0d 0a 20 |NUMWIDTH THEN.. | 00001100 20 20 20 20 20 20 20 20 20 20 20 24 28 20 4c 45 | $( LE| 00001110 54 20 4f 4c 44 43 48 20 3d 20 4e 55 4d 53 54 52 |T OLDCH = NUMSTR| 00001120 25 4e 55 4d 57 49 44 54 48 0d 0a 20 20 20 20 20 |%NUMWIDTH.. | 00001130 20 20 20 20 20 20 20 20 20 20 4e 55 4d 53 54 52 | NUMSTR| 00001140 25 4e 55 4d 57 49 44 54 48 20 3a 3d 20 43 48 0d |%NUMWIDTH := CH.| 00001150 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00001160 46 4c 49 54 28 4e 55 4d 53 54 52 2c 20 4e 55 4d |FLIT(NUMSTR, NUM| 00001170 56 45 43 29 0d 0a 0d 0a 20 20 20 20 20 20 20 20 |VEC).... | 00001180 20 20 20 20 20 20 20 2f 2f 20 49 66 20 69 6e 76 | // If inv| 00001190 61 6c 69 64 20 72 65 70 6c 61 63 65 20 6f 6c 64 |alid replace old| 000011a0 20 31 37 74 68 20 63 68 61 72 61 63 74 65 72 20 | 17th character | 000011b0 65 6c 73 65 20 64 65 63 72 65 6d 65 6e 74 0d 0a |else decrement..| 000011c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 000011d0 2f 20 63 6f 64 65 20 73 6f 20 63 6f 64 65 20 62 |/ code so code b| 000011e0 65 6c 6f 77 20 28 77 68 69 63 68 20 69 6e 63 72 |elow (which incr| 000011f0 65 6d 65 6e 74 73 20 69 74 29 20 77 6f 72 6b 73 |ements it) works| 00001200 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 |..... | 00001210 20 20 20 20 54 45 53 54 20 46 50 45 58 43 45 50 | TEST FPEXCEP| 00001220 20 4e 45 20 30 20 54 48 45 4e 0d 0a 20 20 20 20 | NE 0 THEN.. | 00001230 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4e 55 | NU| 00001240 4d 53 54 52 25 4e 55 4d 57 49 44 54 48 20 3a 3d |MSTR%NUMWIDTH :=| 00001250 20 4f 4c 44 43 48 0d 0a 20 20 20 20 20 20 20 20 | OLDCH.. | 00001260 20 20 20 20 20 20 20 45 4c 53 45 0d 0a 20 20 20 | ELSE.. | 00001270 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 43 | C| 00001280 4f 55 4e 54 20 3a 3d 20 4e 55 4d 57 49 44 54 48 |OUNT := NUMWIDTH| 00001290 2d 31 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 |-1.. | 000012a0 24 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 |$).. | 000012b0 45 4c 53 45 0d 0a 20 20 20 20 20 20 20 20 20 20 |ELSE.. | 000012c0 20 20 24 28 20 4e 55 4d 53 54 52 25 28 43 4f 55 | $( NUMSTR%(COU| 000012d0 4e 54 2b 31 29 20 3a 3d 20 43 48 0d 0a 20 20 20 |NT+1) := CH.. | 000012e0 20 20 20 20 20 20 20 20 20 20 20 20 4e 55 4d 53 | NUMS| 000012f0 54 52 25 30 20 3a 3d 20 43 4f 55 4e 54 2b 31 0d |TR%0 := COUNT+1.| 00001300 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00001310 46 4c 49 54 28 4e 55 4d 53 54 52 2c 20 4e 55 4d |FLIT(NUMSTR, NUM| 00001320 56 45 43 29 0d 0a 20 20 20 20 20 20 20 20 20 20 |VEC).. | 00001330 20 20 24 29 0d 0a 0d 0a 20 20 20 20 20 20 20 20 | $).... | 00001340 20 20 20 20 2f 2f 20 49 66 20 73 74 72 69 6e 67 | // If string| 00001350 20 6e 6f 74 20 61 20 76 61 6c 69 64 20 6e 75 6d | not a valid num| 00001360 62 65 72 20 62 75 74 20 6c 61 73 74 20 63 68 61 |ber but last cha| 00001370 72 61 63 74 65 72 20 65 6e 74 65 72 65 64 0d 0a |racter entered..| 00001380 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 | // i| 00001390 73 20 61 20 6e 75 6d 65 72 69 63 20 63 68 61 72 |s a numeric char| 000013a0 61 63 74 65 72 20 28 69 2e 65 2e 20 30 2d 39 2c |acter (i.e. 0-9,| 000013b0 20 45 20 6f 72 20 27 2e 27 29 20 74 68 65 6e 20 | E or '.') then | 000013c0 6a 75 73 74 0d 0a 20 20 20 20 20 20 20 20 20 20 |just.. | 000013d0 20 20 2f 2f 20 69 67 6e 6f 72 65 20 69 74 2e 20 | // ignore it. | 000013e0 4f 74 68 65 72 77 69 73 65 20 74 72 65 61 74 20 |Otherwise treat | 000013f0 74 68 65 20 69 6e 76 61 6c 69 64 20 63 68 61 72 |the invalid char| 00001400 61 63 74 65 72 20 61 73 0d 0a 20 20 20 20 20 20 |acter as.. | 00001410 20 20 20 20 20 20 2f 2f 20 74 65 72 6d 69 6e 61 | // termina| 00001420 74 69 6e 67 20 74 68 65 20 6e 75 6d 62 65 72 20 |ting the number | 00001430 73 6f 20 27 75 6e 72 65 61 64 27 20 69 74 2e 20 |so 'unread' it. | 00001440 20 49 66 20 6e 6f 0d 0a 20 20 20 20 20 20 20 20 | If no.. | 00001450 20 20 20 20 2f 2f 20 63 68 61 72 61 63 74 65 72 | // character| 00001460 73 20 68 61 76 65 20 62 65 65 6e 20 65 6e 74 65 |s have been ente| 00001470 72 65 64 20 28 6f 72 20 6f 6e 6c 79 20 27 2d 27 |red (or only '-'| 00001480 20 68 61 73 20 62 65 65 6e 0d 0a 20 20 20 20 20 | has been.. | 00001490 20 20 20 20 20 20 20 2f 2f 20 65 6e 74 65 72 65 | // entere| 000014a0 64 29 20 74 68 65 6e 20 4c 4f 4e 47 4a 55 4d 50 |d) then LONGJUMP| 000014b0 20 62 61 63 6b 20 74 6f 20 53 54 41 52 54 20 61 | back to START a| 000014c0 73 20 69 66 20 74 68 69 73 0d 0a 20 20 20 20 20 |s if this.. | 000014d0 20 20 20 20 20 20 20 2f 2f 20 70 72 6f 63 65 64 | // proced| 000014e0 75 72 65 20 68 61 64 20 6e 65 76 65 72 20 62 65 |ure had never be| 000014f0 65 6e 20 63 61 6c 6c 65 64 2e 20 20 4f 74 68 65 |en called. Othe| 00001500 72 77 69 73 65 20 72 65 74 75 72 6e 20 74 68 65 |rwise return the| 00001510 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f |.. //| 00001520 20 6e 75 6d 62 65 72 20 65 6e 74 65 72 65 64 2e | number entered.| 00001530 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 |.... | 00001540 49 46 20 46 50 45 58 43 45 50 20 4e 45 20 30 20 |IF FPEXCEP NE 0 | 00001550 54 48 45 4e 0d 0a 20 20 20 20 20 20 20 20 20 20 |THEN.. | 00001560 20 20 24 28 20 49 46 20 43 48 54 59 50 45 20 3d | $( IF CHTYPE =| 00001570 20 54 2e 4e 55 4d 43 48 20 54 48 45 4e 0d 0a 20 | T.NUMCH THEN.. | 00001580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001590 20 45 4e 44 43 41 53 45 20 20 20 20 20 20 20 20 | ENDCASE | 000015a0 2f 2f 20 69 67 6e 6f 72 65 20 69 6e 76 61 6c 69 |// ignore invali| 000015b0 64 20 6e 75 6d 65 72 69 63 20 63 68 61 72 61 63 |d numeric charac| 000015c0 74 65 72 73 0d 0a 20 20 20 20 20 20 20 20 20 20 |ters.. | 000015d0 20 20 20 20 20 55 4e 52 44 43 48 28 29 0d 0a 20 | UNRDCH().. | 000015e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 46 | IF| 000015f0 20 43 4f 55 4e 54 20 3d 20 30 20 7c 20 28 43 4f | COUNT = 0 | (CO| 00001600 55 4e 54 20 3d 20 31 20 26 20 4e 55 4d 53 54 52 |UNT = 1 & NUMSTR| 00001610 25 31 20 3d 20 27 2d 27 29 20 54 48 45 4e 0d 0a |%1 = '-') THEN..| 00001620 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001630 20 20 4c 4f 4e 47 4a 55 4d 50 28 52 45 53 2e 4c | LONGJUMP(RES.L| 00001640 45 56 2c 20 52 45 53 2e 4c 41 42 29 0d 0a 20 20 |EV, RES.LAB).. | 00001650 20 20 20 20 20 20 20 20 20 20 20 20 20 4e 55 4d | NUM| 00001660 53 54 52 25 30 20 3a 3d 20 43 4f 55 4e 54 20 2f |STR%0 := COUNT /| 00001670 2f 20 69 67 6e 6f 72 65 20 6c 61 74 65 73 74 20 |/ ignore latest | 00001680 63 68 61 72 61 63 74 65 72 0d 0a 20 20 20 20 20 |character.. | 00001690 20 20 20 20 20 20 20 20 20 20 46 4c 49 54 28 4e | FLIT(N| 000016a0 55 4d 53 54 52 2c 20 4e 55 4d 29 20 2f 2f 20 73 |UMSTR, NUM) // s| 000016b0 65 74 20 75 70 20 4e 55 4d 0d 0a 20 20 20 20 20 |et up NUM.. | 000016c0 20 20 20 20 20 20 20 20 20 20 52 45 54 55 52 4e | RETURN| 000016d0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 24 29 |.. $)| 000016e0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f |.. //| 000016f0 20 43 68 61 72 61 63 74 65 72 20 76 61 6c 69 64 | Character valid| 00001700 20 73 6f 20 6c 65 61 76 65 20 69 74 20 69 6e 20 | so leave it in | 00001710 73 74 72 69 6e 67 2e 0d 0a 0d 0a 20 20 20 20 20 |string..... | 00001720 20 20 20 20 20 20 20 43 4f 55 4e 54 20 3a 3d 20 | COUNT := | 00001730 43 4f 55 4e 54 2b 31 0d 0a 20 20 20 20 20 20 24 |COUNT+1.. $| 00001740 29 0d 0a 0d 0a 20 20 20 20 20 20 2f 2f 20 44 69 |).... // Di| 00001750 73 70 6c 61 79 20 73 74 72 69 6e 67 20 61 6e 64 |splay string and| 00001760 20 67 6f 20 62 61 63 6b 20 74 6f 20 67 65 74 20 | go back to get | 00001770 6e 65 78 74 20 63 68 61 72 61 63 74 65 72 20 28 |next character (| 00001780 62 75 74 20 64 69 73 70 6c 61 79 0d 0a 20 20 20 |but display.. | 00001790 20 20 20 2f 2f 20 61 6e 20 65 6d 70 74 79 20 73 | // an empty s| 000017a0 74 72 69 6e 67 20 61 73 20 27 30 27 29 2e 0d 0a |tring as '0')...| 000017b0 0d 0a 20 20 20 20 20 20 4e 55 4d 50 4f 53 28 29 |.. NUMPOS()| 000017c0 20 20 20 20 2f 2f 20 70 6f 73 69 74 69 6f 6e 20 | // position | 000017d0 63 75 72 73 6f 72 0d 0a 20 20 20 20 20 20 57 52 |cursor.. WR| 000017e0 42 49 4e 28 31 33 37 29 20 20 2f 2f 20 63 61 6e |BIN(137) // can| 000017f0 63 65 6c 20 66 6c 61 73 68 69 6e 67 0d 0a 20 20 |cel flashing.. | 00001800 20 20 20 20 46 4f 52 20 4a 20 3d 20 31 20 54 4f | FOR J = 1 TO| 00001810 20 28 43 4f 55 4e 54 3d 30 20 2d 3e 20 4e 55 4d | (COUNT=0 -> NUM| 00001820 57 49 44 54 48 2d 31 2c 20 4e 55 4d 57 49 44 54 |WIDTH-1, NUMWIDT| 00001830 48 2d 43 4f 55 4e 54 29 20 44 4f 0d 0a 20 20 20 |H-COUNT) DO.. | 00001840 20 20 20 20 20 20 57 52 43 48 28 27 2a 53 27 29 | WRCH('*S')| 00001850 0d 0a 20 20 20 20 20 20 54 45 53 54 20 43 4f 55 |.. TEST COU| 00001860 4e 54 20 3d 20 30 20 54 48 45 4e 0d 0a 20 20 20 |NT = 0 THEN.. | 00001870 20 20 20 20 20 20 57 52 43 48 28 27 30 27 29 0d | WRCH('0').| 00001880 0a 20 20 20 20 20 20 45 4c 53 45 0d 0a 20 20 20 |. ELSE.. | 00001890 20 20 20 20 20 20 46 4f 52 20 4a 20 3d 20 31 20 | FOR J = 1 | 000018a0 54 4f 20 43 4f 55 4e 54 20 44 4f 0d 0a 20 20 20 |TO COUNT DO.. | 000018b0 20 20 20 20 20 20 20 20 20 57 52 43 48 28 4e 55 | WRCH(NU| 000018c0 4d 53 54 52 25 4a 29 0d 0a 20 20 20 20 20 20 43 |MSTR%J).. C| 000018d0 4f 50 59 4c 31 4c 32 28 29 20 20 2f 2f 20 32 6e |OPYL1L2() // 2n| 000018e0 64 20 6c 69 6e 65 20 6f 66 20 64 6f 75 62 6c 65 |d line of double| 000018f0 20 68 65 69 67 68 74 20 64 69 73 70 6c 61 79 0d | height display.| 00001900 0a 20 20 20 20 20 20 47 45 54 43 48 28 29 0d 0a |. GETCH()..| 00001910 20 20 20 24 29 20 52 45 50 45 41 54 0d 0a 24 29 | $) REPEAT..$)| 00001920 0d 0a 0d 0a |....| 00001924