Contents of Article


Differences between Column Shift and Data Shift line commands

Indent Shift - a new kind of Column Shift line command

Data-Shifting Insert-Mode function

Data-Delete function

Data-Backspace and Data-Delete-Mark


Introduction


When you edit data, the editor automatically shifts characters on a line to the left or right to accommodate insertions or deletions. This shifting can be either implicit or explicit. Implicit shifts occur when INS mode is in effect when you press the Insert key, deleting characters with the DEL key, or when the CHANGE command string-2 length is different from the string-1 length.


There are three new facilities available for shifting of data. These are Data-Shifting Insert Mode, and the Data Delete function, described at the end of this section, and the Indent Shift line commands described here.


Explicit shifts occur when you use the following line commands:

    • ( or ((        Column Shift Left
    • ) or ))        Column Shift Right
    • < or <<        Data Shift Left
    • > or >>        Data Shift Right
    • [ or [[        Indent Shift Left
    • ] or ]]        Indent Shift Right


Two columns is the standard default for shift operations. This default can be changed to any number of columns desired (in the range of 1 through 999 columns) by a General Options setting. 


When shifting a block of lines more or less than the default, enter the amount on the first or last line of the block. If you enter it in both places, the line shifts only if both amounts are the same.


Differences between Column Shift and Data Shift line commands


There are some significant differences between Column shifts and Data Shifts. Shifting occurs within the column boundaries (either the default - the whole line) or those specified with the BOUNDS command or the BNDS line command. 


Column Shift moves all characters within the bounds without altering their relative spacing. Characters shifted past the bounds are deleted. That is, blanks are inserted at the bound from which the characters are being shifted, and the characters are deleted at the opposite bound. So, this shift is called a destructive shift because information shifts within column boundaries without regard to its contents, and can result in the loss of data with no error being noted. 


Data Shift moves characters non-destructively within the BOUNDS. The end-result of a data shift is a change in the widths of one or more spans of blanks; nonblank data will not be changed or deleted.


For data shift left attempts that exceed the current Left BOUNDS setting, text movement stops at the left bound.


Note: The ISPF editor marks lines with ==ERR> flags when a data shift operation can only be partially completed, either because of the data contents of the line or the current location of the BOUNDS. SPFLite recognizes the same conditions, but currently does not support the display of ==ERR> flags. Instead, it will display a message if there were any lines that could not completely shifted. The message will say "Data shifting incomplete" and will report the number of lines for which the full shifting amount could not be applied.


Data shifting works by moving contiguous spans of nonblank characters as a unit, and 'pushing' adjacent spans of characters as needed to make sure there is no data loss. When spans of nonblank characters are separated by only one space, that space is never collapsed (deleted); that way, the spans of nonblank data are never 'run together'.

                                                                          

For a data shift right, shifting can occur up to and including the right bound column. If the right bound is MAX, right-shifting the data line may result in making it longer.


For a data shift left, shifting can occur up to but not including the right bound column.


If left BOUND column of the data line is nonblank, it defines a "label" field, which is locked at that position and is not moved during either a left or right data shift.


Note:  The Data Shift commands are intended to allow for non-destructive shifting of the kind of data that appears in typical programming-language statements, by applying some general rules. These rules require a certain amount of parsing and analysis of your data. The support in SPFLite for Data Shifting commands has been extensively tested, and great efforts were made to ensure that it handles data in an ISPF compatible manner. However, because these general rules may or may not be applicable or useful in your particular situation, you should inspect the results of a Data Shift to ensure you obtained the results you intended, until you are familiar with how this feature operates.


Example:


=BNDS>    <                                               >

000010    Word1    Word2     Word3                    Wordn


If a Data Shift Right command of >10 is entered on line 00010 the result would be


=BNDS>    <                                               >

000010    Word1              Word2     Word3          Wordn


As can be seen,  Word1 and Wordn  have been left alone, and only the other data shifted.


