KEDIT Reminders
Last Updated:
2/19/26 21:18
Jeffrey Knauth
Current Line (Field)
- The current line is a field in the data area of
the KEDIT window.
(Often "current line" is used as shorthand for the line currently in the current line field.)
(The KEDIT data area starts immediately below the Windows top section of the window, i.e., below
the title bar line, menu bar line (File/Edit/Actions/...), and icons line (New File/Open File/Save File...)
(The first line in the data area is KEDIT window line number 1.)
- The current line location is specified by
SET CURLINE, e.g.,
'SET CURLINE 4', with
- x = 4 meaning the fourth line from the top of the KEDIT window.
- x = M meaning the middle line of the KEDIT window.
- x = -2 meaning the second line from the bottom of the KEDIT window.
- curline.1() returns the value set by SET CURLINE,
e.g., "4", "M", or "-2".
- curline.2() returns the (positive integer) window line number of the current line.
- Get the file line number of the line in the current line field:
current_file_line_number = line.2()
or
'SOS SAVE'; 'SOS CURRENT'; current_file_line_number = line.1(); 'SOS RESTORE'
- Get the window line number of the current line field:
current_window_line_number = curline.2()
or
'SOS SAVE'; 'SOS CURRENT'; current_window_line_number = cursor.1(); 'SOS RESTORE'
Focus Line
- The focus line is the line from which KEDIT operates, e.g., changes, moves, searches from.
- If the cursor is on the command line, the focus line is the line in the current line field.
- If the cursor is in the data area (other than the command line), the focus line is the line where the cursor is.
(The prefix area is considered to be part of the data area.)
- Get the line contents of the focus line (which may or may not be the current line):
focus_line_contents = curline.3()
- Get the file line number of the focus line (which may or may the current line):
focus_line_file_line_number = line.1()
- column.1() returns the column number of the focus column.
(Does not show correct information when the cursor is in the prefix area.)
Line and Cursor Placements after Certain Commands
When the cursor is in the command line:
| Command | Focus Line | Current Line | Cursor |
| TOP | TOF | TOF | Cmnd line |
| BOTTOM | BOF-1 | BOF-1 | Cmnd line |
| LOCATE | Found line | Found line | Cmnd line |
| CLOCATE | Found line | Found line | Cmnd line |
| INPUT | New line | New line | Cmnd line |
| REPLACE | Repl line | Repl line | Cmnd line |
| DELETE | Next line | Next line | Cmnd line |
| UP | Prev line | Prev line | Cmnd line |
| DOWN | Next line | Next line | Cmnd line |
| COPY | Copied targ | Copied targ | Cmnd line |
| MOVE | Moved targ | Moved targ | Cmnd line |
| ADD | Added | Added | Added |
| ALL | 1st in all | 1st in all | Cmnd line |
| DUPLICATE | Dupe targ | Dupe targ | Cmnd line |
| FIND | Found targ | Found targ | Cmnd line |
| LEFT | Unchanged | Unchanged | Cmnd line |
| RIGHT | Unchanged | Unchanged | Cmnd line |
| SHIFT | Unchanged | Unchanged | Cmnd line |
When the cursor is NOT in the command line:
| Command | Focus Line | Current Line | Cursor |
| TOP | TOF | TOF | TOF |
| BOTTOM | BOF-1 | BOF-1 | BOF-1 |
| LOCATE | Cursor line | (note 1) | Found Line |
| CLOCATE | Cursor line | (notes 1, 2) | Found Line |
| INPUT | New line | Unchanged | New line |
| REPLACE | Repl line | Unchanged | Repl line |
| DELETE | Next line | Unchanged | Next line |
| UP | Prev line | Unchanged | Prev line |
| DOWN | Next line | Unchanged | Next line |
| COPY | Copied targ | Unchanged | Copied targ |
| MOVE | Moved targ | Unchanged | Moved targ |
| ADD | Added | Added | Added |
| ALL | 1st in all | 1st in all | 1st in all |
| DUPLICATE | Dupe targ | Dupe targ | Dupe targ |
| FIND | Found targ | Found targ | Found targ |
| LEFT | Unchanged | Unchanged | Unchanged |
| RIGHT | Unchanged | Unchanged | Unchanged |
| SHIFT | Unchanged | Unchanged | Unchanged |
Note 1: The current line is unchanged if the
target line is in the window. If the target line is not in the window, the file
is scrolled to make the target line be the current line.
Note 2: If the target is not visible, the
screen is shifted to make at least the first character of the target be
visible.
Cursor Location
- curline.1() returns the window line number.
- curline.2() returns the window column number.
- curline.3() returns the file line number (or -1 if cursor is not in file).
- curline.4() returns the file column number (or -1 if cursor is not in file).
- .5, .6, .7. and .8 are for the previous cursor window/file line/column locations.
- CURSOR CMDLINE puts the cursor on the command line.
Window Topography
- flscreen.1() returns file line number of first file line in window.
- flscreen.2() returns file line number of last file line in window.
- lscreen.1() returns the height in lines of the current document window.
- lscreen.2() returns the width in columns of the current document window.
Parse
- To parse variable abc, parse var abc template.
- To parse evaluated expression abc, parse value abc template.
- The default template uses spaces as delimiters.
Arg
- parse arg template parses
the argument string passed to the macro or subroutine.
- arg template is the same as
parse upper arg template.
- Macro invocations and subroutine calls handle
arguments differently. A macro invocation has just a single
argument string (commas are not treated specially). A subroutine
call can have multiple argument strings, each separated by a
comma. The
arg() function with no parameter gives
the number of arguments. The
arg(n) function gives the nth argument
in the string.
Note the presence or absence of commas
in the following, including whether the comma is within a quoted
string.
- arg() returns the number of
comma-separated arguments in the string.
-
- For mymacro
aBc 'x,y,z' 75 arg() returns "1".
- For mymacro
aBc, 'x,y,z', 75 arg() returns "1".
- For mymacro
"aBc, 'x,y,z', 75" arg() returns "1".
- For call mysubroutine
aBc 'x,y,z' 75 arg() returns "1".
- For call mysubroutine
aBc, 'x,y,z', 75 arg() returns "3".
- For call mysubroutine
"aBc, 'x,y,z', 75" arg() returns "1".
- arg(n) returns the nth argument in the string.
-
- For mymacro
aBc 'x,y,z' 75 arg(1) returns "aBc 'x,y,z' 75".
- For mymacro
aBc, 'x,y,z', 75 arg(1) returns "aBc, 'x,y,z', 75".
- For call mysubroutine
aBc 'x,y,z' 75 arg(1) returns "aBc 'x,y,z' 75".
- For call mysubroutine
aBc, 'x,y,z', 75 arg(1) returns "aBc".
- For call mysubroutine
aBc 'x,y,z' 75 arg(3) returns "".
- For call mysubroutine
aBc, 'x,y,z', 75 arg(3) returns "75".
- The arg instruction and the
arg(n) function produce different case outputs.
-
- arg w changes text to upper case.
- w = arg(n) retains mixed case.
The above holds for both macro invocations and subroutine calls.
- In a subroutine call, parse arg w t u, x y z is the same as
parse value arg(1) with w t u plus
parse value arg(2) with x y z.
- Miscellaneous for call sub '1a' 'pws hgk', '2b,2b', 111
and q = arg(1)
- w = arg(1) returns "1a pws hgk".
- arg w returns "1A PWS HGK".
- parse upper arg w returns "1A PWS HGK".
- parse value arg(1) with w returns "1a pws hgk".
- parse var q w returns "1a pws hgk".
- arg w z returns "1A" and "PWS HGK".
- parse upper arg w z returns "1A" and "PWS HGK".
- parse value arg(1) with w z returns "1a" and "pws hgk".
- parse var q w z returns "1a" and "pws hgk".
SOS
In the following, SOS op operates on the cursor. (There are other SOS ops.)
- SOS CURRENTMove cursor to current line; preserve col
- SOS EXECUTEMove cursor to command line and executes the command on the line
- SOS MAKECURRMake cursor line be the current line; preserve col; nop if cursor on command line
- SOS QCMNDMove cursor to col 1 of command line and clear command line
- SOS SAVESave cursor window (screen) position
- SOS RESTORERestore cursor window (screen) position
- SOS *EDGEMove cursor to top/bottom/left/right edge of file (if cursor is in data area)
- SOS CU, CD, CL, CRMove cursor up, down, left, right
Boolean
In the following, each function tests the listed condition. It
returns 1 for true and 0 for false. (There are other Boolean
functions).
- *EDGE()Cursor is at top/bottom/left/right edge
- COMMAND()Cursor is on command line
- CURRENT()Cursor is on current line
- END()Cursor is on last nonblank character of cursor field
- EOF()Cursor is on EOF line
- FILELINE()Cursor is not on command line
- FIRST()Cursor is in column 1 of cursor field
- FOCUSEOF()Focus line is EOF
- FOCUSTOF()Focus line is TOF
- INBLOCK()Cursor is in marked block
- INPREFIX()Cursor is in prefix area
- INSERTMODE()Insert mode is on
- MODIFIABLE()Cursor is in modifiable area
- PREFIX()Prefix area is displayed
- SHADOW()Cursor is on shadow line
- SPACECHAR()Cursor is on space character
- TOF()Cursor is on TOF line
Trace
- trace +r
- trace off
- trace independence in called macros, called subroutines?
SIGNAL
- signal on novalue catches uninitialized variables
- signal on syntax catches syntax errors
- sigl is the file line number of the line which just issued signal
- signal here goes to here: (colon is at end of label)
Miscellaneous
- ABORT: Shift-Ctrl-Alt
- WINPROF.kex
- PRESERVER/RESTORE
- DOS/DOSNOWAIT/DOSQUIET
- WINEXEC
- ALERT/DIALOG
- call
- fileid.2() is the fully-qualified fileid, in mixed case for (default) FCASE ASIS
- pos()
- substr()
- translate()
- verify
- wordpos
- word index
- dosenv
- dosdir
- countstr
-
HIGHLIGHTING
SET and QUERY
- 'AUTOEXIT'
- 'STREAM'
- 'WRAP'
- 'THIGHLIGHT'
- 'CASE'
- 'STAY'
- 'COLMARK'
- 'COLMARK'
- 'VERIFY'
Gotchas
- The GET command reads lines from the disk file, not from the
memory version of that file if the file is currently being
edited. Do a SAVE first to get the two versions in sync if the
file is currently being edited.
- Issuing KEDIT always puts the cursor on the command line. This
is the case whether KEDIT was issued from the command line or via a
macro, including KEDIT key macros. Also it does not matter if a file
parameter is specified for the KEDIT.
- When switching back and forth among files, the cursor is always
placed on the command line initially when KEDIT first accesses a file
after a switch. The position of the cursor in the data area of that
file when it was last being edited can be re-established by executing
"CURSOR HOME". However if it is possible that the cursor was on the
command line before the switch, "CURSOR HOME" will put the cursor in
some old location in the data area, not on the command line. Doing
an "SOS SAVE" immediately before the switch and an "SOS RESTORE"
immediately when the file is edited again handles all situations.
The cursor is put back to where it was before the switch, which could
have been on the command line or in the data area.
- 'CLOCATE :0' and 'CLOCATE -*' do not work as expected in most
cases if the intent is that a subsequent CLOCATE should be able to
find the target even if it starts in column 1. A workaround is to do
a CURSOR CMDLINE and then LOCATE the line to be searched to make it
the current line and the focus line. It is important to leave the
cursor on the command line. Then a subsequent CLOCATE for a target
will start the search in column 1 of the current line.
- When adding a blank line, be sure to use "INPUT ", not just
"INPUT". Otherwise Input Mode might be entered, depending on the
setting of INPUTMODE.
HOME