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



On 11/13/14 11:19 AM, Vernon Hamberg wrote:
Cool! Lunch for me, too, no nap, however!

Ok. Here's what I came up with; maybe somebody else will find it useful as well:

Assume you've prototyped all the relevant "UNIX-type" calls (Scott Klement wrote an excellent e-book on the subject of accessing the IFS from ILE RPG) and symbolic constants. And note that I've squeezed out the excess white space, in hopes that the line breaks won't be screwed up.

DSTMFNAME S 46
D M_WIDEOPEN C 511


D FD S 10I 0
D LINE S 512A
D MSG S 52A

C EVAL STMFNAME = '/QSYS.LIB/QTEMP.LIB/FOO.USRSPC'
C EVAL FD = open(STMFNAME:
C O_CREAT + O_WRONLY + O_TRUNC:
C M_WIDEOPEN)
C EVAL LINE = 'I like Spam!'
C CAT X'0D25':0 LINE
C CALLP write(FD: %ADDR(LINE): %LEN(%TRIMR(LINE)))
C CALLP close(FD)
C EVAL FD = open(STMFNAME:
C O_RDONLY)
C CLEAR LEN 5 0
C EVAL LEN = read(FD: %ADDR(LINE): 512)
C CALLP close(FD)
C EVAL FD = open(STMFNAME:
C O_CREAT + O_WRONLY + O_TRUNC:
C M_WIDEOPEN)
C EVAL LINE = %TRIM(LINE)
C + 'Model Railroading is Fun'
C CAT X'0D25':0 LINE
C CALLP write(FD: %ADDR(LINE): %LEN(%TRIMR(LINE)))
C CALLP close(FD)
C SETON LR

The first open/write/close creates a user space, FOO, in QTEMP, and puts "I like Spam!" and a line break into it.
The open/read/close then reads that entire user space into our LINE buffer.
The last open/write/close appends "Model Railroading is Fun" to the trimmed contents of the user space, and writes it back out.

This is a workaround: I found that for some reason, I couldn't just let the operating system append my write to the user space; it wouldn't work.

--
JHHL

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.