Re: Simple Fup question



mustlearntandem wrote:
> Man would someone with 10 minutes to spare write this poor guy 10
lines of TAL or COBOL and do this for him? I would but I'm thoroughly
in the middle of something right now.

It has taken a lot more than 10 minutes, but I took up your challenge. Below is both a TAL and COBOL form for the program.

I must give the warning that I cannot test either program because I don't have access to a Tandem system at the moment, so
if Jim wants to try using either, he may have to do a little testing/debugging. They might even have a few compilation
errors.

If you use one of these programs, I suggest first running a modified version that copies just a few records and examining the output file carefully to be sure it seems to be doing the copy correctly. It might even be good to try a test run with a few thousand records and time it to get an estimate of how long it will take to copy the whole data file. (If you don't know the number of records in your data file, you can determine the number of records in a file using FUP INFO filename,STAT.)

Here are the sources for the programs -- first the TAL, then the COBOL -- take the text between the lines of hyphens:

-------------------------------------------------------------------------------------------------------
?symbols,inspect

! Program to copy file, with record length 821 and key being the last 33 bytes,
! inserting 34 blanks before the key.
! ! If this program file is named scopy, compile it with the command:
!
! TAL/IN SCOPY/COPY
!
! Run it with the command: !
! RUN COPY/IN input, OUT output/
!
! It drops into debug on any errors.

int err;
int .startup[0:500];

int out,in;
int .recin[0:822/2];
int .recout[0:856/2];
string .srecin := @recin'<<'1;
string .srecout := @recout'<<'1;
string .key[0:32] := [33*[0]];
string .blanks[0:33] := [34*[" "]];

?nolist, source $system.system.extdecs(initializer,open,debug,close,stop,read,write,fileinfo,keyposition)
?list


proc startupproc(rucb,passthru,msg,msglen,match) variable;
int .rucb,.passthru,.msg,msglen,match;
begin
int movelen;
movelen := $MIN(1000,msglen);
startup ':=' msg for movelen bytes;
end;

proc m main;
begin

call initializer(,,startupproc);
call open(startup[9],in,%2000);
if <> then call debug;
call open(startup[21],out);
if <> then call debug;
call keyposition(in,key);
if <> then call debug;

while 1 do
begin
call read(in,recin,833);
if <> then begin
call fileinfo(in,err);
if err = 1 then goto done;
call debug;
end;
srecout ':=' srecin for 788;
srecout[788] ':=' blanks for 34;
srecout[822] ':=' srecin[789] for 33;
call write(out,recout);
if <> then call debug;
end;

done:
call close(in);
call close(out);
call stop;

end;
------------------------------------------------------------------------------------------------------------------
?symbols,inspect

* Program to copy file, with record length 821 and key being the last 33 bytes,
* inserting 34 blanks before the key.
*
* Before compiling the program, change the filenames in the SELECT statements to reflect the
* actual file names you are copying from and to.
*
* I believe the START statement is not needed, because I believe the OPEN will default to position
* at the beginning of the file. If you have trouble with the START statement, try just removing it.
*
* It would improve performance to set the BUFFERED attribute of the output file before running this
* program using a command something like:
*
* FUP ALTER newfile,BUFFERED
*
* After the program has been run, you can turn off BUFFERED mode with a command something like:
*
* FUP ALTER newfile,NOBUFFERED
* * If this program file is named scopy, compile it with the command:
*
* COBOL85/IN SCOPY/COPY
* or
* NMCOBOL/IN SCOPY/COPY;RUNNABLE
*
* Run it with the command: *
* RUN COPY
*

identification division.
program-id. COPY.

environment division.
configuration section.
object-computer. tandem/16.
input-output section.
file-control.
select in-file assign oldfile
organization is indexed
access mode is sequential
record key is part-2.
select out-file assign newfile
organization is indexed
access mode is sequential
record key is part-2.

data division.
file section.

fd in-file.
01 in-rec.
02 part-1 pic x(788).
02 part-2 pic x(33).

fd out-file.
01 out-rec.
02 part-1 pic x(788).
02 part-new pic x(34).
02 part-2 pic x(33).

working-storage section.
01 end-flag pic x value "N".
01 record-count pic 9(12) value 0.

procedure division.
p1-main.
open input in-file.
move low-values to part-2 of in-rec.
start in-file key >= part-2 of in-rec.
open output out-file.
perform p2-copy until end-flag = "Y".
close in-file.
close out-file.
display record-count " records copied".
stop run.

p2-copy.
read in-file at end move "Y" to end-flag.
if end-flag = "N"
add 1 to record-count.
move part-1 of in-rec to part-1 of out-rec
move spaces to part-new of out-rec
move part-2 of in-rec to part-2 of out-rec
write out-rec.
--------------------------------------------------------------------------------------------------------
.


Loading