SED Extensions - Variables, constants and functions

SED  -  Variables, Constants and Functions

Top  Previous  Next


All extension program source text is case insensitive except for literal strings.



Local Variables


These are names commencing with a letter and containing only letters, digits, periods (.) and dollar signs. A procedure or function can use at most 250 local variables. Local variables are private to the procedure or function and the same name used in another procedure refers to a different local variable.



Global Variables


These are names commencing with a dollar sign and containing only letters, digits, periods (.) and dollar signs. Global variables are common to all extensions and retain their values until the user leaves SED.


Global variables beginning with two dollar signs are reserved. Current usage of these names is:


$$EXTENSION.FILESContains a space separated list of the files to be searched for extension programs. By default, this variable contains &SED.EXTENSIONS& but it may be modified at any time by user written extension programs. File names are used left to right. If the requested extension is not found in any of these files, a final attempt is made using the &SED.EXTENSIONS& file in the QMSYS account. Once an extension program has been loaded on first use, it remains loaded unless it is specifically unloaded by use of unload or by recompilation by the user who has it loaded.





Numeric constants are written as a sequence of digits, optionally prefixed by a sign or including a decimal point. A numeric constant with an absolute value of less than one must be written with a leading zero (e.g. 0.5).


A string constant may be enclosed in either single or double quotes. It may contain any character except the mark characters (which are available using the tokens shown below) and ASCII character 0 (nul).


The logical values are represented as 0 for False and 1 for True. In general, use of any value other than zero is treated as True by operations that expect logical values as their arguments.



Key Tokens


The get.key function returns a code that relates to an internal function number. Each function has a corresponding symbolic name. These all begin with a period (.) and are the same as the comment inserted at the start of each line of a key binding record with spaces replaced by period. The names are:
































































System Variables


Extension programs may examine the current state of many editor features by use of system variables. These all begin with a percent sign (%) and are read only (i.e. they cannot be used in a set function).


The following system variables may also be referenced in extensions:




















A comment is introduced by an asterisk (*) and extends to the end of the line.



Erroneous Programs


Extension programs may test whether the buffer being processed is read only. Attempts to change such a buffer are ignored. No error is displayed.


Variables are type variant in the same way as for QMBasic programs and they follow the same rules. In most cases, attempts to use a non-numeric value where a number is required result in use of a default.