Contents of Article


Case sensitivity and default search context

Mouse-based text editing

Formatting paragraphs

Splitting lines

Joining and gluing lines

The GLUEWITH command

Case-conformant change strings

Performing line swaps

Performing text swaps

Text-swap example

Text Move example

Using raw-mode copying

Application Note: Splitting Lines Based on a Search String


Introduction


SPFLite is not designed as a word-processor per se, since its primary focus is on editing lines rather than words, just as in IBM ISPF. However, a number of word-processing features have been added, so that when you need to do simple word-processing tasks, you will  have less need to leave SPFLite for some other editor (like Notepad) and then come back.


This section is a general overview of the commands used for word or text processing. These commands consist of the line commands: TF (text flow), TS (text split), UC (Upper Case), LC (Lower Case) SC (Sentence Case) and TC (Title Case). As Primary commands there are the companion commands UC, LC, SC, and TC. And as keyboard primitives we have (UpperCase), (LowerCase), (SentenceCase) and (TitleCase). TF now also comes in a block-mode form, the TFF command and new commands Text Break (TB) and Text Margin (TM) are also available.


You can take advantage of implicit highlighting of single characters. When character-modification functions are used when the cursor is in the data area, but no data is actively being highlighted, the single character at the cursor position is modified as if that character were highlighted. Making such small changes is now easier, faster and more reliable. Functions affected by this are any that modify data that is dependent on a selected field, such as word-processing functions (UpperCase) and (LowerCase), and color modification functions like (PenRed).


The 'casing' commands allow quick changing of the case of a portion of text into alternative formats. SC reformats in sentence format: the first letter of the first word of a sentence is capitalized, and all other characters are lowercased. TC reformats as a Title: the first letter of each word is capitalized. UC and LC are conventional Upper Case and Lower Case commands. 


TF and TS assume that the data is grouped in paragraphs. A paragraph is a group of lines that begin in the same column. The first line of a paragraph is excluded from the grouping. The editor interprets any indentation or blank line as representing a new paragraph. It also recognizes  word processor control words used by various common scripting languages. These control words begin with a period, a colon, a '<', or an ampersand. Also, additional "paragraph-based" line commands Text Break TB/TBB and Text Margin TM/TMM are available.


If you use text line commands frequently, you can assign commands like TS, TF, TB and TM to function keys. (Assigning block-mode commands like TFF, TBB and TMM is possible but not as useful.)  Use KeyMap  to open the keyboard preferences dialog.


See also Using TM to Emulate the TE command on ISPF for notes about simulating the ISPF Text Entry line command.


See also Application Note: Splitting Lines Based on a Search String.


Case sensitivity and default search context


You can use the CASE command so that unquoted strings, like ABC, or quoted strings without a type code, like 'ABC' will be assumed to be case-sensitive, as if specified as C'ABC', or case-insensitive as if specified as T'ABC'. These defaults are set with CASE C or CASE T, respectively. See the CASE command for more information.


FIND and CHANGE commands take an option that describes the search context, which is are the conditions under which SPFLite decides that a string of characters is the one you want. The deciding factor is whether a string is delimited or not, and if so, where. A delimiter is either (a) any character not listed on the WORD line, or (b) a blank, or (c) the left or right edge of the line. The choices you get basically allow you to either require a delimiter or they require the absence of a delimiter. With that in mind, the four standard search contexts are:


Search Context Operand

Delimiter present on left?

Delimiter present on right?

CHARS

Don't care

Don't Care

WORD

Yes

Yes

PREFIX

Yes

No

SUFFIX

No

Yes


By default, SPFLite normally assumes the CHARS context; that is, it doesn't care what is on the left and right side of string. If the string is there, it's found. If you are working extensively with words, it would be convenient if you didn't have to keep saying FIND ABC WORD all the time. 


To let SPFLite know that you want to assume you are working with words unless you say otherwise, you can say FIND WORDS or FIND CHARS to temporarily change this assumption. See the FIND command for more information. To permanently change this assumption, you can set the Use WORD as the default for FIND/CHANGE commands checkbox in the Options - General tab of SPFLite Global Options.


See the FIND command and the WORD command for more information.


Mouse-based text editing

 

