'0010 0100'b '11010111'bThese strings are equivalent to the strings
'24'x 'D7'x
The DROP instruction resets the specified variables to their default values (that is, the name of the variables in uppercase), freeing up any space used to hold the variables and their current values. If you DROP a stem, the values of all compound variables whose names begin with the specified stem are also dropped.
New in KEDIT for Windows 1.5: The list of variables can also include variable names in parentheses. When a variable name in parentheses is encountered, the variable itself is not dropped, but its value is taken as a list of variables that should themselves be dropped. For example:
list = 'a b c.19' drop v1 v2 (list) xyzwould drop the variables V1, V2, A, B, C.19, and XYZ.
In previous versions of KEXX, instructions processed by INTERPRET could not CALL internal routines or invoke internal routines as functions. This limitation has been removed.
PROCEDURE EXPOSE is new in KEDIT for Windows 1.5. The PROCEDURE instruction is valid only at the start of a KEXX internal routine; it must be the first instruction encountered after the label that begins the internal routine. The PROCEDURE instruction tells KEXX to make all variables used in the routine local to the routine. Variables in the routine do not inherit values from the calling routine and variables set in the routine do not affect the values of variables of the same name in the calling routine. In contrast, when PROCEDURE is not the first instruction of an internal routine, all variables used in the routine are shared with the calling routine.
* PROCEDURE Example do i = 1 to 10 say sum(i) end exit sum: procedure * i in this procedure doesn't affect i in main routine total = 0 do i = 1 to arg(1) total = total + i end return totalPROCEDURE can optionally be followed by the keyword EXPOSE and a list of variables that should not be local to the procedure, but should instead be shared with the caller of the procedure. That is, references to variables in the list are treated as references to variables of the same name in the calling procedure. For example:
x = 1 y = 2 call test say x y exit test: procedure expose x x = 55 y = 66 returnwould display ``55 2'', because changes made within TEST to the value of X are exposed to the caller, while changes made to Y are not.
The list of variables to be exposed can include simple variables, compound variables, and stem variables. Items in the list can also be variable names in parentheses. In this case, the variable in parentheses is first exposed, and then its value is taken to be a list of additional variables to be exposed. For example:
height = 12 width = 13 depth = 14 globals = 'height width' call test exit test: procedure expose (globals) say height width depth returnwould display ``12 13 DEPTH'', since
The SELECT instruction, and the related WHEN and OTHERWISE instructions, are new in KEDIT for Windows 1.5.
The SELECT instruction lets you execute one sequence of instructions out of a set of possible alternatives. SELECT offers a cleaner way of specifying what would otherwise be a sequence of IF -- THEN -- ELSE instructions.
An example of a SELECT instruction:
select when option = 'A' then call optiona when option = 'B' then call optionb when option = 'C' then do say 'Option C selected' call optionc end otherwise say 'Unknown option specified' return endSELECT constructs begin with a SELECT instruction and end with an END instruction. In between, you use one or more instructions of the form
WHEN expression THEN instructionEach WHEN expression is tested in sequence. As soon as one is found to be true (that is, has the value 1), the corresponding THEN instruction is executed. To execute more than one instruction when an expression is found to be true, group them together within a DO -- END pair. After the THEN instruction corresponding to the true expression has been executed, no additional WHEN expressions are evaluated, and execution continues with the instruction following the END that terminates the SELECT construct.
The set of WHEN -- THEN instructions can be followed by the keyword OTHERWISE and a sequence of zero or more instructions to be executed if none of the WHEN expressions are true. If you know that at least one of the WHEN expressions will always be true you can omit the OTHERWISE construct, but KEXX generates an error if none of the WHEN expressions are true and OTHERWISE is not present.
The SIGNAL instruction is new in KEDIT for Windows 1.5. Use the SIGNAL instruction to immediately transfer control to some other location within a KEXX program. To do this, use
SIGNAL labelwhere
Also available are
SIGNAL ON condition [NAME trapname]and
SIGNAL OFF conditionThey are discussed in Section 7.5, ``Conditions''.
When searching for a function, KEDIT looks first for an internal routine with the specified name, then for a built-in function, an implied EXTRACT function, a Boolean function, and finally an external routine. (The search for an internal routine is bypassed if the name of the function is in quotes.)
The external routine can use PARSE ARG to access the arguments passed to it, and can use the RETURN instruction to pass a result back to the caller.
When searching for an external routine, the order of searching is the same as it is with the MACRO command: in-memory macros loaded via the DEFINE command are searched for first, and then macros in disk files (with a default extension of .KEX) are searched for, with the search order controlled by the current SET MACROPATH setting.
External routine names with drive or path components, or including special characters, must be specified as quoted names.
For example,
CALL 'F:\MACROS\SAMPLE' X, Y, Zor
SAY '&&'(17)
Here are the functions that are new in KEDIT for Windows 1.5:
Converts a string in binary notation (that is, consisting
of zeroes and ones) into the equivalent hexadecimal string. Blanks
may be included in Returns the result of changing all occurrences of the
string Returns information about the currently trapped condition.
For information about condition handling, see Section 7.5, ``Conditions''. If no condition is currently being handled, the CONDITION()
function returns the null string.
Possible values for C
(``Condition name'') Returns the name of the current
condition, which can be ERROR, FAILURE, HALT, SYNTAX, or NOVALUE.
D
(``Description'') Returns a description of the current
condition. For HALT and SYNTAX conditions, this is the null string.
For the ERROR or FAILURE condition, this is the command string that
led to the error or failure. For the NOVALUE condition, this is the
derived name of the variable involved.
I
(``Instruction'') Returns CALL or SIGNAL, depending
on the method used to invoke the signal handler.
S
(``State'') Returns the state of the current condition:
ON, OFF, or DELAY.
Returns the number of occurrences of the string Returns the text of KEXX error message SOURCELINE(), with no arguments, returns the number of
lines in the currently-executing KEXX macro.
SOURCELINE( Returns ``BAD'' if TRACE() with no arguments returns the trace setting currently
in effect. That is, it returns `A', `C', `E', `F', `I', `L', `N',
`O', or `R', possibly preceded by `?'.
If specified, Returns the value of the symbol specified by
After
Converts a string in hexadecimal notation to binary notation
and returns the result. Blanks may be included in
You can have a KEXX macro automatically transfer control to a different
location in your macro when certain special conditions occur. This
allows your macro to, for example, display diagnostic information
after a syntax error occurs, or ask a user of the macro who has pressed
Ctrl+Break whether to terminate the macro.
The conditions that can be handled are:
You can use
With SIGNAL ON, control is transferred to the appropriate label when
a condition is raised, but there is no convenient way of resuming
execution of your macro at the point that the condition was detected.
An alternative is to use
You can use
CALL ON b2x('1101')
CHANGESTR(
changestr('a', 'abABab', 'x')
CONDITION(
COUNTSTR(
COUNTSTR('a', 'abABab')
ERRORTEXT(
errortext(100)
SOURCELINE(
SYMBOL(
x = 17
a. = 'Hello'
drop a.17
drop y
the SYMBOL() function would yield:
symbol('==')
TRACE(
VALUE(
a = 's'
a9 = 17
s = '9'
the VALUE() function would yield:
value('a')
X2B(
x2b('0d')
Conditions
Condition handling is new to KEXX in KEDIT for Windows 1.5. Condition
handling is an advanced feature of KEXX that most macro writers need
not be familiar with.
With
SIGNAL ON condition [NAME trapname]
When SIGNAL ON has been executed for a condition and that condition
occurs, control is transferred, as if SIGNALSIGNAL ON HALT
KEXX will transfer control to the label HALT if Ctrl+Break is pressed
while your macro is executing.
SIGNAL ON HALT NAME BREAKER
KEXX will transfer control to the label BREAKER if Ctrl+Break is pressed
while your macro is executing.
SIGNAL OFF condition
to disable user-specified condition handling and restore the default
behavior.
CALL ON condition [NAME trapname]
which calls your condition handler as a subroutine and, if your subroutine
returns, resumes execution immediately following the point where the
condition was triggered.
CALL OFF condition
to disable this form of user-specified condition handling.
Notes
KEXX and REXX
KEDIT's macro language, KEXX, contains a large subset of the REXX
language. As of KEDIT for Windows 1.5, almost all of the features
of REXX, as documented in
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.