× 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.



Right, I know, I use it all the time in xTools...
Here's my prototype:
     D Qp0lGetAttr     PR            10I 0 ExtProc('Qp0lGetAttr')
     D   szPath                            LikeDS(qlg_Path_Name_T)
     D   nAttribs                          LikeDS(ga_Attr)
     D   szBuffer                          Like(ga_RtnData)
     D   nBuffLen                    10U 0 Value
     D   nBytesNeeded                10U 0
     D   nBytesRtn                   10U 0
     D   nSymbLink                   10U 0 Value Options(*NOPASS)

Seems to work for me.

-Bob Cozzi
www.RPGxTools.com
RPG xTools - Enjoy programming again.


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of darren@xxxxxxxxx
Sent: Friday, January 27, 2006 10:48 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: CONST vs. VALUE on a pointer parameter

This 'Qp0lGetAttr' API was a little different in that it does not require
*NULL terminated strings.  Instead you pass a datastructure that tells how
big of a buffer you're passing.  I did experience all of the fun you listed
below when I first tried to implement lstat64().  After all that, I figured
out that this API gives you all the date information, except for creation
date.


Thanks everyone for your help.  I'm a little wiser on C API calling now.




                                                                           
             "Bob Cozzi"                                                   
             <cozzi@xxxxxxxxx>                                             
             Sent by:                                                   To 
             rpg400-l-bounces@         "'RPG programming on the AS400 /    
             midrange.com              iSeries'" <rpg400-l@xxxxxxxxxxxx>   
                                                                        cc 
                                                                           
             01/27/2006 11:26                                       Fax to 
             AM                                                            
                                                                   Subject 
                                       RE: CONST vs. VALUE on a pointer    
             Please respond to         parameter                           
              RPG programming                                              
              on the AS400 /                                               
                  iSeries                                                  
             <rpg400-l@midrang                                             
                  e.com>                                                   
                                                                           
                                                                           




You're calling a C function. In C, char* or "const char*" are similar to
passing this:
     D  path                        640A

The CONST keyword means nothing at this point.

However, in your case, it is expecting a null-terminated string. RPG IV
automatically creates these strings when you add OPTIONS(*STRING) to a
pointer parameter. So first we have to convert the above to a pointer, as
follows:
     D  path                           *

This is okay if we pass %addr(myField), but if we only pass this, then we
also need to include the null terminator, X'00'. Not very pretty, so we let
RPG do it for us.
     D  path                           *  Options(*STRING)

Hmmm... something's not working, what is it? Well in the called procedure
it
is looking at the address of the value passed in, and taking the
information
in that address, as data. Unfortunately since RPG passes-by-reference, the
data the called routine is looking at is actually the pointer, not the
value
we passed to it.
So we need to make it more C-friendly, by passing the address "by value",
     D  path                           *  VALUE Options(*STRING)

Now suddenly it works, but we still have an issue.
When we call this procedure, we should use %trimR(myPath) to delete any
trailing blanks in the path name.
What if we used this instead?
     D  path                           *  Const Options(*STRING)
It is these same as without the CONST keyword, pass-by-reference and you'll
get crap.

-Bob Cozzi
www.RPGxTools.com
RPG xTools - Enjoy programming again.


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of darren@xxxxxxxxx
Sent: Friday, January 27, 2006 9:09 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: CONST vs. VALUE on a pointer parameter


I attempted to call the Qp0lGetAttr API to get the creation date of a file
in the IFS.  I used the following prototype.

     D Qp0lGetAttr     PR            10I 0 ExtProc('Qp0lGetAttr')
     D  path                           *   Const
     D  AttArrPtr                      *   Const
     D  BuffPtr                        *   Const
     D  BuffLenSent                  10U 0 Const
     D  BuffLenNeed                  10U 0
     D  BuffLenRet                   10U 0
     D  FollowLink                   10U 0 Value


The above did not work, apparently because I had used Const.  The program
compiles fine both ways, but the API returns a -1 indicating that some kind
of error occurred.  I can toggle the 'path' parameter from Value to Const
and get it to fail, with everything else as shown below.  My reason for
using Const was to document that the variable being pointed to was an Input
only variable per the API's specs.  Can someone in the know, educate me as
to the different between Const and Value in this case?

     D Qp0lGetAttr     PR            10I 0 ExtProc('Qp0lGetAttr')
     D  path                           *   Value
     D  AttArrPtr                      *   Value
     D  BuffPtr                        *   Value
     D  BuffLenSent                  10U 0 Value
     D  BuffLenNeed                  10U 0
     D  BuffLenRet                   10U 0
     D  FollowLink                   10U 0 Value

--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.