The mouse can be used to quickly perform certain editing tasks faster than using the keyboard alone. You are invited to try these techniques yourself to see how useful they can be:


    • If you highlight part of a line with the mouse, you can delete it using the DEL key, or replace it with any single data character by typing it. So, if you had a string like aaaXXXbbb where the XXX part was highlighted, typing the DEL key would produce aaabbb and typing a / slash character would result in aaa/bbb.


    • If you double-click on a 'word' string (characters that are bounded by non-WORD characters or by the edge of the line) the whole word will be highlighted.


    • If you highlight a 2-dimensional block of characters, the DEL key will delete the whole square block. If you type any single data character, that character will appear once on each line of the block, the same as if the block were first entirely deleted and then replaced by a vertical column one character wide, one for each line of the block. So, if you had a block where aaaXXXbbb appeared on each line in the block and the XXX part was highlighted, typing the DEL key would produce aaabbb on each line of the block, and typing a / slash character would result in aaa/bbb on each line of the block.


    • If you highlight a 2-dimensional square block of characters, you can copy the whole block into the clipboard. You can then paste that whole square block into another location, using the (Paste) function. 


    • If you highlight part of a line, or  2-dimensional square block of characters, you can replace the highlighted area with an equal number of blanks, by using a key mapped to the (Erase) function.


    • If you highlight part of a line with the mouse, you can find additional instances of that string using the (FindNext) and (FindPrev) functions.


    • You can use the mouse to quickly enter frequently-used line commands. For example, the line commands CC and MM are often used on blocks of lines. By setting selected mouse-button actions, a single mouse click can set a command on a line. For example, suppose that Ctrl+Left Mouse Button were mapped to {CC}. Then, by just holding down the Ctrl key, you can quickly set the boundary of a CC block by clicking the left mouse button on the desired line.

 

Formatting paragraphs

 

The TF (text flow) line command formats paragraphs. It assumes that the sentences are roughly in paragraph form with a ragged right margin when it attempts to recognize groupings. TF can be followed by a number (TF72 for example) to specify the desired right side column for the paragraph. If you do not specify a number, the current right side of the edit screen is used.


The editor assumes that because the first line of a paragraph may be at a different indentation level than the remainder of the paragraph, the starting column of the second line is the left side of the paragraph. When formatting paragraphs, the editor: 


    • Moves text so that each line contains the maximum number of words. TF limits its activity to within the limit described above. Thus, it can be used to flow text within a border. 
    • Keeps any blanks between words.
    • Assumes one blank between the word at the end of a line and the word on the next line.


The end of the paragraph is denoted by a blank line, a change in indentation, or the special characters period (.), colon (:), ampersand (&), or left carat (<) in the left boundary column. These special characters are commonly used as control indicators by a variety of scripting languages and formatting utilities. 


The restructure operation removes trailing blanks on a line by using words from the following line. It does not remove embedded blanks within a line. Accordingly, if one or more words in a line are to be removed, delete the words rather than type over them.


You can use the TFF block command to perform the same paragraph formatting done by TF, but applied to multiple paragraphs.


You can also use the Text Margin line command TM/TMM to format paragraphs much like TF does, but in a way that is less sensitive to any non-default BOUNDS margins that may be in effect. See TM / TMM - Set Text Margin for more information.


Splitting lines


The Text Split line command TS splits a line into two lines. The cursor shows where the line is to be split. The editor moves the characters to the right of the cursor or to a new line following the original line and aligns the new line with the left side of the paragraph. As mentioned earlier, the left side of a paragraph is determined by looking for a pattern in the lines preceding or succeeding a paragraph.


One or more blank lines are inserted after the line being split, depending on what you specify when you enter the TS command. If not used, these lines will be removed (as are all inserted temporary lines). You can also specify a zero line count using TS0 to split lines without inserting any blank lines between them.


Most users will find it faster and more convenient to map the TS command to a key (such as Alt-S, for example) and to move the cursor to the desired split point by using the mouse.


You can map mouse buttons with any combination of Shift, Ctrl and/or Alt modifiers. As an example, you could map the Alt+Left Mouse Button to {TS}(2:Enter). By doing this, you can quickly split any line by holding down the Alt key, moving the mouse pointer to the desired location and pressing the Left Mouse Button.


The Text Break line command TB/TBB also breaks apart lines like TS does, but when blank lines are inserted at the break point, these are permanent blank lines rather than temporary ones. The TBB form can be used to break apart of block of lines all at the same column location. Like TS, TB/TBB will take an n value of 0 to insert zero blank lines.


You can also use the SPLIT primary command to split lines based on a Picture string.


Joining and gluing lines


