× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello Mike,

You wrote:
>First,   QAHSTDS is defined in my GEMAIL procedure.  I do realize that's
>what the compiler is fussing about, but I don't want it to.  I'm just
>trying to compile GIFPRINT.

Data defined in a procedure is local to that procedure i.e., not visible
outside the procedure, therefore the compiler cannot 'see' the definition
in the procedure when it is parsing the prototype.  More gory detail
below.

>The GEMAIL procedure is the last one that I added.  I then added GTXTMSG
>and got the same error I get on GIFPRINT, so I was just backing up,
>trying to get GIFPRINT to compile again.

This doesn't make sense.  There is nothing wrong with the prototype for
Gifprint nor Gtxtmsg.  The compiler should not be generating errors for
those prototypes since both the parameter and return value are explicitly
defined.  The only prototype in your sample code that can possibly have a
problem is Gemail due to the LIKE definition for the parameter.

Other problems may surface when you try to compile code that uses these
prototypes (e.g., pValidCat will never be included unless you /define
CopyPValidCat).

>So, I guess that's why I'm trying to use the /define stuff.

It won't help, unless you use /define to remove the definitions of
failing prototypes completely from your code.  You will also have to use
/define to remove the procedure itself since it won't compile without the
prototype.

>Second.  Your correct on this.  I just copied this from an example I
>found (not that I really understood it) so this was just a typo.

(The quality of English on this list is appalling  "Your correct on this"
is syntactically incorrect.  It should be "You're correct on this".
Jeez)

The real problem is the lack of understanding.  I see far too much of
this going on where people simply copy something that works without
understanding what all the bits do and then run into trouble when they
change something.  It used to be subfiles (and probably still is), now we
see it with procedures and binding and activation groups.  It is your job
to understand this stuff!

>Third.  I don't know why all this crap.  Again.  Just copied from an
>example I found somewhere.

See my previous comments.

>Basically I had this all working until I added Gtxtmsg.  Now it doesn't
>like QAHSTDS.  So I want to prevent bringing in the prototype for GEMAIL
>when I don't need to.

I do not see how you could ever have successfully compiled PROCS after
you added the prototype for Gemail because the /define GEmail statement
would cause the prototype for Gemail to be included and the LIKE(QAHSTDS)
definition cannot be resolved (unless you removed the /define GEmail
statement and had similar conditional compile statements around the
Gemail procedure source, or coded a /undefine GEmail somewhere after this
in your code).  It has nothing to do with adding Gtxtmsg.

>Can you explain this to a simple minded dolt like me.

Now that is a difficult task :)   Thinking you are a 'simple minded dolt'
becomes a self-fullfilling prophecy.  Stop doing that!  If you really are
that stupid you then you are stealing from your employer.

Now to take it slowly, and answer your original question in detail in
light of the fact that you are trying to get the Gifprint procedure to
compile again.  Let's presume your copy member is called PROTOS.  I also
presume all procedures are in the same source member, which we'll call
PROCS, otherwise none of the /define stuff makes much sense.

(I wonder if you are trying to use a single prototype member with
multiple procedure source members (i.e., the procedure implementation is
done using a separate source member for each procedure) in which case you
are quite likely to have difficulties.)

Here is PROTOS with the spelling mistake corrected.

 /If Not Defined( CopyingPrototypes )
 /Define PValidCat
 /Define PUsrSec
 /Define GIfPrint
 /Define GEmail
 /Define GTxtMsg
 /Endif

  /If Defined( PValidCat )
 * __________________________________________________
 * pValidCat - validate the category against the category file(QACAT)
 * --------------------------------------------------
D pValidCat       PR             1A
D Incat                          3A   VALUE
 /Endif

/If Defined( PUserSec )
 * __________________________________________________
 * PUSRSEC   - verify user security to QA System
 * --------------------------------------------------
D PUSRSEC         PR             5    DIM(10)
D INUSER                        10
 /Endif


  /If Defined( GifPrint )
  * __________________________________________________
  * Gifprint  - determine if the edit should print
  * --------------------------------------------------
 D Gifprint        PR             1
 D INEDIT                        10
  /Endif


 /If Defined( GEmail )
 * __________________________________________________
 * GEmail    - Send Email if necessary
 * --------------------------------------------------
D Gemail          PR
D QAHSTDSP                            LIKE(QAHSTDS)
 /Endif


/If Defined( GTxtMsg)
 * __________________________________________________
 * Gtxtmsg   - retrieve text message for history file
 * --------------------------------------------------
