× 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 Tom,

I think your suggestion of using an aligned structure in the programs
on both sides of the CL should work.

You also wrote:
>BTW, I think Simon Coulter generally described a technique of handling
>pointers via CL in an IBM newsgroup quite a few years ago; maybe in
>ibm.software.os400.tips or ibm.os400.software.syspgmg. I believe his
>article is still in the newsgroup  via news.software.ibm.com. Also,
>maybe you can repeat this question on the MIDRANGE-L list to see if
>there are better answers.

Hey, not only does someone read what I write but they remember it too!

I've been following this thread (and its spurious diversions) thinking
I've written something about this before but i couldn't recall where.
I even searched the midrange archives.  Thanks to your prompting I
discovered I discussed this topic way back in 1995 when I was a
developer at IBM.  It was discussed in March '95 in the SYSPGMG forum
and again in October '95 in the APPLPGMG forum.  I decided to format
the information into an item in my personal FAQ.  Here it is:

       Can I force alignment for CL variables?

       Yes, you can, although there is very little reason to
       require alignment in CL since it is usually only
       important for pointer variables and CL does not
       support pointers.

       However, you may need to pass a pointer through a CL
       program so here are the instructions showing how you
       can force alignment in CL but it is messy and probably
       release dependant.

       Warning!
       The following is a solution to the problem but
       is not the best -- it is interesting though

       You need to compile the CL and generate an IRP listing
       (specify GENOPT(*LIST)). Find the variable you need to
       align in the IRP section. It will look something like:

            DCL DD &VAR CHAR(nnnn) AUTO POS(nnn) INIT(C' ')

       The POS value is the one you are interested in. You
       need to force it to start on a boundary appropriate
       for the data. If you are attempting to pass a pointer
       then it must be aligned on a 16-byte boundary. So if
       POS(139) is found you need to move it to POS(145) --
       the next boundary. You can do this by declaring a
       dummy variable that is both physically before and
       alphabetically prior to the &VAR declaration. So your
       CL would look something like:

            DCL &V@ *CHAR 6 /* Force 16-byte boundary */
            DCL &VAR *CHAR nnnn

       This will result in IRP like the following:

            DCL DD &V@ CHAR(00006) AUTO POS(000139) INIT(C' ')
            DCL DD &VAR CHAR(nnnn) AUTO POS(000145) INIT(C' ')

        As I said, messy, and prone to changing on a new
        release or when changes are made to the CL program.

        Update for ILE CL

        A cursory investigation indicates that the ILE CL
        compiler declares variables in the same order as
        specified in the CL program (i.e., it does not sort
        them like the non-ILE compiler) but it does ensure
        each variable is aligned on its natural boundary.

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.