Note: Data Shift line commands have the following features:


    • Spaces contained inside of strings enclosed in ' single quotes or " double quotes are considered 'protected' and will not be compressed or expanded as a result of data shifting. For this 'protection' to apply, the string must be properly closed. That is, there must a close-quote of the same kind that begins the string value. An individual quote (such as an apostrophe in a word like don't) is ignored for purposes of protecting spaces. There is presently no support for treating ` accent quotes in the same way; accent characters are ordinary data.


    • IBM ISPF documentation states that both ' single quotes and " double quotes are supposed to be handled the same way, but tests show that their string handling is not consistent with their documentation, and is release-dependent. SPFLite fully supports both quote types in this regard.


    • When you perform data shifting on data that has colors, the colors are shifted as well, so that the underlying colors of your nonblank data will not change.


    • If you issue a data shift command for a line that has colors, you need to be aware that spaces can have colors as well. Even though a space has no visible graphic symbol, there is still an underlying "color attribute byte" just like any other data character on a line. Colorized spaces may or may not be visible, depending on the background highlight color you choose for it in the Screen Options dialog. In most cases, this is not usually important, but if you issue commands like FIND "ABC DEF" RED, the string will only be found if it is entirely RED, including the blank in the middle. When a Data Shift command moves spans of nonblank characters around on a line, existing spans of spaces can get larger or smaller. If these spans of spaces have color attributes, the attributes for the existing span of blanks are copied, as much as will fit, into the new span of blanks, if equal or shorter in length. If the new span is larger because blank data characters were inserted, the color attribute of the inserted blanks will be the same as the rightmost blank of the existing span of blanks (the rightmost color attribute is propagated). In the FIND example, if you had a string of "ABC   DEF" with the blank in between having an attribute of RED, and it became "ABC       DEF", all the new blanks would also be RED, and everything should work fine. However, if for some reason you had a string like "ABC       DEF" in which the inner blanks had mixed color attributes, the color attributes are propagated on the right (the blue blanks are extended) or are truncated on the right. This may or may not be the results you intended. If your data has unusual color attributes, you may wish to avoid using data shifting on such data, or verify or re-establish the colors after the data has been modified by a data shifting operation.


    • In order to properly handle quoted strings in the C language and similar syntax, a single or double quote preceded by a \ backslash can be treated as ordinary data and not as a quote. This is an extension to ISPF, which does not recognize escapes in string data. Support for recognizing \ backslash escapes is an experimental feature, enabled by the use of the SPFLite SET symbol OPT.DS.ESCAPE. If this SET symbol is defined as 1, backslash-escaped quotes will be bypassed; otherwise backslash characters will be treated as ordinary data. Because this is an experimental feature, it is subject to change (or even removal) in future releases.


    • By default, spans of blanks are never compressed shorter than one blank. As an experimental feature it is possible to make the default minimum size of the space between nonblank spans larger, by the use of the SPFLite SET symbol OPT.DS.MINSIZE. If you define this, the symbol can have a value from 1 to 9. For example, a COBOL programmer might want to shift items in the Data Division using a default MINSIZE of 2, so that level numbers are separated from data names by two spaces. If you define this value as greater than 1, and a data shift operation would "push" one span of nonblanks next to another, and the space between them was already less than the defined minimum, the spacing is left as is rather than being increased to the minimum. For example, if you set OPT.DS.MINSIZE to 2, and do a right data shift of 10, suppose you had string like  "ABC DEF"  that was pushed right. Since the space between ABC and DEF is just one blank, it stays that way and is not expanded to 2, even though the "minimum" size was set to 2. The MINSIZE value only applies to existing spans that were already larger than the minimum. Because this is an experimental feature, it is subject to change (or even removal) in future releases.


Indent Shift - a new kind of Column Shift line command


SPFLite supports the Indent Shift facility. In terms of how data interacts with Bounds, as described above, an Indent Shift may be thought of as a specialized form of Column Shift. When there is no n value on an Indent Shift line command, the number of columns shifted is the same as the default shift columns value that appears in the General Options dialog. So, a simple ] command with no n value works the same way as ) does. And, as always, a command like )n overrides the default, so if the default is 4 and you say )3 you indent 3 columns.


However, when a command like ]n is used, the n value is not an override.  Instead, the Indent Shift takes the established default number of columns and multiplies it by n


So, if the default columns was 4, and you issued a ]3 line command, the number of columns shifted would be 4 x 3 = 12. Suppose you are entering data, and wanted it formatted so that there were indentations at 4-column boundaries. Now, if you wanted to indent by 3 "indentation levels" you could use ]3 rather than )12


Using Indent Shifts, you no longer have to think in terms of columns, but in terms of the number of indentation levels you are working with. 


As an added convenience, because the Indent Shift line commands use the [ and ] bracket keys (which are non-shifted keys on many keyboards) these commands will be a little easier to type than ( and ) for most users.


Data-Shifting Insert-Mode function


There is a close relationship between SPFLite's standard Insert Mode and the ) Shift Right line command. For example, if a line command of )4 is issued, four blanks are inserted at the beginning of the line, which is the same thing that would happen if Insert Mode is enabled, then the cursor is moved to the beginning of the line, and then finally the spacebar is pressed four times.


It is desirable to also have a relationship between an “insert mode” and the > Shift Right Data line command. It is now possible with the Data Shifting Insert Mode, enabled by the (DataInsert) keyboard function.


A suggested mapping for this key is Ctrl-Insert or Shift-Ctrl-Insert. 


By the way, it's technically possible to map the Shift-Insert key also, but that is not recommended. If you are entering capital letters by holding down the shift key and then press Insert, you probably just want to enter normal Insert Mode and not do something special.


The (DataInsert) function will toggle Data Shifting Insert Mode, somewhat similar to the INS mode that occurs when the Insert key is pressed. Data Shifting Insert Mode allows data to be inserted into lines in a way similar to the way that the Data Shift line command > operates. Because of this, if you are inserting data that is formatted into columns, (DataInsert) will not disturb the column alignment, as long as two or more blanks separate the columns. 


Looking at the example below, suppose we want to insert some data before the commas on each line, and we do not want to disturb the column containing CCC but want to keep it aligned. It may be possible to do this with BOUNDS, but BOUNDS can be inconvenient to use. With Data Shifting Insert Mode, you can enter data and have SPFLite maintain the alignment of columns in a way similar to how a word processor would maintain the alignment of tabbed columns (without actually using tabs). 

   

When Data Shift Insert Mode is in effect:

    • non-blanks are shifted right as new data keys (including spacebar) are pressed, as usual  


    • when existing non-blanks are pushed to the right, and a span of two or more blanks follows the non-blanks, the span of blanks is shortened


    • a span of blanks will never be completely removed by shortening it; there will always remain at least one blank


    • the status indicator will show INS instead of INS or OVR


    • pressing either of the the keys mapped to (Insert) or (DataInsert) will cause the status indicator to revert from  INS back to OVR


For example, assuming the following data lines:


000001 A,B       CCC

000002 AA,BB     CCC

000003 AAA,BBB   CCC


Suppose we want to add 1, 22 and 333 before the commas on the data lines above. Using regular Insert Mode, this would first produce:


000001 A1,B       CCC

000002 AA22,BB     CCC

000003 AAA333,BBB   CCC


and the lines would have to be ‘repaired' to restore the alignment of the CCC column. With Data Shifting Insert Mode, the strings ending in B would be pushed to the right without moving the CCC column, as long as no data loss occurred. On line 3, that is not possible, and so its CCC value has to be pushed over:


000001 A1,B      CCC

000002 AA22,BB   CCC

000003 AAA333,BBB CCC


When multiple spans of blanks exist, they get “compressed” in left-to-right order, starting from the point on the line where the cursor is positioned and going rightward as needed.


When a key mapped to (DataInsert) is pressed, the editor enters Data Shifting Insert Mode. To distinguish this mode from regular Insert Mode on the Status Line, the regular INS indicator is displayed in Green hilights as INS instead.


When the editor is in Data Shift Insert Mode, pressing (DataInsert) again will toggle Data Shift Insert mode off, and return the previous state of the Insert key.


Data-Delete function


This function will delete text in the same way that (Delete) does, except that the data being "pulled left" by the delete action is "delimited" by any span of two or more blank characters. Because of this, if you are deleting data that is formatted into columns, (DataDelete) will not disturb the column alignment, as long as two or more blanks separate the columns.


Unlike the (DataInsert) function, (DataDelete) does not define or toggle a "mode" but merely deletes a character, as described below.


A suggested mapping for this key is Ctrl-Delete or Shift-Ctrl-Delete.


Let's take the same data from above, inserting an additional line, and compare (Delete) and (DataDelete). Assuming the following data lines:


000001 A,B       CCC

000002 AA,BB     CCC

000003 AAA,BBB   CCC

000004 AAAA,BBBB CCC


Suppose we want to delete the words A, AA, AAA and AAAA. Using regular (Delete) function, this would produce:


000001 B       CCC

000002 BB     CCC

000003 BBB   CCC

000004 BBBB CCC


and the CCC column gets shifted over. Using the (DataDelete) function produces:


000001 B         CCC

000002 BB        CCC

000003 BBB       CCC

000004 BBBB CCC


Note that the CCC column gets shifted over on line 4. That is because there was only one space between the original BBBB and the CCC, and so the string "BBBB CCC" is treated as a "single unit" of text, and is pulled to the left. On lines 1-3, the CCC string in each case was preceded by two or more spaces, and so it does not get pulled to the left on those lines.


Data-Backspace and Data-Delete-Mark


Two new functions are available that involve data shifting. These are (DataBackspace) and (DataDeleteMark).


(DataBackspace) is essentially a cursor-left-one followed by a (DataDelete).


(DataDeleteMark) will delete highlighted (marked) text in the same way that (DataDelete) does, but if there is no text highlighted, the function does nothing.


Created with the Personal Edition of HelpNDoc: Free Web Help generator