Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think your second attempt was nearly correct. As Paxdiablo pointed out in his answer, the problem you have is overwriting data.</p> <p>If I understand your problem correctly, you read in a single record containing a complete address (Name, Address, City-State-Zip) and have to print out two copies of it side by side.</p> <p>Notice that for every line you read, you need to print 3. Also notice that you only have one output record buffer. This means you can only process one output line at a time. The solution is to move each address component into the left and right hand side of the ouput line, output the line and then move on to the next address component. Since there are 3 address components, you end up printing 3 lines for each one read.</p> <p>Try modifying paragraph 200-PROCESS-ONE-RECORD as follows </p> <pre><code>200-PROCESS-ONE-RECORD. MOVE NAME-IN TO LEFT-LABEL-OUT MOVE SPACES TO BLANK-OUT MOVE NAME-IN TO RIGHT-LABEL-OUT MOVE SPACES TO BLANK-A-OUT WRITE LABEL-RECORD-OUT MOVE ADDRESS-IN TO LEFT-LABEL-OUT MOVE SPACES TO BLANK-OUT MOVE ADDRESS-IN TO RIGHT-LABEL-OUT MOVE SPACES TO BLANK-A-OUT WRITE LABEL-RECORD-OUT MOVE CITY-STATE-ZIP-IN TO LEFT-LABEL-OUT MOVE SPACES TO BLANK-OUT MOVE CITY-STATE-ZIP-IN TO RIGHT-LABEL-OUT MOVE SPACES TO BLANK-A-OUT WRITE LABEL-RECORD-OUT </code></pre> <p>This takes one input line, produces 3 output lines. You might want to output a fourth blank line to separate addresses (as illustrated in your sample output - I will let you figure out how to get that done).</p> <p>I think Paxdiablo's solution solved a slightly different problem where you would be printing one copy of each address but printing addresses 2 across.</p> <p>BTW... Despite the number of disparaging "drive by" comments your question got, COBOL is still actively used in some segments of this industry.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload