Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

REPLACING Algorythm
I'm trying to code the REPLACING algorythm. I've played with the Fujitsu
NetCobol compiler and am trying to get some insight. All the examples
and descriptions I found don't have a word and a pseudo word. Somehow I
can't get it together.

COPY BLA REPLACING 10 BY 20, ==(20)== BY ==(20)==

What happens is clear, but I could code it. Can anybody point me in the
right direction or give me a code snippet in more or less anything other
than assembler ;-).

Keith

Report this thread to moderator Post Follow-up to this message
Old Post
Keith Paterson
04-19-05 01:55 PM


Re: REPLACING Algorythm
OK,  I have been waiting and hoping someone else would answer this question.
  I
am not totally clear what you are actually asking for/about - but the follow
ing
MAY help.  (This applies to the '85 Standard and compilers conforming to tha
t
with NO extensions to COPY REPLACING support.  Those with extensions may all
ow
"other stuff". The '02 Standard also introduces some new functionality - suc
h as
the "common extension" of allowing copy "member" names in quotes.)

Rule 1
any text NOT in pseudo-text delimiters is treated "as if it were" in such.
(such text is SUPPOSED TO BE COBOL words and identifiers)

Rule 2
REPLACING rules apply to TEXT WORDS - these include (but are not limited to)
"COBOL words".

Rule 3
The special characters ":" "(" and ")" can be used to "make" text words
without space (or other) separators, e.g.
A(B)
is made up of 2 text words "A" and "B" and the two separators "(" and ")"

Therefore, if you have a COPY statement (named CPY)  of:

05   A(B)C   PIX  X(10).

and a COPY/REPLACING statement of

Copy CPY
Replacing ==(B)== by ==-insert-here-==
PIX   by Pic

Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
04-20-05 08:55 AM


Re: REPLACING Algorythm
Keith Paterson wrote:
> I'm trying to code the REPLACING algorythm. I've played with the Fujitsu
>  NetCobol compiler and am trying to get some insight. All the examples
> and descriptions I found don't have a word and a pseudo word. Somehow I
> can't get it together.
>
> COPY BLA REPLACING 10 BY 20, ==(20)== BY ==(20)==
>
> What happens is clear, but I could code it. Can anybody point me in the
> right direction or give me a code snippet in more or less anything other
> than assembler ;-).

I've never been able to get a word *and* pseudo-text on the same replace
(or replacing) statement.  My compiler is the Unisys 2200 UCS COBOL
compiler, so I can't guarantee it won't work on yours.  Is there any way
you can uniquely identify the words you're wanting to replace?  i.e., do
they all start with "Pic" or something?

What I've had to do in certain situations is use pseudo-text to avoid
replacing a paragraph in a proc I wanted to intercept.  Say I have a
paragraph called 900-SQL-ERROR, and I wanted to code my own, if I say

copy my-proc
replacing 900-SQL-ERROR by MY-SQL-ERROR.

I would also replace 900-SQL-ERROR (which is contained in the proc).
However, if I use the pseudo-text option, I can say

copy my-proc
replacing == GO TO 900-SQL-ERROR==
by == GO TO MY-SQL-ERROR==.

and intercept all the performs, without changing the unwanted paragraph
to the same name that I have in my program.

Hope that helps a bit...


--
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~   /   \  /         ~        Live from Montgomery, AL!       ~
~  /     \/       o  ~                                        ~
~ /      /\   -   |  ~          daniel@thebelowdomain         ~
~ _____ /  \      |  ~      http://www.djs-consulting.com     ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e    ~
~ h---- r+++ z++++                                            ~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~

Report this thread to moderator Post Follow-up to this message
Old Post
LX-i
04-20-05 01:55 PM


Re: REPLACING Algorythm
Keith Paterson wrote:
> I'm trying to code the REPLACING algorythm. I've played with the Fujitsu
>  NetCobol compiler and am trying to get some insight. All the examples
> and descriptions I found don't have a word and a pseudo word. Somehow I
> can't get it together.
>
> COPY BLA REPLACING 10 BY 20, ==(20)== BY ==(20)==
>
> What happens is clear, but I could code it. Can anybody point me in the
> right direction or give me a code snippet in more or less anything other
> than assembler ;-).
>
> Keith

Thanks for the answers. I am actually trying to implement the REPLACING
algorythm for am IDE to show a Copy in it's modified form and to be able
to show the complete "data tree". I just want to make sure my view shows
something that is near to the real thing. This means I have to think of
more or less all possibilities and not just Pattern A leads to Result A.

THX

Keith

Report this thread to moderator Post Follow-up to this message
Old Post
Fiona McBride
04-20-05 01:55 PM


Re: REPLACING Algorythm
In that case (shudder, shudder), the "hardest" things to understand are

