For Programmers: Free Programming Magazines  


Home > Archive > Cobol > May 2004 > Realia Cobol help please









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Realia Cobol help please
Joe Magiera

2004-05-14, 6:30 pm

I'm running a very old version of Realia Cobol, 4.201.

Is there any way to concatenate multiple files to an input file? I
tried the way I thought made sense to me, which looked like something
like this:

SELECT INPUT-FILE ASSIGN 'C:\INPUT\DATA1.TXT' 'C:\INPUT\DATA2.TXT'.

It didn't give me a compile error, but did not read the second file
either.

If this is possible on this version of PC Cobol, I would really
appreciate it if someone could explain to me how to do it. Thanks,

Joe
joemagiera@ameritech.net
Robert Wagner

2004-05-14, 9:30 pm

joemagiera@ameritech.net (Joe Magiera) wrote:

>I'm running a very old version of Realia Cobol, 4.201.
>
>Is there any way to concatenate multiple files to an input file? I
>tried the way I thought made sense to me, which looked like something
>like this:
>
>SELECT INPUT-FILE ASSIGN 'C:\INPUT\DATA1.TXT' 'C:\INPUT\DATA2.TXT'.
>
>It didn't give me a compile error, but did not read the second file
>either.
>
>If this is possible on this version of PC Cobol, I would really
>appreciate it if someone could explain to me how to do it. Thanks,


Create a .bat file reading:
copy c:\input\data*.txt c:\input\data\xxx.txt
yourprogramname (which reads xxx.txt)
Donald Tees

2004-05-14, 10:30 pm

Joe Magiera wrote:
> I'm running a very old version of Realia Cobol, 4.201.
>
> Is there any way to concatenate multiple files to an input file? I
> tried the way I thought made sense to me, which looked like something
> like this:
>
> SELECT INPUT-FILE ASSIGN 'C:\INPUT\DATA1.TXT' 'C:\INPUT\DATA2.TXT'.
>
> It didn't give me a compile error, but did not read the second file
> either.
>
> If this is possible on this version of PC Cobol, I would really
> appreciate it if someone could explain to me how to do it. Thanks,
>
> Joe
> joemagiera@ameritech.net


Try:

SELECT INPUT-FILE ASSIGN 'C:\INPUT\DATA1.TXT'.
SELECT INPUT-FILE2 ASSIGN TO 'C:\INPUT\DATA2.TXT'.

That will let you open them both at once. Or, if you want to use the
same file despcription to read one file, then the second, you can do
something like:

Select Input-File, Assign to My-file-name.

Where My-file-name is defined in working storage. Then in your procedure
division.(sic) move "C:\INPUT\DATA1.TXT" to My-file-name, open
Input-file, perform your-read-section until the-end-of-file, close
input-file, move C:\INPUT\DATA2.TXT" to My-file-name. Repeat that for
the second file.

Donald


James J. Gavan

2004-05-15, 12:30 am

Joe Magiera wrote:

>I'm running a very old version of Realia Cobol, 4.201.
>
>Is there any way to concatenate multiple files to an input file? I
>tried the way I thought made sense to me, which looked like something
>like this:
>
>SELECT INPUT-FILE ASSIGN 'C:\INPUT\DATA1.TXT' 'C:\INPUT\DATA2.TXT'.
>
>It didn't give me a compile error, but did not read the second file
>either.
>
>If this is possible on this version of PC Cobol, I would really
>appreciate it if someone could explain to me how to do it. Thanks,
>
>Joe
>joemagiera@ameritech.net
>
>

You used the magic word "concatenate". It just isn't possible with File
Definitions :-

FILE-CONTROL.

