 # array

Hi,

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.

steve

Assume that file structre is as shown below
01 #W-FIXED (A500)
01 REDEFINE #W-FIXED
02 #W-WORK-COUNT (N3)

and Code will looke like

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…

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

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

Leon;

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