Home > Archive > Cobol > July 2004 > MicroFocus & Win XP file problems
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 |
MicroFocus & Win XP file problems
|
|
| Michael Russell 2004-07-22, 3:55 pm |
| I'm using Net Express 3.01.14 - University edition & running Win XP Pro,
SP1.
A simple MF program to read a rather large (1.1gb) text (line seq) file & do
some simple cutting out of records seems to lose records from the output.
Well, it actually does lose them - unintentionally, of course :-)
The program is reproduced below. It never executes section 'check-status' -
there's a 'break' on that section's 1st line.
It's quite a pain trying to use a text editor on the file - Textpad & Edit
Plus both fail to load it because it's so big; Ultra Edit 32 loads it but
any editing is excrutiatingly sloooooow. Maybe there's a simple line-editor
out there?
Any thoughts?
Michael
id division.
program-id. Trimmer2.
environment division.
select lineseq-in
assign to ws-in-file
file status is ws-file-status
organization is line sequential.
select lineseq-out
assign to ws-out-file
file status is ws-file-status
organization is line sequential.
data division.
file section.
fd lineseq-in
record contains 200 characters.
01 lineseq-in-rec pic x(200).
fd lineseq-out
record contains 200 characters.
01 lineseq-out-rec pic x(200).
working-storage section.
01 ws-in-file pic x(45) value
'f:\Small-jun01-jul06.sql'.
01 ws-out-file pic x(45) value
'f:\Jun20.sql'.
01 ws-file-status.
05 status-key-1 pic x.
05 status-key-2 pic x.
05 binary-status redefines status-key-2 pic 99 comp-x.
01 ws-recs-in pic 9(9).
01 ws-recs-out pic 9(9).
01 ws-recs-includeed pic 9(9).
01 ws-start-include pic 9(9).
01 ws-end-include pic 9(9).
01 ws-recs-to-include pic 9(9).
01 ws-yorn pic x.
procedure division.
a-control section.
move 0 to ws-recs-in, ws-recs-out, ws-recs-includeed
ws-start-include, ws-end-include
perform until exit
display 'Start include:'
accept ws-start-include
display 'End include (inclusive):'
accept ws-end-include
if ws-start-include > 0 and
ws-start-include < ws-end-include
compute ws-recs-to-include =
ws-end-include - ws-start-include + 1
display 'include ', ws-recs-to-include, '?'
accept ws-yorn
if ws-yorn <> 'Y' and
ws-yorn <> 'y'
stop run
end-if
exit perform
else
display 'Range error!'
end-if
end-perform
perform z-opens.
if status-key-1 <> '0'
perform check-status
stop run
end-if.
perform b-copy.
close lineseq-in, lineseq-out
stop run.
b-copy section.
perform until exit
read lineseq-in
at end
exit perform
end-read
if status-key-1 <> '0'
perform check-status
stop run
end-if
add 1 to ws-recs-in
if ws-recs-in = ws-start-include
move '-- start include at'
to lineseq-out-rec
move ws-start-include to lineseq-out-rec(21:10)
move 'until (inclusive):' to lineseq-out-rec(32:50)
move ws-end-include to lineseq-out-rec(51:10)
write lineseq-out-rec
if status-key-1 <> '0'
perform check-status
stop run
end-if
exit perform cycle
end-if
if ws-recs-in < ws-start-include
exit perform cycle
end-if
if ws-recs-in > ws-end-include
exit perform
end-if
if ws-recs-in = (ws-end-include + 1)
move '-- end include at'
to lineseq-out-rec
move ws-end-include to lineseq-out-rec(21:10)
write lineseq-out-rec
if status-key-1 <> '0'
perform check-status
stop run
end-if
exit perform cycle
end-if
write lineseq-out-rec from lineseq-in-rec
if status-key-1 <> '0'
perform check-status
stop run
end-if
add 1 to ws-recs-out
if ws-recs-in(5:5) = '00000'
display 'Read=' ws-recs-in
' Written=', ws-recs-out
end-if
end-perform.
z-opens section.
open input lineseq-in.
if status-key-1 <> '0'
perform check-status
stop run
end-if.
open output lineseq-out.
if status-key-1 <> '0'
perform check-status
stop run
end-if.
check-status section.
display 'oops at:' ws-recs-in, ', in'
display 'recs out:' ws-recs-out
evaluate status-key-1
when "0" next sentence
when "1" display "end of file reached"
perform check-eof-status
when "2" display "invalid key"
perform check-inv-key-status
when "3" display "permanent error"
perform check-perm-err-status
when "4" display "logic error"
when "9" display "run-time-system error"
perform check-mf-error-message
end-evaluate.
check-eof-status section.
if status-key-2 = "0"
display "no next logical record"
end-if.
check-inv-key-status section.
evaluate status-key-2
when "2" display "attempt to write dup key"
when "3" display "no record found"
end-evaluate.
check-perm-err-status section.
if status-key-2 = "5"
display "file not found"
end-if.
check-mf-error-message section.
evaluate binary-status
when 002 display "file not open"
when 007 display "disk space exhausted"
when 013 display "file not found"
when 024 display "disk error "
when 065 display "file locked "
when 068 display "record locked "
when 039 display "record inconsistent"
when 146 display "no current record "
when 180 display "file malformed "
when 208 display "network error "
when 213 display "too many locks "
when other display "not error status "
display binary-status
end-evaluate.
| |
| Warren Simmons 2004-07-22, 3:55 pm |
| Michael Russell wrote:
>I'm using Net Express 3.01.14 - University edition & running Win XP Pro,
>SP1.
>
>A simple MF program to read a rather large (1.1gb) text (line seq) file & do
>some simple cutting out of records seems to lose records from the output.
>Well, it actually does lose them - unintentionally, of course :-)
>
>The program is reproduced below. It never executes section 'check-status' -
>there's a 'break' on that section's 1st line.
>
>It's quite a pain trying to use a text editor on the file - Textpad & Edit
>Plus both fail to load it because it's so big; Ultra Edit 32 loads it but
>any editing is excrutiatingly sloooooow. Maybe there's a simple line-editor
>out there?
>
>Any thoughts?
>
>Michael
>
> id division.
> program-id. Trimmer2.
> environment division.
> select lineseq-in
> assign to ws-in-file
> file status is ws-file-status
> organization is line sequential.
> select lineseq-out
> assign to ws-out-file
> file status is ws-file-status
> organization is line sequential.
> data division.
> file section.
> fd lineseq-in
> record contains 200 characters.
> 01 lineseq-in-rec pic x(200).
> fd lineseq-out
> record contains 200 characters.
> 01 lineseq-out-rec pic x(200).
> working-storage section.
> 01 ws-in-file pic x(45) value
> 'f:\Small-jun01-jul06.sql'.
> 01 ws-out-file pic x(45) value
> 'f:\Jun20.sql'.
> 01 ws-file-status.
> 05 status-key-1 pic x.
> 05 status-key-2 pic x.
> 05 binary-status redefines status-key-2 pic 99 comp-x.
> 01 ws-recs-in pic 9(9).
> 01 ws-recs-out pic 9(9).
> 01 ws-recs-includeed pic 9(9).
> 01 ws-start-include pic 9(9).
> 01 ws-end-include pic 9(9).
> 01 ws-recs-to-include pic 9(9).
> 01 ws-yorn pic x.
> procedure division.
> a-control section.
> move 0 to ws-recs-in, ws-recs-out, ws-recs-includeed
> ws-start-include, ws-end-include
> perform until exit
> display 'Start include:'
> accept ws-start-include
> display 'End include (inclusive):'
> accept ws-end-include
> if ws-start-include > 0 and
> ws-start-include < ws-end-include
> compute ws-recs-to-include =
> ws-end-include - ws-start-include + 1
> display 'include ', ws-recs-to-include, '?'
> accept ws-yorn
> if ws-yorn <> 'Y' and
> ws-yorn <> 'y'
> stop run
> end-if
> exit perform
> else
> display 'Range error!'
> end-if
> end-perform
> perform z-opens.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> perform b-copy.
> close lineseq-in, lineseq-out
> stop run.
> b-copy section.
> perform until exit
> read lineseq-in
> at end
> exit perform
> end-read
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> add 1 to ws-recs-in
> if ws-recs-in = ws-start-include
> move '-- start include at'
> to lineseq-out-rec
> move ws-start-include to lineseq-out-rec(21:10)
> move 'until (inclusive):' to lineseq-out-rec(32:50)
> move ws-end-include to lineseq-out-rec(51:10)
> write lineseq-out-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> exit perform cycle
> end-if
> if ws-recs-in < ws-start-include
> exit perform cycle
> end-if
> if ws-recs-in > ws-end-include
> exit perform
> end-if
> if ws-recs-in = (ws-end-include + 1)
> move '-- end include at'
> to lineseq-out-rec
> move ws-end-include to lineseq-out-rec(21:10)
> write lineseq-out-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> exit perform cycle
> end-if
> write lineseq-out-rec from lineseq-in-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
>
> add 1 to ws-recs-out
> if ws-recs-in(5:5) = '00000'
> display 'Read=' ws-recs-in
> ' Written=', ws-recs-out
> end-if
> end-perform.
> z-opens section.
> open input lineseq-in.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> open output lineseq-out.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
>
> check-status section.
> display 'oops at:' ws-recs-in, ', in'
> display 'recs out:' ws-recs-out
> evaluate status-key-1
> when "0" next sentence
> when "1" display "end of file reached"
> perform check-eof-status
> when "2" display "invalid key"
> perform check-inv-key-status
> when "3" display "permanent error"
> perform check-perm-err-status
> when "4" display "logic error"
> when "9" display "run-time-system error"
> perform check-mf-error-message
> end-evaluate.
>
> check-eof-status section.
> if status-key-2 = "0"
> display "no next logical record"
> end-if.
>
> check-inv-key-status section.
> evaluate status-key-2
> when "2" display "attempt to write dup key"
> when "3" display "no record found"
> end-evaluate.
>
> check-perm-err-status section.
> if status-key-2 = "5"
> display "file not found"
> end-if.
>
> check-mf-error-message section.
> evaluate binary-status
> when 002 display "file not open"
> when 007 display "disk space exhausted"
> when 013 display "file not found"
> when 024 display "disk error "
> when 065 display "file locked "
> when 068 display "record locked "
> when 039 display "record inconsistent"
> when 146 display "no current record "
> when 180 display "file malformed "
> when 208 display "network error "
> when 213 display "too many locks "
> when other display "not error status "
> display binary-status
> end-evaluate.
>
>
>
>
>
>
Michael,
I have not tried it my self, but a program called AutoIt might work.
At least it is a choice I may make to try something like that on a much
smaller file.
AFAIK, AutoIT is a script system with lots of options, and perhaps
extend able.
Warren Simmons
| |
| William M. Klein 2004-07-22, 3:55 pm |
| Using the SAME WS item as the file status field for two different files is often
dangerous. i.e where you have:
> select lineseq-in
> assign to ws-in-file
> file status is ws-file-status *> this name
> organization is line sequential.
> select lineseq-out
> assign to ws-out-file
> file status is ws-file-status *> and this name
> organization is line sequential.
I would use different fields for the two and then in all the places you have
if status-key-1 <> '0'
use the CORRECT field for the file that you have just done I/O on (If you have
done I/O on both, then check both fields)
"Michael Russell" <michael.russell@spamex.dsl.pipex.com> wrote in message
news:40ffbe73$0$6445$cc9e4d1f@news-text.dial.pipex.com...
> I'm using Net Express 3.01.14 - University edition & running Win XP Pro,
> SP1.
>
> A simple MF program to read a rather large (1.1gb) text (line seq) file & do
> some simple cutting out of records seems to lose records from the output.
> Well, it actually does lose them - unintentionally, of course :-)
>
> The program is reproduced below. It never executes section 'check-status' -
> there's a 'break' on that section's 1st line.
>
> It's quite a pain trying to use a text editor on the file - Textpad & Edit
> Plus both fail to load it because it's so big; Ultra Edit 32 loads it but
> any editing is excrutiatingly sloooooow. Maybe there's a simple line-editor
> out there?
>
> Any thoughts?
>
> Michael
>
> id division.
> program-id. Trimmer2.
> environment division.
> select lineseq-in
> assign to ws-in-file
> file status is ws-file-status
> organization is line sequential.
> select lineseq-out
> assign to ws-out-file
> file status is ws-file-status
> organization is line sequential.
> data division.
> file section.
> fd lineseq-in
> record contains 200 characters.
> 01 lineseq-in-rec pic x(200).
> fd lineseq-out
> record contains 200 characters.
> 01 lineseq-out-rec pic x(200).
> working-storage section.
> 01 ws-in-file pic x(45) value
> 'f:\Small-jun01-jul06.sql'.
> 01 ws-out-file pic x(45) value
> 'f:\Jun20.sql'.
> 01 ws-file-status.
> 05 status-key-1 pic x.
> 05 status-key-2 pic x.
> 05 binary-status redefines status-key-2 pic 99 comp-x.
> 01 ws-recs-in pic 9(9).
> 01 ws-recs-out pic 9(9).
> 01 ws-recs-includeed pic 9(9).
> 01 ws-start-include pic 9(9).
> 01 ws-end-include pic 9(9).
> 01 ws-recs-to-include pic 9(9).
> 01 ws-yorn pic x.
> procedure division.
> a-control section.
> move 0 to ws-recs-in, ws-recs-out, ws-recs-includeed
> ws-start-include, ws-end-include
> perform until exit
> display 'Start include:'
> accept ws-start-include
> display 'End include (inclusive):'
> accept ws-end-include
> if ws-start-include > 0 and
> ws-start-include < ws-end-include
> compute ws-recs-to-include =
> ws-end-include - ws-start-include + 1
> display 'include ', ws-recs-to-include, '?'
> accept ws-yorn
> if ws-yorn <> 'Y' and
> ws-yorn <> 'y'
> stop run
> end-if
> exit perform
> else
> display 'Range error!'
> end-if
> end-perform
> perform z-opens.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> perform b-copy.
> close lineseq-in, lineseq-out
> stop run.
> b-copy section.
> perform until exit
> read lineseq-in
> at end
> exit perform
> end-read
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> add 1 to ws-recs-in
> if ws-recs-in = ws-start-include
> move '-- start include at'
> to lineseq-out-rec
> move ws-start-include to lineseq-out-rec(21:10)
> move 'until (inclusive):' to lineseq-out-rec(32:50)
> move ws-end-include to lineseq-out-rec(51:10)
> write lineseq-out-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> exit perform cycle
> end-if
> if ws-recs-in < ws-start-include
> exit perform cycle
> end-if
> if ws-recs-in > ws-end-include
> exit perform
> end-if
> if ws-recs-in = (ws-end-include + 1)
> move '-- end include at'
> to lineseq-out-rec
> move ws-end-include to lineseq-out-rec(21:10)
> write lineseq-out-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> exit perform cycle
> end-if
> write lineseq-out-rec from lineseq-in-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
>
> add 1 to ws-recs-out
> if ws-recs-in(5:5) = '00000'
> display 'Read=' ws-recs-in
> ' Written=', ws-recs-out
> end-if
> end-perform.
> z-opens section.
> open input lineseq-in.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> open output lineseq-out.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
>
> check-status section.
> display 'oops at:' ws-recs-in, ', in'
> display 'recs out:' ws-recs-out
> evaluate status-key-1
> when "0" next sentence
> when "1" display "end of file reached"
> perform check-eof-status
> when "2" display "invalid key"
> perform check-inv-key-status
> when "3" display "permanent error"
> perform check-perm-err-status
> when "4" display "logic error"
> when "9" display "run-time-system error"
> perform check-mf-error-message
> end-evaluate.
>
> check-eof-status section.
> if status-key-2 = "0"
> display "no next logical record"
> end-if.
>
> check-inv-key-status section.
> evaluate status-key-2
> when "2" display "attempt to write dup key"
> when "3" display "no record found"
> end-evaluate.
>
> check-perm-err-status section.
> if status-key-2 = "5"
> display "file not found"
> end-if.
>
> check-mf-error-message section.
> evaluate binary-status
> when 002 display "file not open"
> when 007 display "disk space exhausted"
> when 013 display "file not found"
> when 024 display "disk error "
> when 065 display "file locked "
> when 068 display "record locked "
> when 039 display "record inconsistent"
> when 146 display "no current record "
> when 180 display "file malformed "
> when 208 display "network error "
> when 213 display "too many locks "
> when other display "not error status "
> display binary-status
> end-evaluate.
>
>
>
>
| |
| JerryMouse 2004-07-22, 8:55 pm |
| Michael Russell wrote:
> I'm using Net Express 3.01.14 - University edition & running Win XP
> Pro, SP1.
>
> A simple MF program to read a rather large (1.1gb) text (line seq)
> file & do some simple cutting out of records seems to lose records
> from the output. Well, it actually does lose them - unintentionally,
> of course :-)
>
> The program is reproduced below. It never executes section
> 'check-status' - there's a 'break' on that section's 1st line.
>
> It's quite a pain trying to use a text editor on the file - Textpad &
> Edit Plus both fail to load it because it's so big; Ultra Edit 32
> loads it but any editing is excrutiatingly sloooooow. Maybe there's a
> simple line-editor out there?
>
> Any thoughts?
Use WordPad.
| |
| JerryMouse 2004-07-22, 8:55 pm |
| Richard wrote:
>
>
> Don't use Windows XP. Don't try and do it interactively (ie loading
> it into a text editor).
Why not use XP? Why not load into a text editor? Are these rules you learned
by shouting questions down the well (except on Fridays, when it's your turn
in the well) or do you have some empirical - though flawed - reason for
these rules?
| |
| Richard 2004-07-22, 8:55 pm |
| "William M. Klein" <wmklein@nospam.netcom.com> wrote
> Using the SAME WS item as the file status field for two different files is
> often dangerous. i.e where you have:
>
> I would use different fields for the two and then in all the places you have
While using one or many file stautus fields is a matter of style or
choice, I completely disagree that using just one is 'dangerous'.
If the status is checked after each operation, as it should be, then
there is no danger at all in using one shared status. In fact quite
the opposite, with many there is the danger of checking the wrong
status field.
> use the CORRECT field for the file that you have just done I/O on
Using just one means that you _always_ use the correct one. It also
makes a common checking routine (as here) much simpler and more
reliable.
> (If you have done I/O on both, then check both fields)
If you have done I/O on both then you should have checked after _each_
I/O statement. What excuse would you have for doing:
READ InFile
MOVE InRec TO OutRec
WRITE OutRec
IF ( InStatus-1 <> '0' )
DISPLAY "Ooops, just wrote crap"
...
[huge unnecessary quote removed]
| |
| Robert Wagner 2004-07-22, 8:55 pm |
| "William M. Klein" <wmklein@nospam.netcom.com> wrote:
>Using the SAME WS item as the file status field for two different files is
often
>dangerous. i.e where you have:
>
>
>I would use different fields for the two and then in all the places you have
>if status-key-1 <> '0'
>use the CORRECT field for the file that you have just done I/O on (If you have
>done I/O on both, then check both fields)
I've been doing it for 40 years. It's not dangerous so long as you check the
return code immediately after an IO, before doing another.
The benefit is giving a general-purpose abend process one place to look for the
reason. That's exactly what Michael's program is doing.
| |
| William M. Klein 2004-07-22, 8:55 pm |
| When you use a single file-status code, then you cannot reliably doing
multi-file I/O, e.g.
Open Input File-1 File-2
Output File-3
If you check the file status after such a (valid) COBOL statement, only the
status of File-3 will be "recorded".
If you want "general purpose" error handling, that is why DECLARATIVES allow for
checking by:
- All files
- All files opened with a specific Input, Output, I-O, category
- specific file name
Furthermore, thru the '85 Standard, you can use the DEBUG-ITEM to determine
which file (within the DECLARATIVE) you are processing. This is "enhanced" via
the 2002 Standard exception handling.
Of course, if you never do multiple I/O's in a single statement, using a single
file status may be OK, but notice (for example), the original code had:
perform z-opens.
if status-key-1 <> '0'
perform check-status
stop run
end-if.
As z-opens, opened BOTH files and actually does a STOP run when status-key-1
isn't "0" this is both "redundant" and potentially confusing to a maintenance
programmer.
--
Bill Klein
wmklein <at> ix.netcom.com
"Robert Wagner" <robert.deletethis@wagner.net> wrote in message
news:41003d37.92247432@news.optonline.net...
> "William M. Klein" <wmklein@nospam.netcom.com> wrote:
>
> often
have[color=darkred]
>
> I've been doing it for 40 years. It's not dangerous so long as you check the
> return code immediately after an IO, before doing another.
>
> The benefit is giving a general-purpose abend process one place to look for
the
> reason. That's exactly what Michael's program is doing.
>
>
| |
| JerryMouse 2004-07-23, 3:55 am |
| William M. Klein wrote:
> When you use a single file-status code, then you cannot reliably doing
> multi-file I/O, e.g.
>
> Open Input File-1 File-2
> Output File-3
>
> If you check the file status after such a (valid) COBOL statement,
> only the status of File-3 will be "recorded".
Ah ha! A "Style" debate.
People who do:
Open Input File-1 File2 Output File-3 I-O File-4 Beer
Are the same kind of rats who code:
Move 0 to Variable-A Variable-B Variable-C
and
Add 1 to Variable-A Variable-A Variable-A Variable-B
But soap sometimes leaves a film, so I say "Hold the soap! Hold the soap!"
| |
| docdwarf@panix.com 2004-07-23, 3:55 am |
| In article <c6Wdnas4eZoM-p3cRVn-gg@giganews.com>,
JerryMouse <nospam@bisusa.com> wrote:
>William M. Klein wrote:
>
>Ah ha! A "Style" debate.
>
>People who do:
>
> Open Input File-1 File2 Output File-3 I-O File-4 Beer
Which, of course, any Decent and Sane Coder would have rendered
intelligibly, as in:
OPEN INPUT FILE-1
FILE-2
OUTPUT FILE-3
I-O FILE-4.
.... so that in the 9000-EOJ paragraph the same lines could be copied and,
with a few simple keystrokes, changed to a single CLOSE.
>
>Are the same kind of rats who code:
>
> Move 0 to Variable-A Variable-B Variable-C
.... which, of course, the aforemented Decent and Sane Coder renders as
MOVE 0 TO FIELD-A
FIELD-B
FIELD-C
.... because this Coder knows that mention of 'variables' instead of
'fields' (and 'arrays' instead of 'tables') might betray the speaker as a
dabbler in a dialect of BASIC.
>
>and
>
> Add 1 to Variable-A Variable-A Variable-A Variable-B
See above about 'variables' versus fields.
>
>But soap sometimes leaves a film, so I say "Hold the soap! Hold the soap!"
I have been known to leave a film... but when doing so I try not to
disturb the other cinema-partons.
DD
| |
| Richard 2004-07-23, 3:55 am |
| "JerryMouse" <nospam@bisusa.com> wrote
>
> Why not use XP?
He asked for a suggestion, I gave him one.
> Why not load into a text editor?
If you had read the problem you should have seen that the file is 1.1
GIGABYTES.
Typically a text editor will load the file into memory rather than
page it from disk. This is likely to exceed the resources available,
even on a fairly large machine, if it could load it all.
A stream editor, such as the AWK or sed that I suggested would be a
much better solution for his _actual_ problem.
> or do you have some empirical - though flawed - reason for
> these rules?
Yes, I do have reasons for these 'rules'. Actually they are not
rules, they are suggestions as requested. Why do you 'consider' the
reasons to be flawed, even when you have no clue at all what they are
?
| |
| William M. Klein 2004-07-23, 3:55 am |
| Jerry,
and how would you code a SORT or MERGE statement (that doesn't need an Input
or Output procedure) without referencing MULTIPLE files in the same statement?
--
Bill Klein
wmklein <at> ix.netcom.com
"JerryMouse" <nospam@bisusa.com> wrote in message
news:c6Wdnas4eZoM-p3cRVn-gg@giganews.com...
> William M. Klein wrote:
>
> Ah ha! A "Style" debate.
>
> People who do:
>
> Open Input File-1 File2 Output File-3 I-O File-4 Beer
>
> Are the same kind of rats who code:
>
> Move 0 to Variable-A Variable-B Variable-C
>
> and
>
> Add 1 to Variable-A Variable-A Variable-A Variable-B
>
> But soap sometimes leaves a film, so I say "Hold the soap! Hold the soap!"
>
>
| |
| Richard 2004-07-23, 3:55 am |
| "William M. Klein" <wmklein@nospam.netcom.com> wrote
> When you use a single file-status code, then you cannot reliably doing
> multi-file I/O, e.g.
>
> Open Input File-1 File-2
> Output File-3
Which I never do. Generally I have each file separated out into
diferent routines so that the opportunity to do OPEN for several files
doesn't exist, even if I thought there was any point in doing so.
In general I would OPEN each file in turn and check each is successful
before bothering to open the next. The danger in the above is that
the OUTPUT file-3 may be overwritten when file-1 or file-2 is not
available.
Systems that use locks may, for example, have one program apply a file
lock to file-1 to stop particular types of processing while doing
operations that require exclusive access.
You may find that File-1 is locked, but too late, you've already
killed file-3.
> If you check the file status after such a (valid) COBOL statement, only the
> status of File-3 will be "recorded".
Yes, it is valid, and saves a whole 13 characters.
> If you want "general purpose" error handling, that is why DECLARATIVES allow
> for checking by:
Don't like DECLARITIVES, don't use them.
> Of course, if you never do multiple I/O's in a single statement, using a
> single file status may be OK,
"May be" ? Why only "May be" ?
> but notice (for example), the original code had:
> perform z-opens.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> As z-opens, opened BOTH files and actually does a STOP run when status-key-1
> isn't "0" this is both "redundant"
Exactly, he is correctly checking the file status after each i/o and
has left some harmless redundant code laying around.
> and potentially confusing to a maintenance programmer.
OTOH a maintenance programmer may be enough by a:
OPEN INPUT some-file
IF some-status-1 <> "0"
...
when it should have been someother-status-1.
| |
| JerryMouse 2004-07-23, 3:55 pm |
| William M. Klein wrote:
> Jerry,
> and how would you code a SORT or MERGE statement (that doesn't
> need an Input or Output procedure) without referencing MULTIPLE files
> in the same statement?
>
Would this work?
SORT SORT-WORK ON ASCENDING KEY SORT-KEY
INPUT PROCEDURE IS SORT-IN
OUTPUT PROCEDURE IS SORT-OUT.
| |
| JerryMouse 2004-07-23, 3:55 pm |
| Richard wrote:
> "JerryMouse" <nospam@bisusa.com> wrote
>
>
> He asked for a suggestion, I gave him one.
>
>
> If you had read the problem you should have seen that the file is 1.1
> GIGABYTES.
So what?
>
> Typically a text editor will load the file into memory rather than
> page it from disk. This is likely to exceed the resources available,
> even on a fairly large machine, if it could load it all.
>
> A stream editor, such as the AWK or sed that I suggested would be a
> much better solution for his _actual_ problem.
Psst! Streaming text editors exist. Pass it on.
>
>
> Yes, I do have reasons for these 'rules'. Actually they are not
> rules, they are suggestions as requested. Why do you 'consider' the
> reasons to be flawed, even when you have no clue at all what they are
>
I suppose because inherent in the "suggestion" is that the poster dip
himself in the vat of boiling Unix/Linux oil. Both AWK and sed are
Unix/Linux programs (although sed has been ported to DOS).
| |
| William M. Klein 2004-07-23, 3:55 pm |
| So you always use Input/Output procedures *even when not needed*?
On IBM mainframes (with the FASTSRT option) at least, this significantly slows
down performance - but does allow you to use a generic file status field. My
experience is that would not be a "good solution".
--
Bill Klein
wmklein <at> ix.netcom.com
"JerryMouse" <nospam@bisusa.com> wrote in message
news:c8WdnWhmxLvxl5zc4p2dnA@giganews.com...
> William M. Klein wrote:
>
> Would this work?
>
> SORT SORT-WORK ON ASCENDING KEY SORT-KEY
> INPUT PROCEDURE IS SORT-IN
> OUTPUT PROCEDURE IS SORT-OUT.
>
>
| |
| Richard 2004-07-23, 8:55 pm |
| "JerryMouse" <nospam@bisusa.com> wrote
>
> Psst! Streaming text editors exist. Pass it on.
Fine, you suggest one of those to him then. Give him a name or a page
he can download it from.
> I suppose because inherent in the "suggestion" is that the poster dip
> himself in the vat of boiling Unix/Linux oil. Both AWK and sed are
> Unix/Linux programs (although sed has been ported to DOS).
Actually AWK and sed have many implementations on many systems
including native Windows, CygWin and Microsoft's SFU (Services For
Unix). These are freely available and can be located using google in
a matter of seconds.
The main point is that with a 1.1 Gb file the 'Windows Way' of loading
it into a window and using the mouse and scroll bar to find the point
in the file visually is quite inappropriate to the problem, as it is
to many problems.
For this particular problem the 'Unix Way' of using a script to pass
the text through a simple utilty without trying to display it is
exactly what is required.
To a hammer all problems look like nails. You seem to be advocating
the 'Windows Way', as you often do, regardless that it is
inappropriate.
| |
| JerryMouse 2004-07-23, 8:55 pm |
| William M. Klein wrote:
> So you always use Input/Output procedures *even when not needed*?
Well, no. I only use them when I need something sorted. It's not like
periods.
[color=darkred]
>
> On IBM mainframes (with the FASTSRT option) at least, this
> significantly slows down performance - but does allow you to use a
> generic file status field. My experience is that would not be a
> "good solution".
>
| |
| Michael Russell 2004-07-24, 8:55 am |
| Thanks for all the info & suggestions.
In answer to one of the qustions, the lines lost are random, and usually 2
or 3 at a time. (I think it's an MF problem with high speed, high volume i/o
on text files, but I'm not asserting anything).
In answer to another - yes, I'm trying to recover from a database whose
rollback doesn't include the ability to jump back to a point-in-time:
Sybase. Now I'm swapping to Oracle 9i. I also neglected to use
version-control in NetExpress. I thought I wouldn't need it - just 3 x
600-line programs - to calculate some horse ratings.
The horse-ratings were flawed & I corrected them. Now they work, but the
results are consistently poor. When flawed, they were consistently (36,000
races over 7 years) profitable. Someone asked whether I wanted 'flawed &
profit', or 'perfect & loss'. I'm trying to reverse-engineer the data so
that I can then reverse-engineer my un-flawed software.
Though you might be amused at the tale.
Regards
Michael
"Michael Russell" <michael.russell@spamex.dsl.pipex.com> wrote in message
news:40ffbe73$0$6445$cc9e4d1f@news-text.dial.pipex.com...
> I'm using Net Express 3.01.14 - University edition & running Win XP Pro,
> SP1.
>
> A simple MF program to read a rather large (1.1gb) text (line seq) file &
do
> some simple cutting out of records seems to lose records from the output.
> Well, it actually does lose them - unintentionally, of course :-)
>
> The program is reproduced below. It never executes section
'check-status' -
> there's a 'break' on that section's 1st line.
>
> It's quite a pain trying to use a text editor on the file - Textpad & Edit
> Plus both fail to load it because it's so big; Ultra Edit 32 loads it but
> any editing is excrutiatingly sloooooow. Maybe there's a simple
line-editor
> out there?
>
> Any thoughts?
>
> Michael
>
> id division.
> program-id. Trimmer2.
> environment division.
> select lineseq-in
> assign to ws-in-file
> file status is ws-file-status
> organization is line sequential.
> select lineseq-out
> assign to ws-out-file
> file status is ws-file-status
> organization is line sequential.
> data division.
> file section.
> fd lineseq-in
> record contains 200 characters.
> 01 lineseq-in-rec pic x(200).
> fd lineseq-out
> record contains 200 characters.
> 01 lineseq-out-rec pic x(200).
> working-storage section.
> 01 ws-in-file pic x(45) value
> 'f:\Small-jun01-jul06.sql'.
> 01 ws-out-file pic x(45) value
> 'f:\Jun20.sql'.
> 01 ws-file-status.
> 05 status-key-1 pic x.
> 05 status-key-2 pic x.
> 05 binary-status redefines status-key-2 pic 99 comp-x.
> 01 ws-recs-in pic 9(9).
> 01 ws-recs-out pic 9(9).
> 01 ws-recs-includeed pic 9(9).
> 01 ws-start-include pic 9(9).
> 01 ws-end-include pic 9(9).
> 01 ws-recs-to-include pic 9(9).
> 01 ws-yorn pic x.
> procedure division.
> a-control section.
> move 0 to ws-recs-in, ws-recs-out, ws-recs-includeed
> ws-start-include, ws-end-include
> perform until exit
> display 'Start include:'
> accept ws-start-include
> display 'End include (inclusive):'
> accept ws-end-include
> if ws-start-include > 0 and
> ws-start-include < ws-end-include
> compute ws-recs-to-include =
> ws-end-include - ws-start-include + 1
> display 'include ', ws-recs-to-include, '?'
> accept ws-yorn
> if ws-yorn <> 'Y' and
> ws-yorn <> 'y'
> stop run
> end-if
> exit perform
> else
> display 'Range error!'
> end-if
> end-perform
> perform z-opens.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> perform b-copy.
> close lineseq-in, lineseq-out
> stop run.
> b-copy section.
> perform until exit
> read lineseq-in
> at end
> exit perform
> end-read
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> add 1 to ws-recs-in
> if ws-recs-in = ws-start-include
> move '-- start include at'
> to lineseq-out-rec
> move ws-start-include to lineseq-out-rec(21:10)
> move 'until (inclusive):' to lineseq-out-rec(32:50)
> move ws-end-include to lineseq-out-rec(51:10)
> write lineseq-out-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> exit perform cycle
> end-if
> if ws-recs-in < ws-start-include
> exit perform cycle
> end-if
> if ws-recs-in > ws-end-include
> exit perform
> end-if
> if ws-recs-in = (ws-end-include + 1)
> move '-- end include at'
> to lineseq-out-rec
> move ws-end-include to lineseq-out-rec(21:10)
> write lineseq-out-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> exit perform cycle
> end-if
> write lineseq-out-rec from lineseq-in-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
>
> add 1 to ws-recs-out
> if ws-recs-in(5:5) = '00000'
> display 'Read=' ws-recs-in
> ' Written=', ws-recs-out
> end-if
> end-perform.
> z-opens section.
> open input lineseq-in.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> open output lineseq-out.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
>
> check-status section.
> display 'oops at:' ws-recs-in, ', in'
> display 'recs out:' ws-recs-out
> evaluate status-key-1
> when "0" next sentence
> when "1" display "end of file reached"
> perform check-eof-status
> when "2" display "invalid key"
> perform check-inv-key-status
> when "3" display "permanent error"
> perform check-perm-err-status
> when "4" display "logic error"
> when "9" display "run-time-system error"
> perform check-mf-error-message
> end-evaluate.
>
> check-eof-status section.
> if status-key-2 = "0"
> display "no next logical record"
> end-if.
>
> check-inv-key-status section.
> evaluate status-key-2
> when "2" display "attempt to write dup key"
> when "3" display "no record found"
> end-evaluate.
>
> check-perm-err-status section.
> if status-key-2 = "5"
> display "file not found"
> end-if.
>
> check-mf-error-message section.
> evaluate binary-status
> when 002 display "file not open"
> when 007 display "disk space exhausted"
> when 013 display "file not found"
> when 024 display "disk error "
> when 065 display "file locked "
> when 068 display "record locked "
> when 039 display "record inconsistent"
> when 146 display "no current record "
> when 180 display "file malformed "
> when 208 display "network error "
> when 213 display "too many locks "
> when other display "not error status "
> display binary-status
> end-evaluate.
>
>
>
>
| |
| Michael Russell 2004-07-24, 8:55 am |
| Just a test - I did reply earlier, but can't see the posting.
"Michael Russell" <michael.russell@spamex.dsl.pipex.com> wrote in message
news:40ffbe73$0$6445$cc9e4d1f@news-text.dial.pipex.com...
> I'm using Net Express 3.01.14 - University edition & running Win XP Pro,
> SP1.
>
> A simple MF program to read a rather large (1.1gb) text (line seq) file &
do
> some simple cutting out of records seems to lose records from the output.
> Well, it actually does lose them - unintentionally, of course :-)
>
> The program is reproduced below. It never executes section
'check-status' -
> there's a 'break' on that section's 1st line.
>
> It's quite a pain trying to use a text editor on the file - Textpad & Edit
> Plus both fail to load it because it's so big; Ultra Edit 32 loads it but
> any editing is excrutiatingly sloooooow. Maybe there's a simple
line-editor
> out there?
>
> Any thoughts?
>
> Michael
>
> id division.
> program-id. Trimmer2.
> environment division.
> select lineseq-in
> assign to ws-in-file
> file status is ws-file-status
> organization is line sequential.
> select lineseq-out
> assign to ws-out-file
> file status is ws-file-status
> organization is line sequential.
> data division.
> file section.
> fd lineseq-in
> record contains 200 characters.
> 01 lineseq-in-rec pic x(200).
> fd lineseq-out
> record contains 200 characters.
> 01 lineseq-out-rec pic x(200).
> working-storage section.
> 01 ws-in-file pic x(45) value
> 'f:\Small-jun01-jul06.sql'.
> 01 ws-out-file pic x(45) value
> 'f:\Jun20.sql'.
> 01 ws-file-status.
> 05 status-key-1 pic x.
> 05 status-key-2 pic x.
> 05 binary-status redefines status-key-2 pic 99 comp-x.
> 01 ws-recs-in pic 9(9).
> 01 ws-recs-out pic 9(9).
> 01 ws-recs-includeed pic 9(9).
> 01 ws-start-include pic 9(9).
> 01 ws-end-include pic 9(9).
> 01 ws-recs-to-include pic 9(9).
> 01 ws-yorn pic x.
> procedure division.
> a-control section.
> move 0 to ws-recs-in, ws-recs-out, ws-recs-includeed
> ws-start-include, ws-end-include
> perform until exit
> display 'Start include:'
> accept ws-start-include
> display 'End include (inclusive):'
> accept ws-end-include
> if ws-start-include > 0 and
> ws-start-include < ws-end-include
> compute ws-recs-to-include =
> ws-end-include - ws-start-include + 1
> display 'include ', ws-recs-to-include, '?'
> accept ws-yorn
> if ws-yorn <> 'Y' and
> ws-yorn <> 'y'
> stop run
> end-if
> exit perform
> else
> display 'Range error!'
> end-if
> end-perform
> perform z-opens.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> perform b-copy.
> close lineseq-in, lineseq-out
> stop run.
> b-copy section.
> perform until exit
> read lineseq-in
> at end
> exit perform
> end-read
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> add 1 to ws-recs-in
> if ws-recs-in = ws-start-include
> move '-- start include at'
> to lineseq-out-rec
> move ws-start-include to lineseq-out-rec(21:10)
> move 'until (inclusive):' to lineseq-out-rec(32:50)
> move ws-end-include to lineseq-out-rec(51:10)
> write lineseq-out-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> exit perform cycle
> end-if
> if ws-recs-in < ws-start-include
> exit perform cycle
> end-if
> if ws-recs-in > ws-end-include
> exit perform
> end-if
> if ws-recs-in = (ws-end-include + 1)
> move '-- end include at'
> to lineseq-out-rec
> move ws-end-include to lineseq-out-rec(21:10)
> write lineseq-out-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
> exit perform cycle
> end-if
> write lineseq-out-rec from lineseq-in-rec
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if
>
> add 1 to ws-recs-out
> if ws-recs-in(5:5) = '00000'
> display 'Read=' ws-recs-in
> ' Written=', ws-recs-out
> end-if
> end-perform.
> z-opens section.
> open input lineseq-in.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
> open output lineseq-out.
> if status-key-1 <> '0'
> perform check-status
> stop run
> end-if.
>
> check-status section.
> display 'oops at:' ws-recs-in, ', in'
> display 'recs out:' ws-recs-out
> evaluate status-key-1
> when "0" next sentence
> when "1" display "end of file reached"
> perform check-eof-status
> when "2" display "invalid key"
> perform check-inv-key-status
> when "3" display "permanent error"
> perform check-perm-err-status
> when "4" display "logic error"
> when "9" display "run-time-system error"
> perform check-mf-error-message
> end-evaluate.
>
> check-eof-status section.
> if status-key-2 = "0"
> display "no next logical record"
> end-if.
>
> check-inv-key-status section.
> evaluate status-key-2
> when "2" display "attempt to write dup key"
> when "3" display "no record found"
> end-evaluate.
>
> check-perm-err-status section.
> if status-key-2 = "5"
> display "file not found"
> end-if.
>
> check-mf-error-message section.
> evaluate binary-status
> when 002 display "file not open"
> when 007 display "disk space exhausted"
> when 013 display "file not found"
> when 024 display "disk error "
> when 065 display "file locked "
> when 068 display "record locked "
> when 039 display "record inconsistent"
> when 146 display "no current record "
> when 180 display "file malformed "
> when 208 display "network error "
> when 213 display "too many locks "
> when other display "not error status "
> display binary-status
> end-evaluate.
>
>
>
>
| |
| Richard 2004-07-24, 8:55 pm |
| "Michael Russell" <michael.russell@spamex.dsl.pipex.com> wrote
> The horse-ratings were flawed & I corrected them. Now they work, but the
> results are consistently poor. When flawed, they were consistently (36,000
> races over 7 years) profitable. Someone asked whether I wanted 'flawed &
> profit', or 'perfect & loss'. I'm trying to reverse-engineer the data so
> that I can then reverse-engineer my un-flawed software.
There is a reliable way to make a small fortune from betting on horse
races and that is to start with a large fortune.
| |
|
| JerryMouse wrote:
> Richard wrote:
>
>
>
> I suppose because inherent in the "suggestion" is that the poster dip
> himself in the vat of boiling Unix/Linux oil. Both AWK and sed are
> Unix/Linux programs (although sed has been ported to DOS).
You can use awk using Cygwin, too... along with grep and all other
sorts of *nix tools... :)
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ LXi0007@Netscape.net ~
~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ I do not read e-mail at the above address ~
~ Please see website if you wish to contact me privately ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
| |
| Michael Russell 2004-07-26, 3:55 pm |
| That is more or less inexact, but thanks anyway.
Michael
"Richard" <riplin@Azonic.co.nz> wrote in message
news:217e491a.0407241204.9b77a2e@posting.google.com...
> "Michael Russell" <michael.russell@spamex.dsl.pipex.com> wrote
>
(36,000[color=darkred]
>
> There is a reliable way to make a small fortune from betting on horse
> races and that is to start with a large fortune.
|
|
|
|
|