Routines |
Prev: 08304 | Up: Map | Next: 08633 |
The address of this routine is found in the parameter table.
This routine allows for values entered from the keyboard to be assigned to variables. It is also possible to have print items embedded in the INPUT statement and these items are printed in the lower part of the display.
|
||||
INPUT | 08329 | CALL SYNTAX_Z | Jump forward if syntax is being checked. | |
08332 | JR Z,INPUT_1 | |||
08334 | LD A,1 | Open channel 'K'. | ||
08336 | CALL CHAN_OPEN | |||
08339 | CALL CLS_LOWER | The lower part of the display is cleared. | ||
INPUT_1 | 08342 | LD (IY+2),1 | Signal that the lower screen is being handled (set bit 0 of TV-FLAG and reset all other bits). | |
08346 | CALL IN_ITEM_1 | Call the subroutine to deal with the INPUT items. | ||
08349 | CALL CHECK_END | Move on to the next statement if checking syntax. | ||
08352 | LD BC,(23688) | Fetch the current print position (S-POSN). | ||
08356 | LD A,(23659) | Jump forward if the current position is above the lower screen (see DF-SZ). | ||
08359 | CP B | |||
08360 | JR C,INPUT_2 | |||
08362 | LD C,33 | Otherwise set the print position to the top of the lower screen. | ||
08364 | LD B,A | |||
INPUT_2 | 08365 | LD (23688),BC | Reset S-POSN. | |
08369 | LD A,25 | Now set the scroll counter (SCR-CT). | ||
08371 | SUB B | |||
08372 | LD (23692),A | |||
08375 | RES 0,(IY+2) | Signal 'main screen' (reset bit 0 of TV-FLAG). | ||
08379 | CALL CL_SET | Set the system variables and exit via CLS_LOWER. | ||
08382 | JP CLS_LOWER | |||
The INPUT items and embedded PRINT items are dealt with in turn by the following loop.
|
||||
IN_ITEM_1 | 08385 | CALL PR_POSN_1 | Consider first any position control characters. | |
08388 | JR Z,IN_ITEM_1 | |||
08390 | CP "(" | Jump forward if the present character is not a '('. | ||
08392 | JR NZ,IN_ITEM_2 | |||
08394 | RST 32 | Fetch the next character. | ||
08395 | CALL PRINT_2 | Now call the PRINT command routine to handle the items inside the brackets. | ||
08398 | RST 24 | Fetch the present character. | ||
08399 | CP ")" | Give report C unless the character is a ')'. | ||
08401 | JP NZ,REPORT_C | |||
08404 | RST 32 | Fetch the next character and jump forward to see if there are any further INPUT items. | ||
08405 | JP IN_NEXT_2 | |||
Now consider whether INPUT LINE is being used.
|
||||
IN_ITEM_2 | 08408 | CP 202 | Jump forward if it is not 'LINE'. | |
08410 | JR NZ,IN_ITEM_3 | |||
08412 | RST 32 | Advance CH-ADD. | ||
08413 | CALL CLASS_01 | Determine the destination address for the variable. | ||
08416 | SET 7,(IY+55) | Signal 'using INPUT LINE' (set bit 7 of FLAGX). | ||
08420 | BIT 6,(IY+1) | Give report C unless using a string variable (bit 6 of FLAGS reset). | ||
08424 | JP NZ,REPORT_C | |||
08427 | JR IN_PROMPT | Jump forward to issue the prompt message. | ||
Proceed to handle simple INPUT variables.
|
||||
IN_ITEM_3 | 08429 | CALL ALPHA | Jump to consider going round the loop again if the present character is not a letter. | |
08432 | JP NC,IN_NEXT_1 | |||
08435 | CALL CLASS_01 | Determine the destination address for the variable. | ||
08438 | RES 7,(IY+55) | Signal 'not INPUT LINE' (reset bit 7 of FLAGX). | ||
The prompt message is now built up in the work space.
|
||||
IN_PROMPT | 08442 | CALL SYNTAX_Z | Jump forward if only checking syntax. | |
08445 | JP Z,IN_NEXT_2 | |||
08448 | CALL SET_WORK | The work space is set to null. | ||
08451 | LD HL,23665 | This is FLAGX. | ||
08454 | RES 6,(HL) | Signal 'string result'. | ||
08456 | SET 5,(HL) | Signal 'INPUT mode'. | ||
08458 | LD BC,1 | Allow the prompt message only a single location. | ||
08461 | BIT 7,(HL) | Jump forward if using 'LINE'. | ||
08463 | JR NZ,IN_PR_2 | |||
08465 | LD A,(23611) | Jump forward if awaiting a numeric entry (bit 6 of FLAGS set). | ||
08468 | AND 64 | |||
08470 | JR NZ,IN_PR_1 | |||
08472 | LD C,3 | A string entry will need three locations. | ||
IN_PR_1 | 08474 | OR (HL) | Bit 6 of FLAGX will become set for a numeric entry. | |
08475 | LD (HL),A | |||
IN_PR_2 | 08476 | RST 48 | The required number of locations is made available. | |
08477 | LD (HL),13 | A 'carriage return' goes into the last location. | ||
08479 | LD A,C | Test bit 6 of the C register and jump forward if only one location was required. | ||
08480 | RRCA | |||
08481 | RRCA | |||
08482 | JR NC,IN_PR_3 | |||
08484 | LD A,"\"" | A 'double quotes' character goes into the first and second locations. | ||
08486 | LD (DE),A | |||
08487 | DEC HL | |||
08488 | LD (HL),A | |||
IN_PR_3 | 08489 | LD (23643),HL | The position of the cursor (K-CUR) can now be saved. | |
In the case of INPUT LINE the EDITOR can be called without further preparation but for other types of INPUT the error stack has to be changed so as to trap errors.
|
||||
08492 | BIT 7,(IY+55) | Jump forward with 'INPUT LINE' (bit 7 of FLAGX set). | ||
08496 | JR NZ,IN_VAR_3 | |||
08498 | LD HL,(23645) | Save the current values of CH-ADD and ERR-SP on the machine stack. | ||
08501 | PUSH HL | |||
08502 | LD HL,(23613) | |||
08505 | PUSH HL | |||
IN_VAR_1 | 08506 | LD HL,8506 | This will be the 'return point' in case of errors. | |
08509 | PUSH HL | |||
08510 | BIT 4,(IY+48) | Only change the error stack pointer (ERR-SP) if using channel 'K' (bit 4 of FLAGS2 set). | ||
08514 | JR Z,IN_VAR_2 | |||
08516 | LD (23613),SP | |||
IN_VAR_2 | 08520 | LD HL,(23649) | Set HL to the start of the INPUT line (WORKSP) and remove any floating-point forms. (There will not be any except perhaps after an error.) | |
08523 | CALL REMOVE_FP | |||
08526 | LD (IY+0),255 | Signal 'no error yet' by resetting ERR-NR. | ||
08530 | CALL EDITOR | Now get the INPUT and with the syntax/run flag (bit 7 of FLAGS) indicating syntax, check the INPUT for errors; jump if in order; return to IN_VAR_1 if not. | ||
08533 | RES 7,(IY+1) | |||
08537 | CALL IN_ASSIGN | |||
08540 | JR IN_VAR_4 | |||
IN_VAR_3 | 08542 | CALL EDITOR | Get a 'LINE'. | |
All the system variables have to be reset before the actual assignment of a value can be made.
|
||||
IN_VAR_4 | 08545 | LD (IY+34),0 | The cursor address (K-CUR) is reset. | |
08549 | CALL IN_CHAN_K | The jump is taken if using other than channel 'K'. | ||
08552 | JR NZ,IN_VAR_5 | |||
08554 | CALL ED_COPY | The input-line is copied to the display and the position in ECHO-E made the current position in the lower screen. | ||
08557 | LD BC,(23682) | |||
08561 | CALL CL_SET | |||
IN_VAR_5 | 08564 | LD HL,23665 | This is FLAGX. | |
08567 | RES 5,(HL) | Signal 'edit mode'. | ||
08569 | BIT 7,(HL) | Jump forward if handling an INPUT LINE. | ||
08571 | RES 7,(HL) | |||
08573 | JR NZ,IN_VAR_6 | |||
08575 | POP HL | Drop the address IN-VAR-1. | ||
08576 | POP HL | Reset the ERR-SP to its original address. | ||
08577 | LD (23613),HL | |||
08580 | POP HL | Save the original CH-ADD address in X-PTR. | ||
08581 | LD (23647),HL | |||
08584 | SET 7,(IY+1) | Now with the syntax/run flag (bit 7 of FLAGS) indicating 'run' make the assignment. | ||
08588 | CALL IN_ASSIGN | |||
08591 | LD HL,(23647) | Restore the original address to CH-ADD and clear X-PTR. | ||
08594 | LD (IY+38),0 | |||
08598 | LD (23645),HL | |||
08601 | JR IN_NEXT_2 | Jump forward to see if there are further INPUT items. | ||
IN_VAR_6 | 08603 | LD HL,(23651) | The length of the 'LINE' in the work space is found (STKBOT-WORKSP-1). | |
08606 | LD DE,(23649) | |||
08610 | SCF | |||
08611 | SBC HL,DE | |||
08613 | LD B,H | DE points to the start and BC holds the length. | ||
08614 | LD C,L | |||
08615 | CALL STK_STO | These parameters are stacked and the actual assignment made. | ||
08618 | CALL LET | |||
08621 | JR IN_NEXT_2 | Also jump forward to consider further items. | ||
Further items in the INPUT statement are considered.
|
||||
IN_NEXT_1 | 08623 | CALL PR_ITEM_1 | Handle any print items. | |
IN_NEXT_2 | 08626 | CALL PR_POSN_1 | Handle any position controllers. | |
08629 | JP Z,IN_ITEM_1 | Go around the loop again if there are further items; otherwise return. | ||
08632 | RET |
Prev: 08304 | Up: Map | Next: 08633 |