Select Data-File
assign Data-filename (or hard code filename)
organization indexed/relative/sequential/line sequential
access dynamic (etc...)
(record key Data-PrimeKey
(Relative key ws-RelativeKey
file status ws-FileStatus.

You are establishing a pointer/reference to a specific file.

Same sort of logic applies when using SQL and DBs - you have to give an
'external' name, (the DB name
- which you can consider as a 'folder' with a series of files
(tables)), and you use the SQL 'CONNECT'
which parallels the COBOL file 'ASSIGN'.

Believe me, even OO COBOL isn't that clever :-) Using syntax in the
FILE-CONTROL block above,
and given I have ONE class that handles ISAMs, from which I can create
an 'Instance' for each file,
(call it a 'carbon copy'), I still can't get away with concatenation.
Just like you I have to individually pass
external filenames and record sizes - concatenation is just not an option.

The only way it would work for you, as Donald suggested, was if you were
processing
your files separately and when #1 is finished and CLOSEd, you then pass
the external
filename for File # 2

Jimmy, Calgary, AB

Richard

2004-05-15, 12:30 am

joemagiera@ameritech.net (Joe Magiera) wrote

> Is there any way to concatenate multiple files to an input file? I
> tried the way I thought made sense to me, which looked like something
> like this:
>
> SELECT INPUT-FILE ASSIGN 'C:\INPUT\DATA1.TXT' 'C:\INPUT\DATA2.TXT'.


You need to have

SELECT INPUT-FILE ASSIGN input-filename.
...
WORKING-STORAGE SECTION.
01 input-filename PIC X(80).
...

MOVE "C:\INPUT\DATA1.TXT" TO input-filename
PERFORM Process-File
MOVE "C:\INPUT\DATA2.TXT" TO input-filename
PERFORM Process-File
...

Where Process-File will do an OPEN (check status) READ until end and CLOSE.
JerryMouse

2004-05-15, 8:30 am

Joe Magiera wrote:
> I'm running a very old version of Realia Cobol, 4.201.
>
> Is there any way to concatenate multiple files to an input file? I
> tried the way I thought made sense to me, which looked like something
> like this:
>
> SELECT INPUT-FILE ASSIGN 'C:\INPUT\DATA1.TXT' 'C:\INPUT\DATA2.TXT'.
>
> It didn't give me a compile error, but did not read the second file
> either.
>
> If this is possible on this version of PC Cobol, I would really
> appreciate it if someone could explain to me how to do it. Thanks,


If you're asking whether your compiler is smart enough to handle successive
input files without either affirmative coding or human intervention, the
answer is "No."

But that's okay, no other compiler can do it either. This is something
compilers just don't do.

Seemingly, you have two choices:
1. Concatenate the two files into one before exercising your program, or
2. Handle the file switch from within your program.


Robert Wagner

2004-05-15, 2:30 pm

joemagiera@ameritech.net (Joe Magiera) wrote:

>I'm running a very old version of Realia Cobol, 4.201.
>
>Is there any way to concatenate multiple files to an input file? I
>tried the way I thought made sense to me, which looked like something
>like this:
>
>SELECT INPUT-FILE ASSIGN 'C:\INPUT\DATA1.TXT' 'C:\INPUT\DATA2.TXT'.


Read them using the Microsoft ODBC driver for flat files. OPEN CURSOR will refer
to a SELECT, where you can use JOIN to concatenate two 'tables'.
Warren Simmons

2004-05-15, 5:30 pm

JerryMouse wrote:
> Joe Magiera wrote:
>
>
>
> If you're asking whether your compiler is smart enough to handle successive
> input files without either affirmative coding or human intervention, the
> answer is "No."
>
> But that's okay, no other compiler can do it either. This is something
> compilers just don't do.
>
> Seemingly, you have two choices:
> 1. Concatenate the two files into one before exercising your program, or
> 2. Handle the file switch from within your program.
>
>

I'd try to sort each file, and then use them as input
doing a merge as you go.

Warren Simmons
JerryMouse

2004-05-16, 10:30 am

Warren Simmons wrote:
> I'd try to sort each file, and then use them as input
> doing a merge as you go.
>
> Warren Simmons


Ooo! Good idea. Especially if you sort on input record number and have a
pretty smart sort that instantly decides there's nothing to do.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com