Re: Is it possible to use the value of the PROGRAM ID within the source code?

From: Robert Wagner (robert.deletethis_at_wagner.net)
Date: 06/11/04


Date: Thu, 10 Jun 2004 22:45:01 GMT

riplin@Azonic.co.nz (Richard) wrote:

>robert.deletethis@wagner.net (Robert Wagner) wrote
>
>> >That is not going to show the name of any CALLed programs, which is
>> >probably the point of the request.
>>
>> No, he wants the name of the Main program,
>
>Where did you get that from ? What part of "every" did you not
>understand ?
>
>> probably to print in a log file or report header.
>
>I do that, using the name of the program that prints the report, not
>just the name of the 'main' program which is the same one in most of
>my systems.

In the case of reports, I hardcode the program name in the header. If a program
prints two reports, I suffix the name with 1 and 2.

In the case of error messages from batch programs, we use a utility starter
program analogous to cobrun. It is an executable, the applications are
dynamically callable. The starter parses the command line, connects to the
database, does housekeeping such as setting nls_date_format, WRITES THE PROGRAM
NAME AND START TIME TO LOG FILES SYSOUT AND SYSERR, then calls the program.
Any messages from the program do not need a program id because it's already in
the log file.

The starter program could pass the program name as parameter 1, but we don't do
that. Structurally, the starter program *should* be the one to abort() if the
return code is non-zero. We can't do that because of a deficiency in 'anim',
which refuses to show called programs even though they are in the 'core' image.

>> The logic getting the name would best be in a called program.
>> Printing 'getmyname' on every report would not be informative.
>
>Then obviously, to me at least, this would _not_ be the 'best' if the
>result would be completely useless. So why did you put 'best' ?

I meant that if the called program getmyname got its own name, its output would
be uninformative. It should return the name of Main or Caller or, preferably, it
should walk back the whole call stack.

>The way that I get the program name available in each program in many
>systems is to pass a parameter block around on each CALL that includes
>the name used by the CALL. This, of course, is not a simple solution
>for a system that doesn't do that.

Our programs, developed on AS/400, keep an internal 'perform stack'. On entry to
every paragraph, they bump an index and insert the paragraph's name; on exit,
they set the index down by 1. A standard abend process in a copybook dumps the
'perform stack' to syserr. I was told by an AS/400 pro that the reason for this
is "The AS/400 debugger is so bad that programmers will do anything to avoid
using it." Out of curiosity, I looked at the debugger. It looks very much like
Micro Focus' anim. One can set breakpoints on lines of code, but not a data
elements, telling to stop when the element is touched or changed. Our most
common question is 'Show me when this field is changed to spaces'. Good
debuggers (possible oxymoron) such as MS DevStudio have it; bad ones don't.

[flame-bait alert] I don't use debuggers except as a last resort. They waste
more time than they save. If you can't read code and see what it does, you
shouldn't call yourself a programmer. Maybe you'd be happier as a tester. [end
of alert]

>The easiest way is probably to process all the source code to pick up
>the word after Program-id (or use the file name) and add a W-S item
>for all source files.

That's what he's gonna do, evinced by subsequent postings.



Relevant Pages

  • Re: report showing who logged in/out of nt 4 server
    ... permission to the log file (in the logon script solution, ... able to write to the log file, ... report any time, and you can use Excel to analyze the report. ...
    (comp.os.ms-windows.nt.admin.security)
  • I am not receiving server performance or usage reports
    ... SBS Backup Logs - This log file was not found. ... Click Change Server ... Status Report Settings on the Monitoring and Reporting ... There are no updates for this log file. ...
    (microsoft.public.windows.server.sbs)
  • I am not receiving server performance or usage reports in Outlook
    ... SBS Backup Logs - This log file was not found. ... Click Change Server ... Status Report Settings on the Monitoring and Reporting ... There are no updates for this log file. ...
    (microsoft.public.windows.server.general)
  • Re: Creating a log file (archive) of reports printed
    ... Create a table to hold details on the print events, with fields for report ... Set rst = CurrentDB.OpenRecordset ... Microsoft DAO 3.6 for Access2K or later). ... create a report which can print the log file but not change any of the ...
    (microsoft.public.access.formscoding)
  • SmtpMail.send() does _not_ cause button click to block . . .
    ... report to a number of email recipients. ... and then the debugger pops back into the code at ... that the execution of Sendis taking too long and somehow putting it ... this library will be driven from from a windows service ...
    (microsoft.public.dotnet.framework.windowsforms)