qdosmsq:traps:trap_3:elin

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
qdosmsq:traps:trap_3:elin [2009/05/20 14:19]
george.gwilt Redrafted
qdosmsq:traps:trap_3:elin [2009/05/29 09:50] (current)
george.gwilt Explanatory notes clarified(?)
Line 1: Line 1:
 +====== IO_EDLIN/IOB_ELIN ======
 +
 +
 +This trap edits a line of characters (CON channel only).
 +
 +^Call Parameters^^Return Parameters^^
 +|D0.B|$04|D0.L|Error return.|
 +|D1.L|line: position/length|D1.L|line: position/length.|
 +|D2.W|Length of buffer |D2.L|Preserved.|
 +|D3.W|Timeout|D3.L|Preserved.|
 +|A0.L|Channel ID |A0.L|Preserved.|
 +|A1.L|Pointer to end of line|A1.L|Updated.|
 +
 +===== Errors =====
 +
 +
 +|ERR_NC|Not complete.|
 +|ERR_NO|Channel not open.|
 +|ERR_BO|Buffer full.|
 +
 +===== Notes =====
 +  * All registers not shown above are not used on entry and are preserved on exit.
 +  * This trap allows a line of characters situated in a buffer to be edited.
 +  * On entry D1.W must contain the length of the line to be edited (L).
 +  *Before the trap is called, some or all of the characters from the start of the line can be printed. The number printed N, say, (from 0 to the line length) must be set in the top word of D1.
 +  * IO_EDLIN/IOB_ELIN prints the remaining L - N characters of the line before editing starts. The cursor on the line to be edited is positioned on the first character so printed, or just after the end of the line if no characters are printed.   
 +  * A1 is the address, in the buffer, of the character just after end of the line to be edited. This value, plus the line length in D1.W (L), defines exactly where the line to be edited is.  
 +  * When the call is made there must be no terminating character, but the terminating character will be included in the character count on return.
 +  * ENTER, UP and DOWN arrows are acceptable terminators. In SMSQ/E the terminator ESC is also allowed.
 +  * On return D1.W contains the length of the line which includes the terminating character.
 +  * Note that this trap operates by keeping the position of the current character in the line in the msw of D1. This position is mirrored on the screen. Thus, if you move the cursor to the start of the line to be edited, the value of the msw of D1 becomes zero. For example, if the line length is 8 and the msw of D1 is set as 7, the last character of the line in the buffer will be printed to the screen at the current cursor position. The trap will assume that there are 7 previous positions on the screen (for the first part of the line). It is up to the user to see that this is so. 
 +===== Example =====
 +The example below shows the use of this trap call to obtain a filename.
 +
 +The filename is held in PROMPT(A6) as a QDOS string, length followed by characters.
 +
 +The code below shows how to get IO_EDLIN to print the current value of the filename and then allow it to be edited.
 +
 +This code allows the terminator ESC to be used. If the code runs under SMSQ/E this terminator is recognised and is used to abandon editing. Of course if the program is not running under SMSQ/E the editing will not be terminated by ESC so this facility cannot be used.
 +
 +It is assumed that A0 contains the window's ID.
 +
 +<code>
 +name    
 + MOVEQ #SD_NL,D0       ; $12
 +        MOVEQ   #-1,D3          ; Timeout   
 + TRAP #3 ; New line
 +        LEA     ASK,A1          ; Request string
 +        MOVEA.W UT_MTEXT,A2     ; Print the request
 +        JSR     (A2)
 + MOVEQ #0,D1           ; Get EDLIN to print all the line
 + MOVE.W PROMPT(A6),D1   ; Length of current filename
 + MOVE.W #40,D2 ; Buffer length
 + LEA PROMPT+2(A6),A1 ; Point to . . 
 + ADDA.W D1,A1           ; . . end of name
 + MOVEQ #IO_EDLIN,D0    ; $04
 + TRAP #             ; Edit the name
 + CMPI.B #$1B,-1(A1) ; ESC? . .
 + BEQ REP4 ; . . yes - abandon file    
 +        SUBQ.W  #1,D1           ; Length of filename
 + MOVE.W D1,PROMPT(A6) ; . . set this in the string
 +
 +ASK     DC.W    10
 +        DC.B    "Filename: "
 +</code>
  
  • qdosmsq/traps/trap_3/elin.txt
  • Last modified: 2009/05/29 09:50
  • by george.gwilt