Home > Archive > Cobol > June 2004 > Getting the "program name"
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 |
Getting the "program name"
|
|
| William M. Klein 2004-06-15, 8:55 am |
| I am not certain that we (C.L.C.) ever heard back from the person who asked the
original question about getting the "program name". However, that thread has
gotten so filled with misinformation and/or erroneous opinion, that I thought I
would start a new thread - with what I believe to be "fact" *and* "sometimes"
information.
1) In Standard (or even many common dialects) of COBOL, there is *NO* portable
way to get the "program name" at run-time - unless that information is
explicitly stored in the application source code.
2) There are at least three possible "program names" that are supported as
POTENTIALLY distinct in some (not all) compilers and operating systems:
- the name in the Program-ID paragraph
- the name by which the source code was stored
- the name of the "object" (executable) code
In addition, some (not all) compilers support
- an "ENTRY" statement name (extension to the Standard) by which the program
was activated
- a nested program's name
3) In many (possibly most - demonstrated NOT all) operating system/compiler
combinations, the "program name" (of the executable) may be stored SOMEWHERE
within the OS/run-time system - in a "place" where *some* type of application
code could get at it. If the COBOL compiler supports the 2002 Standard features
(but extensions to the '85 Standard) of USAGE Pointer / Procedure-Pointer, it is
*possible* (not guaranteed) that a COBOL program could get at this "system"
information. In other environments (compiler / OS combinations) it might be
impossible in COBOL but possible in the "OS" native-ish language - such as
Assembler, C, Algol, whatever. It is also possible that getting at this
information requires some type of "authorization" that most application code
does not have.
5) Depending on WHY the application wants to obtain this information, it may be
useful to get the name of:
- the program currently "running"
- the program at the head of the current run unit
- some other "relevant" program name (start of process, thread, transaction,
etc)
Only the programmer designing the application will know WHICH is desired /
desirable, i.e. meets the application needs. (I know of cases where each of
these is what one is after)
****
Bottom-Line: (for the original poster - and anyone still interested in this
thread)
- Tell us your compiler and operating system
- Tell us which "program name" you are after
- (possibly useful, WHY you want the name)
and we can tell you
- is it possible to get this (for your environment)
- and if so, how to get it
If you read generalizations that claim that this (whatever "this is") is ALWAYS
possible (much less portable), then it is (almost certainly) wrong.
--
Bill Klein
wmklein <at> ix.netcom.com
| |
| David Latimer 2004-06-16, 8:55 pm |
| "William M. Klein" <wmklein@nospam.netcom.com> wrote in message news:<KOAzc.1003$w07.841@newsread2.news.pas.earthlink.net>...
<snip>
>
> Bottom-Line: (for the original poster - and anyone still interested in this
> thread)
>
> - Tell us your compiler and operating system
> - Tell us which "program name" you are after
> - (possibly useful, WHY you want the name)
>
> and we can tell you
> - is it possible to get this (for your environment)
> - and if so, how to get it
>
> If you read generalizations that claim that this (whatever "this is") is ALWAYS
> possible (much less portable), then it is (almost certainly) wrong.
I am the original poster!
compiler = MicroFocus Object COBOL v4.0
OS = UnixWare 2.1.3
Program Name - I'm after the name which follows PROGRAM-ID (which
"should" be the same as the .cbl & .gnt name).
I'm trying to improve our standard error routine, done in copy code
and contained in every program.
If there is a file error the standard routine is performed and the
user gets a red box containing useful information (eg File, Paragraph
Position, Key, File Status) which the user can convey to us when they
ring about the error.
It turns out that they don't always ring!
After pressing F11 to leave the error screen they can sometimes carry
on while avoiding the error (depending on which part of the system).
I had the idea of emailing the error directly to us (now that we've
installed versionone's fax and mail software) which is actually
working well except for the fact that it doesn't tell us which program
the error occured.
So having read the previous thread I have already come to the
conclusion that I'll have to explicitly declare the program name value
as a working storage item with a standard name that the error routing
can use.
I now need to edit lots of programs but I'm hoping to find a short
cut, hence another thread asking if sed or COBOL were the best
solution.
It might actually be awk (but I haven't tried yet!)
David
| |
| Lueko Willms 2004-06-16, 8:55 pm |
| Am 16.06.04
schrieb david@quantumcat.demon.co.uk (David Latimer)
auf /COMP/LANG/COBOL
in a9026f4e.0406160753.6ea3ff2a@posting.google.com
ueber Re: Getting the "program name"
DL> Program Name - I'm after the name which follows PROGRAM-ID (which
DL> "should" be the same as the .cbl & .gnt name).
DL> I'm trying to improve our standard error routine, done in copy code
DL> and contained in every program.
How about a
COPY <errcopy>
REPLACING == program-id == BY == <actual-program-id> ==
Yours,
Lüko Willms http://www.mlwerke.de
/--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten --
"Ohne Pressefreiheit, Vereins- und Versammlungsrecht ist keine
Arbeiterbewegung möglich" - Friedrich Engels (Februar 1865)
| |
| David Latimer 2004-06-17, 8:55 am |
| Good idea.
It is one of three solutions that i identified.
For every program I could do one of:
1. Insert a Working Storage item with VALUE "prog-name".
2. New A001 copy code WS item & MOVE "prog-name" to it (first
statement).
3. New A001 copy code WS item & do REPLACING "xyz" WITH "prog-name".
(NB every program has a001.cpy which contains Working Storage items)
Thinking about it again, the third solution is looking the best and
could well be the easiest in terms of using something like sed to
convert many programs.
David
l.willms@jpberlin.de (Lueko Willms) wrote in message news:<9B2xUMnPflB@jpberlin-l.willms.jpberlin.de>...
> Am 16.06.04
> schrieb david@quantumcat.demon.co.uk (David Latimer)
> auf /COMP/LANG/COBOL
> in a9026f4e.0406160753.6ea3ff2a@posting.google.com
> ueber Re: Getting the "program name"
>
> DL> Program Name - I'm after the name which follows PROGRAM-ID (which
> DL> "should" be the same as the .cbl & .gnt name).
> DL> I'm trying to improve our standard error routine, done in copy code
> DL> and contained in every program.
>
> How about a
>
> COPY <errcopy>
> REPLACING == program-id == BY == <actual-program-id> ==
>
>
>
> Yours,
> Lüko Willms http://www.mlwerke.de
> /--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten --
>
> "Ohne Pressefreiheit, Vereins- und Versammlungsrecht ist keine
> Arbeiterbewegung möglich" - Friedrich Engels (Februar 1865)
|
|
|
|
|