Re: Set a file variable to another



Frederico Fonseca wrote:
On Mon, 23 Oct 2006 09:14:40 -0500, "HeyBub" <heybubNOSPAM@xxxxxxxxx>
wrote:

Apokrif wrote:
Hi,

in C you can say:
FILE *current, *g;
current=g;

Or in Pascal:

var current,g:^text;
begin
f=g;
end;

This is, for instance, if you want to read several input files
(g,h...) but only perform the fgets or readln operations
on a single "current" file variable (for some reason, calls to fgets
or readln are in a part of the source code you cannot change, or
don't want to change so that you have a generic reading operation).
I'd like to know how to do it in Cobol: would

fd foo.
fd bar.
and then:
move foo too bar

be correct ?


"too" is a C command?

A COBOL program can use the same procedure to read multiple physical
files. Typically:

SELECT Input-File assign to DATA-NAME (this construct varies by
compiler)


MOVE "INPUT-A" to DATA-NAME
PERFORM Read-Input
MOVE "INPUT-B" to DATA-NAME
PERFORM Read-Input
etc.


Read-Input
OPEN Input Input-File
Read Input-File
PERFORM UNTIL Input-FS not = '00'
(process input record)
READ Input-file
END-PERFORM
CLOSE Input-File.

this only works if the files have the same structure.
e.g. if they are indexed they MUST have the same record size, and
exactly the same keys on the same order and same definition.


Well, sure. Since the OP wanted to read "several input files," I presumed
the input files were physically identical.

Then, again, his motive may have been to brag about the wonderfullness of C.


.



Relevant Pages