|
This seems to work (using both the supplied buffer and returned pointer): PROCESS NOMONOPRC. IDENTIFICATION DIVISION. PROGRAM-ID. GETPATH. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-AS400. OBJECT-COMPUTER. IBM-AS400. SPECIAL-NAMES. LINKAGE TYPE PROCEDURE FOR "Qp0lGetPathFromFileID". INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. WORKING-STORAGE SECTION. 01 FILE-ID PIC X(16) VALUE X'0000000000000001843E02D800004C26'. 01 PATH-BY-BUFFER PIC X(1024). 01 PATH-SIZE PIC S9(09) BINARY VALUE 1024. 01 PATH-POINTER POINTER. LINKAGE SECTION. 01 PATH-BY-POINTER PIC X(1024). PROCEDURE DIVISION. MAIN-LINE. CALL "Qp0lGetPathFromFileID" USING BY REFERENCE PATH-BY-BUFFER, BY VALUE PATH-SIZE, BY REFERENCE FILE-ID GIVING PATH-POINTER. IF PATH-POINTER = NULL DISPLAY "Error on file id access", STOP RUN. DISPLAY "Buffer: " PATH-BY-BUFFER. SET ADDRESS OF PATH-BY-POINTER TO PATH-POINTER. DISPLAY "Pointer: " PATH-BY-POINTER. STOP RUN. Bruce qsrvbas@netscape.n et (Tom Liotta) To: cobol400-l@midrange.com Sent by: cc: cobol400-l-admin@m Subject: API parm confusion idrange.com 06/13/2002 02:25 PM Please respond to cobol400-l I'm trying to call the Qp0lGetPathFromFileID API and having amazingly minimal success. I've tried every way I can think of and I get a null pointer every time. I even tried the example code from PID (or whatever they're called now) once I understood what it was attempting to do and after I'd modified it to be more correct. (And I e-mailed my changes back to them first, asking if they thought I made the right changes and they definitely agreed.) >From the UNIX-type APIs manual, the function prototype is: char *Qp0lGetPathFromFileID(char *buf, size_t size, Qp0lFID_t fileid); buf (Output) A pointer to a buffer that will be used to hold an absolute path name of the file identified by fileid. size (Input) The number of bytes in the buffer buf. fileid (Input) The identifier of the file whose path name is to be returned. That seems so simple... but a couple thing throw me. First, the full description of buf includes "The buffer must be large enough to contain the full path name including the terminating NULL character." Since I don't know what the path name is until after the API returns, how can I know how large buf should be? Second, buf is described as being both 'output' and 'pointer'. What does that mean? If I pass a pointer, is the API going to change it ('output')? If so, how do I associate it with the "buf" that I've somehow managed to make "...large enough to contain the full path name including the terminating NULL character"? The only thing that makes minimal sense is a LINKAGE item that I've set ADDRESS OF to null. Is there sense to be made of this in COBOL? Much TIA for any light that can be shed on this. Tom Liotta -- Tom Liotta The PowerTech Group, Inc. 19426 68th Avenue South Kent, WA 98032 Phone 253-872-7788 Fax 253-872-7904 http://www.powertechgroup.com __________________________________________________________________ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ _______________________________________________ This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list To post a message email: COBOL400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/cobol400-l or email: COBOL400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/cobol400-l.
As an Amazon Associate we earn from qualifying purchases.
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.