Focal Point
copy a row?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1461068331

June 03, 2005, 02:08 PM
dhofman
copy a row?
I am a novice when it comes to FOCUS coding and hoping someone can help me. I am looking for the easiest way to copy a row into two rows from a hold file. Let me explain. If I have a row that meets certain criteria coming in from a hold file (in this case a code equals 'BIPD') I need to take that row and split it into two rows. The code that equals 'BIPD' will remain the same, however another code within that row will be updated/changed on the new row. I know I can do this with doing multiple hold files, however there has got to be a command to do this in one step. Any advice or help would be greatly appreciated. Thanks.
June 04, 2005, 04:59 AM
susannah
well, by your having said you're a novice, we're limited in what we can answer you with. Us grizzled old-timers would MacGyver it, but thats not a technique for your freshman year.
you can write out 2 holds files and read them together a couple of different ways, either by using the MORE command or by using dialogue manager to -READ a flat file record by record and -WRITE it to some output file, doubling the write when your input record meets your criteria.
What i might suggest you do, if that multiple file thing doesn't appeal to you, is make a little tiny output file of just the valid criteria, doubled, then JOIN this file to your source file, effectively doubling the number of valid records in your resultant entity.
I think the multiple file thing is easier for you.
TABLE FILE CAR
PRINT *
ON TABLE HOLD AS H2
END
TABLE FILE CAR
PRINT * IF COUNTRY IS 'ENGLAND'
ON TABLE HOLD AS H1
END
TABLE FILE H2
PRINT *
ON TABLE HOLD AS H3
MORE
FILE H1
END
TABLE FILE H3 PRINT *
END
and you got yourself 2 Englands.
June 04, 2005, 02:30 PM
HÃ¥kan
If the file is not too big I think I would go for the -READ and multiple -WRITE option. Something like this:

-:read
-READ INFILE &CODE.A4. &REST.A256.
-IF &IORETURN NE 0 GOTO :end_read;
-WRITE &CODE&REST
-IF &CODE NE 'BIPD' GOTO :read;
-WRITE &CODE&REST
-GOTO :read
-:end_read