Your expression for function string is a Perl regular expression. So if that really works, your wordfile must contain additionally the line
/Regexp Type = Perl
Well, the expression is not really wrong, but could be simplified. UltraEdit runs the regular expression search for the list in function list window always with
Match Case option not checked. Therefore the expression
[A-Za-z] is equal the expression
[A-Z] and equal the expression
[a-z]. The expression
[A-Za-z] is not really wrong, but
[a-z] does the same and makes reading in the expression a little bit faster.
The hyphen character
- has no special meaning in an expression except when used within a character set definition
[...
]. In this case it means "from X to Y". Therefore
- within
[...
] in a Perl regular expression must be escaped with a backslash if the hyphen character itself should be added to the character set. You have not done this, but instead added
- as first character to the character set. Well, this works because the error handling routines of the Perl regular expression engine detect if a
- is the first or last character in a character set definition and interpret the not escaped hyphen character in these 2 cases as character to add to the set. But better would be nevertheless to add the hyphen character escaped with a backslash.
It is not necessary to enclose a space character in square brackets if a multiplier like
+ or
* follows. A character set with just a single character makes just the find a little bit slower.
In your expression their are two capturing groups defined by the two pairs of round brackets. That should be avoided here as the inner pair of round brackets is just for the OR expression. The inner group can be defined with
?: immediately after opening round bracket as a non-capturing group.
So the Perl regular expression function string can be one of the two lines below depending on what you would like to see in function list:
/Function String = "([0-9a-z\-]+ +(?:section|division) *\.)"
/Function String = "([0-9a-z\-]+) +(?:section|division) *\."
I'm wondering that you don't use also
Line Comment Valid Columns Alt = [7] in first line. Without this additional definition the character
% is interpreted as line comment starting string wherever found in a line.
The command
Comment Add inserts the primary line comment string always at beginning of all selected lines or current line if no line selected. And command
Comment Remove removes always the first occurrence of the primary line comment string within all selected lines respectively the current line. Special limitations like those of Cobol that the line comment string is valid only in certain columns is not taken into account.
However, it is not very difficult to extend built-in
Comment Add and
Comment Remove by macros or scripts for Cobol files.
For example you can create the following 4 macros and store them all together in a macro file which is configured at
Macro - Set Auto Load to be automatically loaded on startup of UltraEdit. For fast execution of the macros it would make sense to assign hotkeys or chords to the main macros
CommentAdd and
CommentRemove instead of assigning hotkeys or chords to the 2 built-in commands.
Submacro
CobolCmtAdd:
Code: Select all
IfSel
Else
SelectLine
EndIf
UltraEditReOn
Find RegExp SelectText "%^(??????^)"
Replace All "^1*"
Submacro
CobolCmtDel:
Code: Select all
IfSel
Else
SelectLine
EndIf
UltraEditReOn
Find RegExp SelectText "%^(??????^)^*"
Replace All "^1"
Macro
CommentAdd with hotkey ???
Code: Select all
IfExtIs "CBL"
PlayMacro 1 "CobolCmtAdd"
ExitMacro
EndIf
IfExtIs "COB"
PlayMacro 1 "CobolCmtAdd"
ExitMacro
EndIf
IfExtIs "CPY"
PlayMacro 1 "CobolCmtAdd"
ExitMacro
EndIf
IfExtIs "S"
PlayMacro 1 "CobolCmtAdd"
ExitMacro
EndIf
IfExtIs "F"
PlayMacro 1 "CobolCmtAdd"
ExitMacro
EndIf
IfExtIs "F1"
PlayMacro 1 "CobolCmtAdd"
ExitMacro
EndIf
CommentAdd
Macro
CommentRemove with hotkey ???
Code: Select all
IfExtIs "CBL"
PlayMacro 1 "CobolCmtDel"
ExitMacro
EndIf
IfExtIs "COB"
PlayMacro 1 "CobolCmtDel"
ExitMacro
EndIf
IfExtIs "CPY"
PlayMacro 1 "CobolCmtDel"
ExitMacro
EndIf
IfExtIs "S"
PlayMacro 1 "CobolCmtDel"
ExitMacro
EndIf
IfExtIs "F"
PlayMacro 1 "CobolCmtDel"
ExitMacro
EndIf
IfExtIs "F1"
PlayMacro 1 "CobolCmtDel"
ExitMacro
EndIf
CommentRemove
The macros
CommentAdd and
CommentRemove execute the built-in commands except for files with one of the 5 not case-sensitive file extensions listed in the macros for which the specialized submacros
CobolCmtAdd and
CobolCmtDel are used to insert respectively remove the character
* at column 7.