|
<Joe> 2. There's a limit to the size of the data that can be held in an RPG variable. I should have thought of this right off the bat. I'll have to expand the API to use a user space instead. Scott, what do you think? This can't be all that hard, right? </Joe> I have an API that will take an IFS file and write it to a User Space if you would like that. I use it in conjunction with Scott's HTTPAPI's - I just pass the User Space pointer to Scott's API. I have included the code for that below along with a couple of supporting sub procs. I know this doesn't exactly apply to your situation, but when you get to the part of receiving XML into an "RPG Web Service" through Apache, I have written code that has gotten around the 65535 limitation (basically writing to a User Space). We had quite the long discussion about it on WEB400 about 9 months ago. If you can't find the thread I can post the code again. Aaron Bartell //-------------------------------------------------------------------------- ------------------ // @Name - // @Author - Aaron Bartell // @Description - Take the contents of the specified file and write it to the specified User // Space. The User Space must have already been created otherwise this will // error out. The amount of data written to the User Space will be returned. // @Usage - sizeOfUsrSpc = IFS_fileToUsrSpc('QTEMP': 'MYSPACE': '/myfolder/myfile.txt'); //-------------------------------------------------------------------------- ------------------ P IFS_fileToUsrSpc... P B Export D IFS_fileToUsrSpc... D PI 10I 0 D pUsrSpcLib 10A Value D pUsrSpcName 10A Value D pFile 256A Value D handle S 10I 0 D rc S 10I 0 D strPos S 10I 0 Inz(1) D data S 32767A /Free If IFS_fileExists(pFile); handle = IFS_openFile(pFile: 'RW C CP'); DoU handle < 0 or rc < 1; rc = read(handle: %Addr(data): %Size(data)); If rc > 0; UsrSpc_change(pUsrSpcLib: pUsrSpcName: strPos: rc: data: '0'); EndIf; strPos = strPos + rc; EndDo; EndIf; Return strPos; /End-Free P IFS_fileToUsrSpc... P E //-------------------------------------------------------------------------- ------------------ // @Name - // @Author - Aaron Bartell // @Description - Open a file in the IFS and receive back an handle to use with other IFS sub // procs. The flags are as follows: // R = Read // W = Write // A = Append // C = Create // CP = Code Page // T = Truncate upon opening // @Usage - handle = IFS_openFile('/mydir/myfile': 'RW CP'); //-------------------------------------------------------------------------- ------------------ P IFS_openFile... P B Export D IFS_openFile... D PI 10I 0 D pFile 256A Value D pFlags 15A Value D pCodePage 10I 0 Value Options(*NoPass) D rc S 10I 0 D handle S 10I 0 D IFSMODE C Const(511) D flags S 10I 0 D codePage S 10I 0 /Free If %Parms > 2; codePage = pCodePage; Else; codePage = CP_DOSASCII; EndIf; flags = 0; If %Scan('R': pFlags) > 0; flags = flags + O_RDONLY; EndIf; If %Scan('W': pFlags) > 0; flags = flags + O_WRONLY; EndIf; If %Scan('W': pFlags) > 0 and %Scan('R': pFlags) > 0; flags = O_RDWR; EndIf; If %Scan('A': pFlags) > 0; flags = flags + O_APPEND; EndIf; If %Scan('C': pFlags) > 0; flags = flags + O_CREAT; If %Scan('T': pFlags) > 0; flags = flags + O_TRUNC; EndIf; EndIf; If %Scan('CP': pFlags) > 0; flags = flags + O_CODEPAGE; EndIf; handle = open(%Trim(pFile): flags: IFSMODE: codePage); If handle < 0; Return handle; EndIf; rc = close(handle); // Take the necessary tags back out for the second open If %Scan('C': pFlags) > 0; flags = flags - O_CREAT; If %Scan('T': pFlags) > 0; flags = flags - O_TRUNC; EndIf; EndIf; If %Scan('CP': pFlags) > 0; flags = flags - O_CODEPAGE; EndIf; Return open(%Trim(pFile): flags + O_TEXTDATA: IFSMODE: codePage); /End-Free P IFS_openFile... P E //-------------------------------------------------------------------------- ------------------ // @Name - // @Author - Aaron Bartell // @Description - Check to see if the specified file exists in the IFS. // @Usage - boolean = IFS_fileExists('/mydir/myfile.txt'); //-------------------------------------------------------------------------- ------------------ P IFS_fileExists... P B Export D IFS_fileExists... D PI N D pFile 256A Value /Free If access(%TrimR(pFile): F_OK) < 0; Return *Off; Else; Return *On; EndIf; /End-Free P IFS_fileExists... P E
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.