A) when REPLACING introduces "new" lines of text, e.g.

COPY Bla
Replacing ==abc== by
==this line
that line
another line==.

This gets "tricky" when you are using a compiler that still pays attention t
o
A-/B-margin stuff because the rules are a little tricky (please don't ask me
 to
explain them <G> )

B) when there are debugging lines "in play".  Even the J4 COBOL committee ha
s
admitted this isn't clear in the '85 (or '02) Standards.  You need to play w
ith
YOUR compiler to figure out what it does with:

D  Copy  Bla
replacing ==ABC==   by ==xyz==.

versus

D  Copy  Bla
D     replacing ==ABC==   by ==xyz==.

versus

Copy Bla
replacing
D        ==ABC==  by xyz
==123==     by 456.

versus

Copy Bla
Replacing   ==ABC
D                           XYZ
123==
by   ==other==.

***

Although I am NOT a compiler writer, I have worked with enough of them to kn
ow
that they HATE when they have to "touch" the COPY/REPLACING code - as even t
hose
who wrote it tend not to remember/understand all variations.

--
Bill Klein
wmklein <at> ix.netcom.com
"Fiona McBride" <Fiona.McBride@gmx.de> wrote in message
news:1in44d.qls.ln@uter.bbv-l.de...
> Keith Paterson wrote: 
>
> Thanks for the answers. I am actually trying to implement the REPLACING
> algorythm for am IDE to show a Copy in it's modified form and to be able t
o
> show the complete "data tree". I just want to make sure my view shows
> something that is near to the real thing. This means I have to think of mo
re
> or less all possibilities and not just Pattern A leads to Result A.
>
> THX
>
> Keith



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
04-20-05 01:55 PM


Re: REPLACING Algorythm
I should have also asked about which compiler and operating system.

IBM (for example) used to have a compiler option (in their OS/VS COBOL and
earlier products) called LANGLVL(1) or (2).  This impacted (ignorantly) how 
COPY
statements on an 01-level item worked.  (They claimed - but I won't swear to
this - that this was due to a change between the '68 and '74 ANSI Standards)
.

--
Bill Klein
wmklein <at> ix.netcom.com
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:36n9e.452307$za2.71316@news.easynews.com...
> In that case (shudder, shudder), the "hardest" things to understand are
>
> A) when REPLACING introduces "new" lines of text, e.g.
>
>     COPY Bla
>           Replacing ==abc== by
>               ==this line
>  that line
>                  another line==.
>
> This gets "tricky" when you are using a compiler that still pays attention
 to
> A-/B-margin stuff because the rules are a little tricky (please don't ask 
me
> to explain them <G> )
>
> B) when there are debugging lines "in play".  Even the J4 COBOL committee 
has
> admitted this isn't clear in the '85 (or '02) Standards.  You need to play
> with YOUR compiler to figure out what it does with:
>
>   D  Copy  Bla
>         replacing ==ABC==   by ==xyz==.
>
> versus
>
>   D  Copy  Bla
>   D     replacing ==ABC==   by ==xyz==.
>
> versus
>
>      Copy Bla
>        replacing
>   D        ==ABC==  by xyz
>             ==123==     by 456.
>
> versus
>
>    Copy Bla
>       Replacing   ==ABC
> D                           XYZ
>                               123==
>                   by   ==other==.
>
>   ***
>
> Although I am NOT a compiler writer, I have worked with enough of them to 
know
> that they HATE when they have to "touch" the COPY/REPLACING code - as even
> those who wrote it tend not to remember/understand all variations.
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
> "Fiona McBride" <Fiona.McBride@gmx.de> wrote in message
> news:1in44d.qls.ln@uter.bbv-l.de... 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
04-20-05 01:55 PM


Re: REPLACING Algorythm
> trying to implement the REPLACING
> algorythm for am IDE to show a Copy in it's modified form

Starting with a template file of a simple Cobol source, process this to
add the COPY statement and replacing clauses.  Execute compiler, or at
least the preprocessor part, with COPYLIST output.  Scrape out the
results of the COPY for display.


Report this thread to moderator Post Follow-up to this message
Old Post
Richard
04-20-05 01:55 PM


Re: REPLACING Algorythm
Keith Paterson wrote:
> I'm trying to code the REPLACING algorythm. I've played with the Fujitsu
>  NetCobol compiler and am trying to get some insight. All the examples
> and descriptions I found don't have a word and a pseudo word. Somehow I
> can't get it together.
>
> COPY BLA REPLACING 10 BY 20, ==(20)== BY ==(20)==
>
> What happens is clear, but I could code it. Can anybody point me in the
> right direction or give me a code snippet in more or less anything other
> than assembler ;-).
>
> Keith

This gets evenmore mindboggling.