The existing Join and Glue line commands J/JJ and G/GG perform "physical" join and glue operations. That means that for any two lines being physically combined, the data on the original lines themselves is not changed.


In addition to "physical" join and glue, you can perform a "text join" or "text glue" using TJ/TJJ and TG/TGG. When lines are combined in "text" mode, the "join point" of each line (the point at which the two lines are combined together) are trimmed of blanks. For example, if line 1 and line 2 are being joined or glued together in text mode, all trailing blanks are deleted from the right side of line 1, and all leading blanks are deleted from the left side of line 2.


With these meanings in mind, here is what the Join and Glue command do:

 

The J/JJ (physical join) line command concatenates lines together, with one intervening blank at the join point of each line. The contents of the original lines are not changed.


The G/GG (physical glue) line command concatenates lines together, with no intervening blanks at the join point of each line. The contents of the original lines are not changed.

 

The TJ/TJJ - Text Join Lines command concatenates lines together, with one intervening blank at the join point of each line. The original lines are trimmed of leading or trailing blanks (as discussed above) at the join point.


The TG/TGG - Text Glue Lines command concatenates lines together, with no intervening blanks at the join point of each line. The original lines are trimmed of leading or trailing blanks (as discussed above) at the join point.


You can also use the JOIN primary command to join lines based on a Picture string.


The GLUEWITH command


By default, the Glue line commands G/GG and TG/TGG concatenate glued lines together with no intervening blanks or other characters. The GLUEWITH command can be used to define a string to be inserted between such glued lines.


The GLUEWITH string is a global value, and has an installation default of '' (a zero-length string). This value is stored in the SPFLite CFG configuration file, and is thus persistent. The only way to view or modify the GLUEWITH string is by using the GLUEWITH primary command in an edit session.


The GLUEWITH string setting applies only to the Glue commands G/GG and TG/TGG, not to the Join commands J/JJ and TJ/TJJ. 


Case-conformant change strings


When you do a change with search string having a type code of T, it matches letters in a case-insensitive way. So, if you say,


       CHANGE WORD T'four' 'nine'


it will match on the word “four” no matter how it is capitalized. However, regardless of the original string, the result of this CHANGE will always be capitalized as “nine”:


       four        becomes  nine

       Four        becomes  nine

       FOUR        becomes  nine        


and so, the result fails to conform to the character-casing of the original string.


With case-conformant changes, you can make the result string match the pattern of upper and lower casing that existed in the original string. That is, NOW you can make this happen:


       four        becomes  nine

       Four        becomes  Nine

       FOUR        becomes  NINE        


How?  Just put a type code of T on the change string, like this:


       CHANGE WORD T'four' T'nine'


You can find more information in the Case-Conformant Change Strings section of Finding and Changing Data.


Performing line swaps


SPFLite provides an easy way to swap data from two different areas. The types of data swaps that are supported are line swaps and text swaps. See M / MM - Move Lines and W/WW - Swap Lines for more information on line swaps. 


Performing text swaps/moves


A text swap occurs when a single-line or multi-line selection of text is swapped with another another one. If a single-line text selection is involved, the data can be either on the same line or on another line. When both segments are on the same line, no overlap may occur. 


Note:  It is also possible to swap a marked block when no second block is highlighted, effectively making the swap activity into a text-move function. The marked block is moved to where the cursor is currently located, and text to the right of it is pushed over to make room.


Even with traditional editors like Notepad with its Windows-oriented cut-and-paste functions, it's not an easy thing to do, but SPFLite makes this task quite simple. The process works like this:


    1. A keyboard primitive command (Swap) is now defined.


    1. The (Swap) command must be mapped to a key. There is no default mapping for (Swap); you must map this yourself. For sake of discussion, let us assume this key is Alt-W, though any desired key may be used.


    1. Highlight a piece of text on a single line or on multiple lines. Text selection can be done with the mouse, with shift-arrow keys, or with the line command T/TT. Then press Alt-W.


    1. The highlighting used for the text that is going to be swapped changes to underscores, and a message of  Swap pending  appears on the status line.


    1. Now, highlight a second piece of text on a single line or on multiple lines, and press Alt-W again. Now, the two sections of text are swapped, all highlighting coloring is removed, and the Swap pending status disappears.


    1. Note: The two areas of text may, but need not, have the same width. As seen in the example below, the strings GROSS-PAY and NET-PAY are swapped, even though they are of different sizes. The second marked area may not even be an area. If no area is selected but the cursor remains within the normal text area (and not within the 1st marked area), then it is treated as a Null marked area and the cursor indicates where the 1st marked area is to be moved.


    1. If you are swapping a 2D multi-line block of text, follow the same procedure as is described above. When you get to the point where you are defining the second two-dimensional block, SPFLite know how many lines are involved in the first two-dimensional block, and will automatically highlight that many lines in the second block. 


