EDITOR subroutine 0F2C see also control characters, editing,2089 INPUT Handles input into either the editing or the input area.Performs execution of all the editing control characters by jumps from the editing keys table 0FA0 into the executive subroutines, each of which is discussed separately in this index. Input parameters: none. Action: get the error stack pointer from 5C3D ERR SP and stack it. _0F30_ED_AGAIN (the reentry point of the EDITOR loop): stack the address 107F ED ERROR (rasp and return to EDITOR) - put it in 5C3D ERR SP; temporarily the error address. _0F38_ED_LOOP: call 15D4 WAIT KEY, which copies the edit line to the lower screen and waits till it gets a keystroke - call 03B5 BEEPER with a fixed pitch and the duration in 5C39 PIP; make a click - put the address of 0F38 ED LOOP on the machine stack, so all the control code subroutines will return here - check the code from the keystroke - if it is more than 17h exit to 0F81 ADD CHAR; it will put the code of any digit, letter, symbol or token code in the edit line at the position pointed to by 5C5B K CUR, and return to 0F38 ED LOOP - if the code is less than 07 do the same; it can only be 06, the PRINT comma - (07 -> 17h) if it is less than 10h jump on to ED KEYS;an edit control code - (10h -> 17h) set a counter to two - if the code was less than 16h jump on to ED CONTR; an INK to OVER colour control, eg yellow PAPER, produced by key 6 in E mode with caps shift: the single key input is transformed by 10A8 KEY INPUT and following into_two keystroke outputs, the control code and its parameter. [The notes are wrong in referring only to INK and PAPER, since FLASH, BRIGHT and INVERSE, though not OVER, can also be input from the keyboard inthis way] - (16h AT and 17h TAB; they cannot occur in an edit lineor INPUT as far as the unexpanded Spectrum is concerned, but might be encountered in inputs from peripherals or user m/c) make the counter three - call 15D4 WAIT KEY to get the first parameter. _0F6C_ED_CONTR: call 15D4 WAIT KEY to get the parameter - stack the control code and first parameter if any - call 1655 MAKE ROOM with the counter to make spaces at5C5B K CUR - get back the control code and first parameter and put them in the spaces made - exit to 0FB8 ADD CH 1 to write in the second and update 5C5B K CUR; if there was only one parameter it overwritesthe meaningless byte just written in. [The subroutine 0F81 ADD CHAR is interpolated here; see the separate index entry.] _0F92_ED_KEYS (0F38 ED LOOP jumped on to here with any ofthe control codes 07 EDIT -> 0F GRAPHICS): add the code to the base address 0F99;_not the first address of the table - add the offset thus found in the editing keys table 0FA0 to its own address, to get the subroutine address - get the editing cursor pointer from 5C5B K CUR and make an indirect jump to the subroutine address; all these subroutines return to 0F38 ED LOOP except ED ENTER, unless thereis an error, when they return to ED AGAIN to restore the error address. Exit: from 1026 ED END (1024 ED ENTER) when ENTER pressed; the address dropping etc amounts to a simple return from EDITOR. Output parameters: none - the error address is restored to its old value in ED END (1024 ED ENTER). Called from: 12AC MAIN 2 2148 IN VAR 2 215E IN VAR 3 Rems: Introduction line is checked and stored, or executed 107F ED ERROR rasp and return to editor 1795 AUTO LIST used by 191C LINE STORE used by 2129 IN PR 3 preparation before calling E DIVSN 2D6D (2D4F E TO FP) Jumps from: 2D60 E LOOP ED KEYS 0F92 (0F2C EDITOR) Jumps from: 0F38 ED LOOP ED LEFT subroutine 1007 Called only from the editing keys table 0FA1 by 0F92 ED KEYS in response to 08 "left arrow"; part of the EDITOR loop. Inediting or input mode, moves the editing cursor one place left; but makes no move at the start of the line, and jumps over control codes and their parameters. Not otherwise called from ROM; could be called from m/c,but of doubtful usefulness. Input parameters: HL holds the address of the cursor position in the editing area or work space - for the ROM call, the return address 0F38 ED LOOP is on top of the stack. Action: call 1031 ED EDGE, which returns the correct cursor address for a cursor left move. Exit: into 1011 ED CUR, which updates 5C5B K CUR. Output parameters: HL holds the new cursor position in the editing area or work space. ED LIST subroutine 106E Produces a listing after cursor moves up or down. Input parameters: none Action: call 1795 AUTO LIST - set stream zero to reopen channel K. Exit: into 1601 CHAN OPEN to open the channel; in the ROM, return will be to 0F38 ED LOOP. Output parameters: A holds zero, the stream number. Exit from: 0FF3 ED DOWN 1059 ED UP ED LOOP 0F38 (0F2C EDITOR) The re-entry point to the EDITOR routine; it puts its own address on the machine stack. Otherwise, see 0F2C EDITOR. Jumps (all indirect jumps) from: 0F8B ADD CH 1 0FA9 ED EDIT 1007 ED LEFT 100C ED RIGHT 1024 ED ENTER 1031 ED EDGE 106E ED LIST (via 1601 CHAN OPEN) ED RIGHT subroutine 100C Called only from the editing keys table 0FA1 by 0F92 ED KEYS in response to 09 "right arrow"; part of the EDITOR loop. In editing or input mode, moves the editing cursor right. Not otherwise called from ROM; could be called from m/c,but of doubtful usefulness. There is no provision for skipping over the parameters of colour controls: it takes two cursor moves right to pass these, but only one left. Input parameters: HL holds the address of the cursor position in the editing area or work space - for the ROM call, the return address 0F38 ED LOOP is on top of the stack. Action: read the byte at the cursor - if it is 0D newline return without any action; the cursor is at the end of the line - increment HL. Exit: into 1011 ED CUR to put the address into 5C5B K CUR; return will be to 0F38 ED LOOP, in the ROM. Output parameters: HL holds the new cursor position in the editing area or work space. ED SPACES 115E (111D ED COPY) Jumps from: 1150 ED BLANK ED STOP 1001 (0FF3 ED DOWN) Jumps from: 0FF3 ED DOWN ED SYMBOL 1076 see symbol code ED UP subroutine 1059 Called only from the editing keys table 0FA1 by 0F92 ED KEYS in response to 0B "up arrow"; part of the EDITOR loop. In editing, moves the current line up one BASIC line; in input mode, no action at all. Not otherwise called from ROM; could be called from m/c,but of doubtful usefulness. Input parameters: HL holds the address of the cursor position in the editing area or work space - for the ROM call, the return address 0F38 ED LOOP is on top of the stack. Action: if bit 5 of FLAGX is set return at once; input mode - (editing mode) get the current line number from 5C49 EPPC - call 196E LINE ADDR to find its start address in the program area - switch the pointers to get the start address of the line before - call 1695 LINE NO to find its line number - call 191C LN STORE to put it in 5C49 E PPC. Exit: into 106E ED LIST, producing a new listing. Return will be to 0F38 ED LOOP. Output parameters: none. E END 2D7B (2D4F E TO FP) Exit from: 2D71 E TST END (2D4F E TO FP) E FETCH 2D6E (2D4F E TO FP) Jumps from: 2D60 E LOOP E FORMAT 2CEB (2C9B DEC TO FP) Exit from: 2CB8 NOT BIN 2CDA NXT DGT 1 E-format numbers (in BASIC printout) see also 2DE3 PRINT FP Numbers larger than 99,999,999.5d or smaller than 0.00001d are printed by the BASIC in the form xEy: the value of the number is 10**y * x, with x the mantissa, y the exponent. Either x or y or both may have a minus sign. The mantissa x willbe between one and ten, and it may have a decimal point with up to seven figures after it; the exponent y never has a decimal point, and can range from -39d to +38d. Numbers may also be input in E-format: in this case x and y can be of any reasonable size, but y must be an integer and they must be input as decimals, not BIN or E-format numbers or numeric expressions. Like any other numbers they will be put in the BASIC as 5-byte FP forms, in this case by 2C8B NOT BIN and 2CEB E FORMAT, and when they get printed out it will be in decimal or E-format depending on their magnitude; except in a BASIC line, where they will be reproduced as input. The "E" may be input as "e" or "E". 2C8B NOT BIN looks for "e/E" in number expression 2CEB E FORMAT checks present character for "e/E" 2CFF ST E PART reads exponent 2D18 E FP JUMP assigns value of XeY 2D4F E TO FP converts to FP form 2DE3 PRINT FP printing of nos uses E format if necessary 2F2D PF COUNT needed if digit count > 8 (nb notes misprinted) or < -4 2F4A PF E SBRN entry point for printing E format 2F6C PF E FRMT starts printing of E format 2F85 PF E SGN prints + or - and exponent E FORMAT TO FLOATING POINT SUBROUTINE see 2D4F E TO FP E FP JUMP 2D18 (2C9B DEC TO FP) Jumps from: 2CFF ST E PART elements of array see arrays E LINE system variable 5C59 Bytes: 2 The address of the start of the editing area. It is the next address after the 80-byte marking the end of the variables area; the end of the editing area is marked by a newline and another 80-byte, and the next address is in 5C51 WORKSP. One of the fourteen system pointers set by 1664 POINTERS. Written by: 1219 RAM SET 166B PTR NEXT Read by: 073A SA TYPE 0 084C LD DATA 1 0873 LD PROG 0FA9 ED EDIT 1195 SET DE 12AC MAIN 2 12CF MAIN 3 166B PTR NEXT 16B0 SET MIN 16D4 REC EDIT 19FB E LINE NO 1B8A LINE RUN 1EB7 CLEAR 1 2B29 L SPACES 2BC6 L STRING 2BEA L FIRST 2C2E D NO LOOP Rems: 1031 ED EDGE put in DE to move cursor in edit line E LINE NO subroutine 19FB Reads the line number of the line in the editing area; cf 1695 LINE NO, which reads the number of a line in the programarea. The line number in the editing area is just a string of decimal digits, as input; not as in the BASIC program area, where it has been converted to a reversed 2-byte integer. This is true even when the line has been copied back to the editing area from the program; the number is converted back to decimal form by the call to 1A28 OUT NUM2 from 1965 OUT LINE1. The only difference from the input is that now the number may have leading zeroes. Input parameters: none. Action: get a pointer from 5C59 E LINE on the start of the line - move it back one byte - put it in 5C5D CH ADD as a BASIC pointer - call 0020 NEXT CHAR to move it on to the start; this method is used because there may be leading spaces before the line number, and these will be skipped by NEXT CHAR. The more straightforward LD HL,(E LINE)/CALL 0078 TEMP PTR2 might leave the pointer on a space - put the address of 5C92 MEMBOT in 5C65 STKEND; making the calculator memory into a temporary calculator stack. The stack is cleared on exit anyway, but this is done because the subroutine will sometimes be called after an "Out of memory" report has been made, with no room for the normal stack - call 2D3B INT TO FP; it reads the number on to the temporary stack, or leaves zero there if there is no number - call 2DA2 FP TO BC to put the digits into BC - if the number is over FFFFh/65535d jump on with carry to E L 1 - add D8F0h/55536d; making carry if the number is 10000dor more. _1A15_E_L_1 (heading omitted by misprint: it should be onthe line "JP C,1C8A,REPORT C"): if carry is set report "Nonsensein BASIC". Exit: to 16C5 SET STK to restore the calculator stack. Output parameters: BC holds the line number, or zero if there is none; ie if a direct command has been entered - mem-0 to mem-2 have been corrupted by being used as a calculator stack - the line number remains in mem-0, but is never used.