I have

000030 20 BLA PIC X(020).
000040 20 BLA2 PIC X(20).

and

000023   COPY IMPORT2 REPLACING 20 BY 01,
000024                          ==(20)== BY ==(20)==.

works. Huh? I thought pseudo text was like quoted text.
Does this apply to all/most compilers.

Sorry for the sobbing.

Keith

Report this thread to moderator Post Follow-up to this message
Old Post
Keith Paterson
04-21-05 08:55 AM


Re: REPLACING Algorythm
Keith Paterson wrote:
> Keith Paterson wrote:
> 
>
>
> This gets evenmore mindboggling.
>
> I have
>
> 000030 20 BLA PIC X(020).
> 000040 20 BLA2 PIC X(20).
>
> and
>
> 000023   COPY IMPORT2 REPLACING 20 BY 01,
> 000024                          ==(20)== BY ==(20)==.
>
> works. Huh? I thought pseudo text was like quoted text.
> Does this apply to all/most compilers.

What do you mean by "works"?  (Can you post the compiler-translated code
for the above?)  Also, I'm not sure what swapping (20) for (20) does for
you - did you mean for those to be different?


--
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~   /   \  /         ~        Live from Montgomery, AL!       ~
~  /     \/       o  ~                                        ~
~ /      /\   -   |  ~          daniel@thebelowdomain         ~
~ _____ /  \      |  ~      http://www.djs-consulting.com     ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e    ~
~ h---- r+++ z++++                                            ~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~

Report this thread to moderator Post Follow-up to this message
Old Post
LX-i
04-21-05 08:55 PM


Re: REPLACING Algorythm
Keith Paterson wrote:
> Keith Paterson wrote:
> 

Always hesitant when it's F/J - it may just not be the same as M/F, but
does this help ?

1 - This is the bare bones copy :-

OBJECT-STORAGE SECTION.
copy "\copylib\sqlResult.cpy"
replacing ==(tag)==  by ==01 ws==.

01 Continent-Info.
copy "\copylib\sqlResult.cpy"
replacing ==(tag)==  by ==05 Continent==.
copy "Continent2.cpy"   replacing ==(tag1)== by ==05 Continent==
==(tag)==  by ==Continent==.

2 - the Copyfiles before compilation :

*>----------sqlresult.cpy-------------------------------------

(tag)-SqlResult                        pic 9(03).

88  ResultOK                    value 0.
88  FileResultOK                value 0.

88  RecNotFound                 value 1.

88  NoMoreRows                  value 2.
88  FileFinis                   value 2.

88  DuplicateKey                value 3.

88  DataError                   value 97.
88  CursorError                 value 98.

88  FileError                   value 99.
88  TableError                  value 97 thru 99.

*>----------------------------------------------------------------

*>----------------contint2.cpy ------------------------------
(tag1)-Record.
10 (tag)-PrimeKey.
15 (tag)-Code            pic x(02).
15                       pic x(18).
10 (tag)-Name               pic x(14).
10 (tag)-Flag               pic 9.
88 (tag)-Actioned        value 1.
88 (tag)-NotActioned     value 2.

*>--------------------------------------------------------------

3. Now the entries in # 1 above after compilation :-

OBJECT-STORAGE SECTION.

*>----------sqlresult.cpy-------------------------------------

01 ws-SqlResult                        pic 9(03).

88  ResultOK                    value 0.
88  FileResultOK                value 0.

88  RecNotFound                 value 1.

88  NoMoreRows                  value 2.
88  FileFinis                   value 2.

88  DuplicateKey                value 3.

88  DataError                   value 97.
88  CursorError                 value 98.

88  FileError                   value 99.
88  TableError                  value 97 thru 99.

*>----------------------------------------------------------------

01 Continent-Info.
*>----------sqlresult.cpy-------------------------------------

05 Continent-SqlResult                        pic 9(03).

88  ResultOK                    value 0.
88  FileResultOK                value 0.

88  RecNotFound                 value 1.

88  NoMoreRows                  value 2.
88  FileFinis                   value 2.

88  DuplicateKey                value 3.

88  DataError                   value 97.
88  CursorError                 value 98.

88  FileError                   value 99.
88  TableError                  value 97 thru 99.

*>----------------------------------------------------------------
*>----------------contint2.cpy ------------------------------
05 Continent-Record.
10 Continent-PrimeKey.
15 Continent-Code            pic x(02).
15                       pic x(18).
10 Continent-Name               pic x(14).
10 Continent-Flag               pic 9.
88 Continent-Actioned        value 1.
88 Continent-NotActioned     value 2.

*>--------------------------------------------------------------

Report this thread to moderator Post Follow-up to this message
Old Post
James J. Gavan
04-21-05 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:47 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.