CHANGE
v1.2
v2.1

Purpose, Argument, Streams, Usage, Examples, Related

Syntax

                                    ┌─STRing─┐
>>──CHANGE──┬─────────┬──┤ Range ├──┼────────┼──fromstring──tostring──┬───────────┬──>< 
            └─ANYCase─┘             └─REGexp─┘                        └─maxchange─┘

Range:

   ┌─1-*─────────────────┐
├──┼─────────────────────┼────────────────────────────────────────────────────────────┤ 
   ├──columnrange────────┤ 
   │   ┌─<───────────┐   │
   └─(─┴─columnrange─┴─)─┘

Notes:
(1) columnrange is unsigned.
Purpose

Use the CHANGE stage to replace a character or string of characters with another character or string of characters of the same or different length. CHANGE reads records from its primary input stream, replacing any occurrences of fromstring that are found within the specified columnrange with tostring, and writes the records to its primary output stream. If fromstring does not appear in an input record, CHANGE writes the record unchanged to its secondary output stream, if it is connected, otherwise it writes the unchanged record to its primary output stream.

Argument
Streams

Stream
Action
Primary input
CHANGE reads records from its primary input stream.
Primary output
After replacing any specified strings in records read from its primary input stream, CHANGE writes both records that have been changed and records that remain unchanged to its primary output stream when no secondary output stream is connected.
Secondary output
When the secondary output stream is defined and connected, CHANGE writes changed records to its primary output stream and unchanged records to its secondary output stream.

Usage
  1. CHANGE does not delay the records.

  2. If the CHANGE stage discovers that all of its output streams are not connected, the CHANGE stage ends.

  3. If columnrange is not specified and if both fromstring and tostring consist of only decimal numbers (0-9), you cannot specify a left parenthesis or a number as the delimiting character. For example:

    change /8//9/
    

    is not equivalent to:

    change 383393
    

    The first CHANGE stage changes the string 8 to 9. The second stage results in an error message because 383393 is processed as a columnrange operand rather than a delimited string. The error message is issued because fromstring and tostring are missing and they are required operands.

  4. CHANGE can also be used to delete words. By specifying a NULL tostring; for instance '//', CHANGE will effectively delete the word specified by fromstring. See the following example:

    Deleting words

  5. CHANGE verifies that its secondary input stream is not connected and then begins execution.
Examples

The following examples of the CHANGE stage command use the ANYCASE keyword and the rules that apply for preserving the case of letters.

  1. 'pipe literal /Mick/ | change anycase /mick/ /mack/ | console'
    output:
    Mack

  2. 'pipe literal /Mack MacNeill/ | change anycase /mac/ /mc/ | console' 
    output:
    Mck McNeill

  3. 'pipe literal /Mack MacNeill/ | change anycase /macn/ /mcn/ | console' 
    output:
    Mack Mcneill

  4. 'pipe literal /Mack MacNeill/ | change anycase /macn/ /mcN/ | console' 
    output:
    Mack McNeill

  5. 'pipe literal /Mack MacNeill/ | change anycase /Macn/ /mcn/ | console' 
    output:
    Mack mcneill

  6. 'pipe literal /Mack MacNeill/ | change anycase /MacN/ /McN/ | console' 
    output:
    Mack McNeill

  7. If we revisit our example above; we will also notice that a regular expression is used to select both upppercase and lowercase combinations of the word 'the' with the ANYCASE keyword.

    Deleting words
Related

SPECS, TRANSLATE

History

Version
Date
Action
Description
Pipelines
1.2
??.??.2025
changed
Application-wide rewrite
2.1
1.1
04.02.2012
added
Support for the REGEXP keyword; which specifies that the fromstring and tostring operands are interpreted as a regular expression and a format string, respectively.
2.0
1.0
06.09.2007
created
First version.
1.0