Just looking at the code, the procedure is getting the data passed into the variable pText, while the function is writing wkText and the incoming data is not being set into wkText.
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Roger Harman
Sent: Thursday, May 25, 2017 5:10 PM
To: 'RPG programming on the IBM i (AS/400 and iSeries)' <rpg400-l@xxxxxxxxxxxx>
Subject: fputs() in RPGLE
I am having a brain freeze on using fputs() in an RPGLE program. It needs to be in old-style /free format for another user.
I have this and it is showing 18 bytes written (retBytes) but the IFS file (in /tmp) is zero bytes - checked with Windows Explorer and wrklnk.
I must be missing something very obvious. Thanks.
// call proc to call _C_IFS_fopen mode 'w'
TextData = 'One Line Of Data' ;
TextBytes = IFS_Write(TextData : TextFileHandle);
// invoke proc to call _C_IFS_fclose
**======================================================================
**
**
**
**======================================================================
p IFS_Write b
d IFS_Write pi 10i 0
d pText 32767a const
d pFileHandle *
**----------
d Sys_IFS_Write PR 10i 0 extproc('_C_IFS_fputs')
d pString * value options(*string)
d pHandle * value
**----------
d retBytes s 10i 0 inz
d wkText s 32767a inz
d CRLF s 2a inz(x'0D25')
**----------
wkText = %trim(pText) + CRLF + x'00';
retBytes = Sys_IFS_Write(%addr(wkText) : pFileHandle);
if retBytes = 0;
dsply ('fputs error - Errno = CPE' + %editc(getErrno() : 'Z'));
endif;
return retBytes;
p IFS_Write e
Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power
--
This is the RPG programming on the IBM i (AS/400 and 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.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
HCSC Company Disclaimer
The information contained in this communication is confidential, private,
proprietary, or otherwise privileged and is intended only for the use of
the addressee. Unauthorized use, disclosure, distribution or copying is
strictly prohibited and may be unlawful. If you have received this
communication in error, please notify the sender immediately at
(312)653-6000 in Illinois; (800) 447-7828 in Montana;
(800)835-8699 in New Mexico; (918)560-3500 in Oklahoma;
or (972)766-6900 in Texas.
As an Amazon Associate we earn from qualifying purchases.