Please enable JavaScript to view this site.

InterFormNG2 Manual

Navigation: XPath > Built-in functions

ng:spoolMapCond

Scroll Prev Top Next More

IMPORTANT: This function is only supported for spooled files loaded in the old format, Version 1, which is not recommended - it is not supported for spooled files loaded in version 2, which is better, default alternative to load spooled files in.

 

Better alternative

As an alternative you should implement a repeat loop, that iterates across detail lines with a condition inside. Here is an example, which only prints out non-blank lines:

 

NG2SpoolMapCond0010

It is recommended to use the ng:spoolMapRel function within conditions instead for Version 2 spooled file.

 

 

With this function you can conditionally map data from an input spooled file in the designer.

 

An alternative to the ng:spoolMapCond is the ng:spoolMap function, that select spooled file line(s) without any built in condition.

 

The easiest way to use the ng:spoolMapCond function is to first load a spooled file, insert the ng:spoolMap function via the magnifying glass e.g. in the text element and then change the function call accordingly as described below.

 

Here is an example of the function:

 

ng:spoolMapCond(./text(), 2, 2, 10, 24, '=', 'P', 59, 67, false(),1)

This selects the spooled file data from current page of the input spooled file. It takes the information from position 2 to 2 of the lines from 10 to 24. If position 2 is equal to P, then the spooled file data in positions 59 to 67 are mapped/extracted. false() is an optional parameter, that indicates that blank spooled file lines (where the condition is not true) should not be ignored. The last parameter is also optional and if this is left out, then all spooled file lines will be mapped, if the condition is true for the relevant line. If you state 1, then only the first spooled file line (where the condition is true) will be mapped.

 

The parameters of the function, ng:spoolMapCond are in this sequence:

ng:spoolMapCond(<Page>, <strPosCnd.>, <EndPosCnd.>, <StrLinCnd>,<EndLinCnd>, <Cond>, <CmpVal>,<StrPos>,<EndPos>,<IgnBlank>,<MaxLines>)

 

<Page>

A reference to the page, that you want to map.

The first parameter is a bit special. For that you have two options:

1.You can refer to a specific page number. You should e.g. do that, if you e.g. to insert a condition to compare spooled file data in a specific page, positions and line. For that you select the page number like above: //page[<nbr>], where <nbr> is the page number, that you want to select.

2.You can also refer to the current page. This usage is normally only used in the designer, where you repeat the page element for all pages in the input spooled file as shown in these sections: Map spooled file data from current page and Reproduce input spooled file as output. In these examples you should map the spooled file data with Auto set as the page number in the upper right corner. If you want to type in a reference to the current number, then the page reference in the ng:spoolMap function should be ./text(), so the function: ng:spoolMap(./text(), 2, 27, 6, 11) maps position 2 to 27 of lines 6 to 11 of the current page.

 

<StrPosCnd>

The start position number for the condition.

 

<StrPosCnd>

The end position number for the condition.

 

<StrLinCnd>

The start spooled file line to search for a true condition.

 

<EndLinCnd>

The end spooled file line to search for a true condition.

 

<Cond>

The operator for the comparison. Possible conditions are:

=, !=, <, >, <=, >=, A, U. Each condition are described below:

Condition

Description

=

The condition is true, if the selected positions are equal to the <CmpVal> value.

!=

The condition is true, if the selected positions are not equal to the <CmpVal> value

<

The condition is true, if the selected positions are less than the <CmpVal> value.(*)

>

The condition is true, if the selected positions are greater than the <CmpVal> value.(*)

<=

The condition is true, if the selected positions are less or equal than the <CmpVal> value.(*)

>=

The condition is true, if the selected positions are greater or equal than the <CmpVal> value.(*)

A

The condition is true, if all characters are found in the string inside <CmpVal>.

U

The condition is true, if not all characters are found in the string inside <CmpVal>.

(*) The greater/less comparisons are all based on unicode string comparisons from the left to the right. The means e.g. that numeric comparisons only work for right aligned values.

 

<CmpVal>

The value to compare the selected positions with.

 

<StrPos>

The start position to remap of the current line, where the condition is true.

 

<EndPos>

The end position to remap of the line, where the condition is true.

 

<IgnBlank>

(Default false()). This is an optional boolean parameter: Ignore blank lines. If this is false(), then blank spooled file lines and lines where the condition is not true are not ignored (this is default). If it is true(), then the spooled file lines are ignored if they are either blank lines or if the condition is not true.

 

<MaxLines>

(Default is unlimited). This is an optional numeric parameter. Here you can limit how many lines, that should be mapped as maximum. If this is not filled out, then all spooled file lines are mapped (in the selected line interval), if the condition is true. If you limit this with a number, then you can e.g. with 1 limit the remap/extraction to the first spooled file line in the selected interval, where this condition is true.

 

 

 

Examples

 

Example1

The first parameter of the ng:spoolMapCond can either select data from the current page (but that require that the function is used within a repeat, that iterates across pages in the input spooled file or it can refer to a specific page number. Here is an example of both:

 

NG2SpoolMapCond0006

So in the first function the data from page 1 is used and in the bottom there is a reference to the current page.

 

 

Example2

If you consider this text in a spooled file:

 

NG2SpoolMapCond0001

This shows spooled file data in line 10 to 24, positions 80 to 88.

 

You can with this XPath function output the lines, that contains a value larger than 10.000 in this way:

 

ng:spoolMapCond(./text(), 80, 85, 10, 24, '<', '10.000', 80, 88)

 

The result of this conditioned spooled file mapper is this:

 

NG2SpoolMapCond0002