× 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 04/01/2006, at 8:28 AM, brian wrote:

I want to make a procedure that operates on strings of (practically)
arbitrary size, so I wrote it to accept a pointer and a 10u 0. I'll call
it like p(%addr(string) : %size(string)).

What I don't understand is how, inside the procedure, to make RPG
understand that the pointer is a string pointer so that I can do %subst
and all the other usual string operations on the argument.

Depends on what you mean by "string pointer".

If you mean a pointer to a C-style null-terminated string then just prototype and use the C string functions. Or use the %STR function to copy the data to an RPG character variable.

If you mean an RPG_style character variable then you have to provide the compiler with a suitable view of whatever storage the pointer references. Use a based variable to accomplish this.

D procedureThatOperatesOnStringsOfPracticallyArbitrarySize...
D                           PI
D  input                                    *        VALUE
D  length                                 10U 0      VALUE

D  inputView                S          65535         BASED(input)

The body of the procedure would operate on inputView.

In all cases when you use an RPG character variable you are limited to 32K or 64K depending on compiler release so if your arbitrary strings are longer than this then you'll need to shift the variable over the data in 32K or 64K windows.

If your arbitrary length strings fit within the limits of an RPG character variable then it's probably easier to use a VARYING length character variable.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.