Handling multi-line conditioned sections

Handling multi-line conditioned sections

This section address the situations, where you have conditioned blocks of multiple lines in the input spooled file, that you want to map as blocks. A prerequisite is, that you have loaded a spooled file in the Library and then loaded the sample spooled file in the designer.

 

This is e.g. required in these situations:

 

The spooled file may contain variable data for multiple labels on a page where e.g. line 1 to 4 are the lines for label 1 and lines 5 to 8 are the lines for label 2 etc.

 

A block can also be a section of spooled files lines, that belong together as a detail line section, where the first line might contain part number, short description, price per unit, discount, quantity and line total and the second line may contain other formatted data like e.g. the dimensions and the weight of the object etc. and you want to freely move these elements around within an output block.

 

The description below only covers scenarios for which the block is a single line or a fixed number of lines. If you want to handle a block of a dynamic number of spooled file lines, then you can e.g. consider to use a variable to 'remember' that a block is currently processed and test the value of the variable early in the select element branches.

 

Let us consider a spooled file like this:

 

NG2MultiLineSplf001

 

We want to scan the spooled file for addresses and each time an address is found we want to insert a frame and map the address into this frame like below:

 

NG2MultiLineSplf003

 

For this these solutions can be considered:

 

Solution 1: Trigger on "Adr.:"

Solution 2: First non-blank line is triggered and reserves 6 spooled file lines

 

 

Solution 1: Trigger on "Adr.:"

One simple solution is to scan the spooled file for 'Adr.:' and insert a conditioned section where the 6 spooled file lines are mapped. This can be done with this template:

 

 

NG2MultiLineSplf002

 

Here is an explanation of each element:

 

The first repeat (//page) is for repeating through the pages of the input spooled file.

 

The first container (COND_MULTI) sets the start position for the line repeat. Any addresses found are placed below this.

 

The second repeat (subsequence(./line,1,42)) repeats through the spooled file lines 1 to 42.

 

The When branch of the select verifies if the current spooled file line contains 'Adr.:' in position 1 to 5. If so the following container is inserted in a dynamic position. The height of this container reflect the height of a single spooled file line in the output.

 

Inside the main container a container with a fixed position inserts the box and the two ng:spoolMapRel() functions maps first the address and then the "Adr.:" text in the input spooled file.

 

In the other wise branch another container is inserted with a dynamic position. The height of this container also match the height reserved for a single spooled file line.

 

 

Solution 2: First non-blank line is triggered and reserves 6 spooled file lines

In this scenario we ignore the fact, that for this spooled file there is a unique trigger, which identifies the start of a new address. Instead we could also search of a non-blank text and then handle 6 spooled file lines and ensure, that these 6 lines are skipped in the spooled file line repeat. Still we want the same output as in solution 1 above:

 

This can be done with this template:

 

NG2MultiLineSplf004

If you compare with the solution 1, then you see these differences:

 

1.A variable, block is introduced to keep track of which spooled file lines, that handled in the same conditioned block. The initial value is set to 0, so that a conditioned section can be triggered.

2.The condition for the elements, which here includes the frame and the two remaps is changed so here we verify the contents of 7 characters starting in position 8 of the current spooled file line  - and combine this with a condition for the block variable. If the block variable is 1 or higher, then the spooled file line has already been handled by a previous conditioned section. We use the ng:trim() function and compare with an empty string to ensure that this is only true if spooled file text is found, that is not blank (and it is not a totally empty line for which these positions would be an empty string.

3.If a conditioned section handles 6 lines like in this example the block variable is set to 6 when the conditioned section is processed.

4.In the bottom of the line repeat the value of the block variable is reduced with 1 to open up for another conditioned section to be called, when we have passed the processed spooled file lines.

    • Related Articles

    • Options for handling detail lines

      When it comes to detail lines of a document, then you of course need to use a repeat loop, that iterates across all of the detail lines of your input file. Here I use this XML file as input: (You can find that in the document Library of InterFormNG2 ...
    • Splf extractor: Conditioned mappings

      Both the line and block element can be conditioned in the spooled file extractor. To condition an element you should first select the area in the spooled file view and create a simple mapping. Now you need to enable triggers on the right in order to ...
    • Spooled file multi-Up

      It is possible in InterFormNG2 to convert multiple input spooled file pages into a single output page. This is often referred to as either Multi-Up or pages per side. A classic example of multi-up is this kind of output, where we have chosen to put 4 ...
    • Line element

      If you want to insert a line in a template, then you need to click the line element icon: After you have clicked the line element, the pointer icon changes to a cross hair icon indicating, that InterFormNG2 now expects you to start and end position ...
    • New log line component

      The job logs of InterFormNG2 includes all requests, but it can be a bit difficult to identify a specific document, so to make that possible you can assign a value to the Log info meta data key. This makes is much easier to search for a specific job ...