I have this file coming in as array (A250/8000) these are composed of blocks of data that contains different information… ex. the block (1 to 500) are the basic information (this is fix it will always included). the next block is the address (100 chars). the address can be more than one occurence (max of 999). Then the work places (100 chars) which is also multiple occurence (max of 999). Now, my dilemma is that I am not sure how many occurence are coming. There is one field that will act as indicator (say add-count = 3, work-count = 10) so it means that for the address block there are 3 address information and so there will be 300 additional characters. My job is to determine where the address info starts and ends so the work info… Any advice how this can be done?

There must be more to this problem than stated in your posting.

Assuming that add-count=3 and work-count=10; and assuming that these two counters are located in the basic-information area, at a fixed point; then positions 501-600 is the first address, 601-700 is the second address and 701-800 is the third address. The first work is 801-900, etc.

If this is not correct, you have omitted information from your posting that describes the actual nature of the problem.


Assume that file structre is as shown below
01 #W-FIXED (A500)
02 #W-ADD-COUNT (N3)
01 #W-ADDES-work (A100/1:1998)

and Code will looke like

Move #W-ADDES-work(1:#W-ADD-COUNT ) to array for address
Compute #i = #w-add-count + 1
move #w-addes-work(#I:#W-WORK-COUNT ) to array for work place

hi Steve,

You are right there is more to my problem… One, the counts are not located in the basic/fix information (from A500). two, if the count is 0 the block will not be pass… three, to add more complications there are probably 10 block more information that will be pass…

basic info (A500) - this is fix.
add-count (a3) - if not zero, say 3
add-bloc 1 (a38)
add-bloc 2 (a38)
add bloc 3 (a38)
work-cnt (a3) - if Zero, bloc will not be pass
name-cnt (a3) - if not zero
name-bloc 1 (a50)
name-bloc 2 (a50)

Also the challenge is this… the whole file will be pass as (A250/8000).

Thanks for your assistance…


This is still, as you described it, a programming 101 exercise.

Have you never used SUBSTRING? If not, look it up in Natural documentation. It will make this “problem” simple.

Are you using Natural 4.1 or 4.2? If so redefine your array as A2000000. This will make the coding simple since you will be doing SUBSTRING to a single variable.

If you are not on Natural 4 yet, you will have to deal with subscripts. Not terrible, but definitely messier to code.

If you are on V4, code something like:

move val (add-count) to #num /* assuming not zero)
compute #length = #num * width of an address (38 in you example)
move substring (#string,504,#length) to #workspace

In your example #workspace will have the three addresses.

continue to strip the string in this manner. Of course, the 504 in the substring move will not be hardcoded, you will have to have a variable such as #pos which tells you where you are up to.

If you are on V4.2 you could employ Xtensible arrays to move the substring to. However, with a max of 999 occurrences, if you have a max length of 100 for a “bucket”, you could simply have a single a100000 variable. Xtensible arrays would be fun though.


You can also use an “(A) DYNAMIC” field (NAT 4.1+) and follow the hints of Steve.