If you write KEDIT macros then there will likely come a time when you will want to retrieve the contents of the focus line. You might want to examine the line to see if it begins with some special character or contains a particular character string. EXTRACT /CURLINE/ lets you do this.
A note here about terminology:
The focus line is the line of the file relative to which KEDIT commands operate. When the cursor is in the file area, the cursor line is the focus line. When the cursor is on the command line, the current line is the focus line. In textmode KEDIT the current line is, by default, displayed in the middle of the file window in a different color to distinguish it from the other lines of the file that are visible in the text area. In KEDIT for Windows the current line is delimited by thin horizontal lines above and below it when the cursor is on the command line. When the cursor is in the text area these lines disappear to indicate that the focus line is now the cursor line. | For historical reasons, and to maintain compatibility with macros written for IBM's XEDIT editor, the command used to obtain the contents of the focus line is EXTRACT /CURLINE/, rather than EXTRACT /FOCUSLINE/. |
Say you have a text file that looks like this, where line 4 is the focus line:
Your macro could use the EXTRACT /CURLINE/ command like this:
EXTRACT /CURLINE/ sets several variables but the one you are
interested in is CURLINE.3 which is the contents of the focus line. In
this example, CURLINE.3 is set to "Victoria, BC Canada".
As noted above, EXTRACT /CURLINE/ returns more information than just
the contents of the focus line. This EXTRACT command sets CURLINE.1
through CURLINE.6. This is really more information than is needed for
this example. A slightly more efficient method of retrieving just the
contents of the focus line is to use an implied extract function.
For example:
Note that there is no explicit EXTRACT command used here and rather
than referencing the variable CURLINE.3, the curline.3() implied extract
function is called. This function returns only the contents of the
focus line. In fact, in this example the contents of the focus line are
extracted only once so the above code can be written in this more
compact form:
Retrieving a copy of the focus line is an important thing to be able
to do in a macro. Being able to change the contents of the focus line is
just as important though.
The REPLACE command takes whatever text is specified after it and
replaces the contents of the focus line with this text. For example, if
you were to enter this on the KEDIT command line:
then the contents of the focus line would be replaced with "This is a
new focus line string" beginning in column 1. The single space between
the command REPLACE and the beginning of the text acts as a separator so
this is not part of the text that replaces the focus line. Any further
leading spaces on the text though become part of the updated focus line.
Here's an example of a macro that conditionally modifies the contents of
the focus line:
* Retrieve information regarding the focus line
"extract /curline/"
if pos("CANADA", upper(curline.3)) > 0 then say "It's from Canada"
else say "It's from somewhere other than Canada"
FocusLine = curline.3()
if pos("CANADA", upper(FocusLine)) > 0 then say "It's from Canada"
else say "It's from somewhere other than Canada"
if pos("CANADA", upper(curline.3())) > 0 then say "It's from Canada"
else say "It's from somewhere other than Canada"
For general information about EXTRACT and implied extract
functions see sections 5.1 and 5.2 of the KEDIT for Windows Reference
Manual. For more information about the EXTRACT /CURLINE/ command see the
CURLINE operand under section 5.3 of the KEDIT for Windows Reference
Manual.
The REPLACE Command
replace This is a new focus line string
* Get a copy of the focus line
FocusLine = curline.3()
* Update the focus line based on the first blank-delimited string in
* the line
if word(FocusLine, 1) = "NX" then "replace This was an NX entry"
else "replace This was a non-NX entry"
KEDIT Overview |
Download Libraries |
Maintenance Releases
Ordering/Licensing |
Demo Version |
Technical Support |
What's New
KEDIT for Windows 1.6.1 Upgrade |
KEDIT Mailing List
Copyright © 1996-2012 Mansfield Software Group, Inc.