D Gtxtmsg         PR            50
D INEDIT                        10
 /Endif

If the PROCS source simply codes:
        /copy protos
then all prototypes are included.  This is because of the statements:
 /If Not Defined( CopyingPrototypes )
 /Define PValidCat
 /Define PUsrSec
 /Define GIfPrint
 /Define GEmail
 /Define GTxtMsg
 /Endif
which first checks for the existence of a /define called
CopyingPrototypes and since it is not found, proceeds to /define the
values needed for including the prototypes.  This idea is a bit
arse-backwards but that's what it is doing.  The nett is that when
compiling the PROCS source, all the prototypes are included.  All the PR
definitions are needed because the PI definitions are all in the same
source.and the compiler will not compile a PI without a corresponding PR.

In the source that will call the procedures you are expected to code:
        /define CopyingPrototypes
to stop all of the prototypes being included (now do you see why I think
this is arse-backwards?) and then code /define statements for the
specific procedures you want to use.  For example:
        /define CopyingPrototypes
        /define Gemail
        /define Gtxtmsg
       C                callp   gtxtmsg()
       C                callp   gemail()

Here, too, the LIKE(QAHSTDS) definition cannot be resolved and the
compile will fail.  This can be resolved by:

        Include the definiton of QAHSTDS in the PROTOS copy member.  This
is not as silly as it first sounds because the PROTOS member is actually
capable of holding more than just prototypes and I think it also should
be used for exposed type definitions such as QAHSTDS as well as constant
values used by procedure parameters.  For example, both pValidCat and
Gifprint return a 1-byte flag indicating if something is true.  Since
this flag is probably a boolean value you should have named constants to
describe the result (actually they should probably be indicator data
types rather than character but you that's a discussion we can leave for
later).  So we code constants for the return values and add them to the
PROTOS member.

      D $TRUE           C                       CONST('1')
      D $FALSE          C                       CONST('0')
or if you prefer
      D $YES            C                       CONST('Y')
      D $NO             C                       CONST('N')

Then we can code

      C                 if      ( Gifprint(anEdit) = $TRUE )
or
      C                 if      ( pValidCat(aCategory) = $YES )

You would also include a 'type definition' for QAHSTDS so it is available
to all callers.  (I wish RPG would give us true typedef support -- COBOL
has it so why don't we????).

      D QAHSTDS         DS
      D  define subfields here

Now the LIKE(QAHSTDS) on the prototype can be resolved because QAHSTDS is
defined at the global level and so are the prototypes.

You can still create a local copy in the procedure if required.  However,
you are likely to be bitten by a parsing error in the RPG compiler where
global definitions are not known to the compiler when it is parsing
procedures because it hasn't read them yet.  I believe this nasty
oversight has been corrected at VRM510.

Is that clearer?  Do you understand what is going on in the example code
you provided?  If it is not clear then please ask specific questions and
we'll try to answer them.

For what is it worth, without getting into the merits of using CONST on
all input parameters (and avoiding VALUE), here is how I would code your
example copy member:

/if not defined( some-unique-id )
/define some-unique-id
 * The above is simply to avoid including this member more than once in
 * the same source member.  some-unique-id could be the member name.

D $TRUE           C                   CONST('1')
D $FALSE          C                   CONST('0')
D $YES            C                   CONST('Y')
D $NO             C                   CONST('N')

D QAHSTDS         DS
D  define subfields here

 * __________________________________________________
 * pValidCat - validate the category against the category file(QACAT)
 * --------------------------------------------------
D pValidCat       PR             1A
D Incat                          3A   VALUE

 * __________________________________________________
 * PUSRSEC   - verify user security to QA System
 * --------------------------------------------------
D PUSRSEC         PR             5    DIM(10)
D INUSER                        10

  * __________________________________________________
  * Gifprint  - determine if the edit should print
  * --------------------------------------------------
 D Gifprint        PR             1
 D INEDIT                        10

 * __________________________________________________
 * GEmail    - Send Email if necessary
 * --------------------------------------------------
D Gemail          PR
D QAHSTDSP                            LIKE(QAHSTDS)

 * __________________________________________________
 * Gtxtmsg   - retrieve text message for history file
 * --------------------------------------------------
D Gtxtmsg         PR            50
D INEDIT                        10

/endif

Notice that I've removed all the crap /defines.

Then in the PROCS member I would simply code
        /copy protos

and in the calling source I would simply code
        /copy protos

This is much easier and more obvious than what you are currently working
with.

Regards,
Simon Coulter.

--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists
   http://www.flybynight.com.au/

   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.