:CUT_PROCESS, CUT_PROCESS
Use CUT_PROCESS to cut out a row or range of code points, for example, to cu out columns you specify from any text or table. You can use this scripting element with process handles and select specific columns and work only within them.
Note: The terms Data Sequences and Text Containers are used interchangeably.
This scripting element can be used as both, a script statement and a script function:
-
When used as a script statement, it modifies the text container of the input handle and provides the result in that text container. This is useful for stacking commands to modify text containers, thus avoiding reallocating new process handles.
-
When used as a script function, the text container of the process handle is provided read-only, and the result is provided in a new text container as a return value of the function.
Syntax
When used as a script statement:
:CUT_PROCESS Handle,[, Column[, Range[, Flags]]]
When used as a script function:
CUT_PROCESS (Handle,[, Column[, Range[, Flags]]])
Parameters
-
Handle
Process handle of a text container
Format: script literal or script variable
-
Column
(Optional) The index indicates which column to search, beginning with 1, or the entire line if the index is 0.
If the text container (data sequence) loaded had columns defined, you can select a specific column and use this script element to work within the relevant column. To do so, make sure you know which column delimiter was used at the time of loading the text container (data sequence). Otherwise, you can define the delimiter using the ādā flag.
Format: script literal, script variable or number without quotation marks, Column number or 0 for plain line.
Default value: 0
-
Range
(Optional) Defines the code point range.
When you specify a column, the range is applied to the column selected.
Allowed values:
-
-n: up to
-
m- : starting at
-
m-n: between
-
-
Flags
(Optional) Use flags to modify the operation. The flags available are:
-
v: Inverted selection
Inverts the range specification.
-
d: Delimiter that separates columns
Allows you to define a specific delimiter, which can be any text of at least one character, to virtually break up text into columns. The delimiter is enclosed by the character immediately following the "d". This overwrites any default delimiter that the text container might have. For example:
d' ' for a single blank space
d'$$' for a sequence of two dollar signs
d+,+ for a comma
d!foo! for the word "foo"
Flags can be combined and provided in any order. For example, if you combine flag v with flag d/ /, you can do so using "vd/ /" or "d/ /v", or the script variable &FLAG#.
-
Examples
These examples combine the script elements CAT_PROCESS, CUT_PROCESS, HEAD_PROCESS, TAIL_PROCESS and SWAP_PROCESS in and Include Job (JOBI) and a Job (JOBS) aiming to get different information from a financial report:
Include object (081.INC.PRINT_AND_SUM_NUMBERS) Process page definition:
!* Input:
!* &YEAR# ... year
!* &HND_NUMBERS# ... with numbers
!* Get revenue numbers in the second column from character position 12 to 35
:SET &HND_COL2# = CUT_PROCESS(&HND_NUMBERS#, , "12-35")
!* Get revenue numbers in the second column from character position 12 to 35
:CUT_PROCESS &HND_COL2#, 1, , "d/ /"
!* Output
:PRINT Quarterly results of year &YEAR#:
:DEFINE &TOTAL#, FLOAT
:SET &TOTAL# = 0
:PROCESS &HND_COL2#
: SET &REP_NUMBER# = GET_PROCESS_LINE(&HND_COL2#)
: PRINT &REP_NUMBER#
: SET &TOTAL# = &TOTAL# + &REP_NUMBER#
:ENDPROCESS
:DEFINE &TOTAL_STRING#,STRING
:SET &TOTAL_STRING# = FORMAT(&TOTAL#, "00.0")
:PRINT Total revenue of year &YEAR#: &TOTAL_STRING#
:CLOSE_PROCESS &HND_COL2#
Job Post Process page definition:
!* Get numbers from report
!* Load report to text container
:SET &HND_REPORT# = PREP_PROCESS_REPORT()
!* Cut off job messenger header
:SET &HND_TABLE# = TAIL_PROCESS(&HND_REPORT#, -9)
!* Cut off job messenger trailer
:HEAD_PROCESS &HND_TABLE#, -11
!* Cut off table header
:SET &HND_NUMBERS# = TAIL_PROCESS(&HND_TABLE#, -2)
!* Get numbers of 2022 only and put them into a separate text container &HND_NUMBERS_2022#
:SET &YEAR# = "2022"
:SET ®EX_QSYEAR# = "Q. &YEAR#"
:SET &HND_NUMBERS_2022# = GREP_PROCESS(&HND_NUMBERS#, ®EX_QSYEAR#)
!* Get numbers of 2023 only and filter for them in the same text container &HND_NUMBERS#
:SET &YEAR# = "2023"
:SET ®EX_QSYEAR# = "Q. &YEAR#"
:GREP_PROCESS &HND_NUMBERS#, ®EX_QSYEAR#
!* Print and sum numbers of &YEAR# 2022 in text container &HND_NUMBERS_2022#
!* As output routine in include works with script variable &HND_NUMBERS#, we have to swap the containers first
:SWAP_PROCESS &HND_NUMBERS#, &HND_NUMBERS_2022#
:INC 081.INC.PRINT_AND_SUM_NUMBERS
!* Print and sum numbers of &YEAR# 2023 that have been swapped to text container &HND_NUMBERS_2022#
!* As output routine in include works with script variable &HND_NUMBERS#, we have to swap the containers first
:SWAP_PROCESS &HND_NUMBERS#, &HND_NUMBERS_2022#
:INC 081.INC.PRINT_AND_SUM_NUMBERS
!* Combine both text containers to &HND_NUMBERS# in reverse order:
:CAT_PROCESS &HND_NUMBERS#, &HND_NUMBERS_2022#, "r"
!* Summarize both years and print numbers in reverse order
:SET &YEAR# = "2023 + 2022"
:PRINT Both years combined in reverse order:
:INC 081.INC.PRINT_AND_SUM_NUMBERS
After executing the Job, the Post process report (POST) shows the following information:
2025-08-07 14:35:21 - U00020408 Quarterly results of year 2023: 2025-08-07 14:35:21 - U00020408 7.7 2025-08-07 14:35:21 - U00020408 8.1 2025-08-07 14:35:21 - U00020408 8.5 2025-08-07 14:35:21 - U00020408 8.9 2025-08-07 14:35:21 - U00020408 Total revenue of year 2023: 33.2 2025-08-07 14:35:21 - U00020408 2025-08-07 14:35:21 - U00020408 Quarterly results of year 2023: 2025-08-07 14:35:21 - U00020408 8.9 2025-08-07 14:35:21 - U00020408 8.7 2025-08-07 14:35:21 - U00020408 8.8 2025-08-07 14:35:21 - U00020408 9.3 2025-08-07 14:35:21 - U00020408 Total revenue of year 2023: 35.7 2025-08-07 14:35:21 - U00020408 2025-08-07 14:35:21 - U00020408 Both years combined in reverse order: 2025-08-07 14:35:21 - U00020408 Quarterly results of year 2023 + 2022: 2025-08-07 14:35:21 - U00020408 9.3 2025-08-07 14:35:21 - U00020408 8.8 2025-08-07 14:35:21 - U00020408 8.7 2025-08-07 14:35:21 - U00020408 8.9 2025-08-07 14:35:21 - U00020408 8.9 2025-08-07 14:35:21 - U00020408 8.5 2025-08-07 14:35:21 - U00020408 8.1 2025-08-07 14:35:21 - U00020408 7.7 2025-08-07 14:35:21 - U00020408 Total revenue of year 2023 + 2022: 68.9
The Job report (REP) shows the following information:
See also: