Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to MOVE A TO B with specs 1

Status
Not open for further replies.

RCPD700

MIS
Jun 20, 2001
75
0
0
US
Excuse the subject as I was trying to be brief w/o being too cryptic.

I would like to find a way to move field A to field B specifying the offset into field B for the length of A.

The application needs to construct a signature line where the person's name concatenated with a known job title in field A needs to be moved so it fills the rightmost portion of field B.

Something like:
MOVE FIELD-A TO FIELD-B (offset into FIELD-B:length-of-FIELD-A)

Any ideas?
I'm using Micro Focus Server Express COBOL if it makes any difference.

Thanks

 
Look in your reference manual for "reference modification". The syntax is almost identical to what you have coded.

Tom Morrison
Micro Focus
 
I assume when you want to use the length of field A you actually mean how many characters of field A are being used - not the length as defined in the PIC clause.

You need to set up a loop to calculate the number of characters being used in field A. You could start at pos 1 of field A and add 1 to a counter as long as Field A from that position to the end is not equal to all spaces.
WHILE FIELD-A(pos:) NOT = SPACES
ADD 1 to counter
ADD 1 to pos
END-WHILE

Now that you know how many characters long field A is, you can subtract that from LENGTH OF field B to see what column to start moving into field B.

If field B is defined as 20 bytes long and you have determined that field A uses 6 bytes, you want to begin moving Field A to Field B starting at position 15 of field B (so you fill that rightmost 6 bytes of field B).

MOVE SPACES TO FIELD-B. Get rid of any old data in first 14 bytes
MOVE FIELD-A TO FIELD-B(calculated-first-byte:).
you don't need a length value on the reference modification because you are filling all of the remaining characters of FIELD-B.

Another way would be to define FIELD-B with the JUSTIFIED clause so when you do a move into that field it will be right justified rather than left justified. Now after you have calculated the length of FIELD-A use:

MOVE FIELD-A(1:length of FIELD-A) TO FIELD-B.
You don't need the initial move spaces as previously because when you move a shorter field to a longer, spaces are padded in unused characters.
 
Thank you very much coboldeke, I really appreciate the assistance. You were correct, by length of field A, I intended the positions being used, not the PIC length.

Using JUSTIFIED on the receiving field occurred to me, but I immediately dumped that idea since it is being used for just about every line of the output which is a legal document. The original author (back in 1990) used the approach of stringing text together using a subroutine for that purpose. It appends text to the line and avoids splitting words. It also keeps track of how much of the line is filled.

I came up with a solution at the last minute Friday...
I knew how much space was in the line (field B), and was able to determine the length of text in field A) as you did above, so I then computed the amount of offset needed to right justify the line then called the stringing routine giving it the required info. This seemed the best approach under the circumstances, since I could find what I was looking for in the documentation online. I think I'll go back and implement your suggestion since it was really my preferred method.

k5tm Thanks for the input. Unfortunately we have no manuals these days and I couldn't think of "reference modification" because of time pressures. Being an old timer (today begins week 2 in year 44 of this fun) I much prefer real manuals... you can't keep track of several places in a web "manual" by sticking your fingers between pages. Reference materials on the web are great, but give me a hardcopy manual, please!

Thanks for the responses, and especially for a solution.




 
RCPD700,

Our manuals are always available at:

Yes, I also bemoan the loss of 'real' manuals, fought the battle several years ago at Liant, and lost. The stark reality is that no one wants to pay the extra cost for a 'real manual' these days. And, since I am a developer, the lead time for getting manuals printed is enormous in today's compressed development schedules. Keeping the docs aligned with the actual product was a nightmare when we were actually printing books.

Finally, there are products, both free and at some cost, to add bookmarks to PDF documents. Not sure it is worth the time, though, since you probably only want the marks for one session.

Tom Morrison
Micro Focus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top