For example, if you first define a block of 10 columns by 5 lines, when you begin to highlight the second block, SPFLite knows the first block is contained on 5 lines, so as you go to highlight the second block, it will automatically highlight 5 lines, starting on the line where you begin highlighting. This is done so you don't have to manually try to "get the size right" on the second block - this is done for you. The two blocks need not be the same width, just as equal widths are not required for single-line text swaps.


    1. Special considerations:   If you do the first part of the text-Swap, and the Swap pending status was visible, and then you decide to change your mind and not finish it, you can “back out of it” in one of two ways:  (a) While ensuring that no ‘normal' highlighting is in effect, type Alt-W again. Since there would be no second text block with which the first block is to be swapped, the second Alt-W in this case is considered as a “cancel” request; the Swap pending status disappears and all highlighting is removed. (b) Text Swap is canceled in response to an ordinary RESET command; no special keywords need to be added. 


    1. The Swap-pending status is not persistent and not saved in the STATE information.


This might sound a little involved, but once you understand the process, you will see that text swapping is actually very easy, convenient and fast. Try it!


Text-swap example


000001     MOVE GROSS-PAY TO NET-PAY.


Highlight first field via mouse:


000001     MOVE GROSS-PAY TO NET-PAY.


Invoke the (Swap) function (via Alt-W in the sample key mapping); this causes the highlighted field to be underlined instead:


000001     MOVE GROSS-PAY TO NET-PAY.


At this point, the status line contains: Swap pending


Now, highlight second field via mouse:


000001     MOVE GROSS-PAY TO NET-PAY.


Invoke (Swap) function (via Alt-W) a second time; fields are swapped; underscores and highlighting are now removed:


000001     MOVE NET-PAY TO GROSS-PAY.


At this point, the status line no longer contains: Swap pending



Text-move example


This is similar to the previous example but demonstrates using a null block for the 2nd marked area to cause a Move operation to take place.


000001     MOVE GROSS-PAY TO RIGHT-HERE.


Highlight first field via mouse:


000001     MOVE GROSS-PAY TO RIGHT-HERE.


Invoke the (Swap) function (via Alt-W in the sample key mapping); this causes the highlighted field to be underlined instead:


000001     MOVE GROSS-PAY TO RIGHT-HERE.


At this point, the status line contains: Swap pending


Now, move the cursor to the insertion point (the 1st character of RIGHT-HERE:


000001     MOVE GROSS-PAY TO RIGHT-HERE.


Invoke (Swap) function (via Alt-W) a second time; the 1st marked field is moved to the insertion point:


000001     MOVE TO GROSS-PAY RIGHT-HERE.


At this point, the status line no longer contains: Swap pending



Using raw-mode copying


You can copy data in what is termed Raw Mode. Raw mode copy means that there are no End of Line terminators inserted into the copied text. So, when you copy text that encompasses more than one line, all the text from all of the lines are effectively glued together in one long character string. This action happens under the following cases:


    • CUT primary command with RAW keyword




When you copy text in Raw Mode, you can then go outside of SPFLite and paste the text thus copied as if were a single line, for example, into a Notepad session. By doing this, you would be able to perform a type of conversion from the kind of individual lines that SPFLite edits to text that may wrap across multiple lines, as editors such as Notepad commonly deal with.


Application Note: Splitting Lines Based on a Search String


(Prior to introduction of SPLIT / JOIN commands)


Sometimes you may need to split one or more lines apart based on a string. For example, a common data format is called Comma Separated Values, or CSV. As the name implies, these are files with data fields separated by commas. Suppose you had a file of such values and wanted the fields to be split apart on separate lines. You could manually position the cursor each place a comma appears, and issue a Text Split line command TS mapped to some key. If you had to do this for many lines, it could be very time-consuming.


Since the release of SPLIT / JOIN, these tasks are now facilitated by the SPLIT and JOIN edit primary commands. 

See Working with SPLIT and JOIN Commands for more information.



Created with the Personal Edition of HelpNDoc: Keep Your PDFs Safe from Unauthorized Access with These Security Measures