Data page length

I have a text data source. Is there a way in the datamapper to determine the length (number of lines) in a data page? In this sample

the page has 90 lines and I need to get that value.
(I need to find something starting at the end of page and searching backwards.)

I couldn’t find a variable with that information BUT to achieve what you want, simply start with a Repeat statement with a type of Until no more elements, added with a Goto that moves down by 1 line, which position you at the end of the page.

Then another Repeat which type would match you requirement as far as condition, added with a Goto that moves -1 line.

A more efficient alternative would be:

  • GOTO next page

  • Store (steps.currentPosition-1) in a sourceRecord property created previously, for instance:

    sourceRecord.properties.lineCount = steps.currentPosition-1;

  • GOTO previous page

Your sourceRecord property will now contain the number of lines for the current page.

1 Like

Thanks Phil and Hamelj
I found that I really needed the record length, rather than the page length. I used Phil’s method, but looped over all pages.

Never would I thought of that…again learning am I…my master!!! :wink:

yoda

Is this correct for the line count on a page?

Steps

Next_Page

Extract

Back_Page

Or would it be better to use an action instead?
StepsAction

Action

Both are valid.

However, the second method does not extract the line count value to a field stored in the datamodel, it simply stores it in a sourceRecord variable, which means you’ll have to add an extra Extraction step to store that line count value in a field if you need it stored in the database.

The first method both assigns the line count value to a sourceRecord property and extracts it to the database in one fell swoop, so it’s slightly more efficient.

Also note that if your record has multiple pages and you want to count the total number of lines in the record (i.e. across all pages), as stuart did, then your first Goto step should point to some impossibly large value (1000 pages in the following example):
GOTO-Bottom
And then, the second Goto should simply point to the top of the record instead of moving back a single page:
GOTO-Top