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



Have you looked at using a null terminated string? The %str() bif makes
them very easy to use and they can be any length between 1 and 65534
characters long. I don't know what your API is doing or what it is
written in, but to quote the RPG manual "%STR is used to create or use
null-terminated character strings, which are very
commonly used in C and C++ applications." so it might be a good fit for
your API. All it requires is a pointer pointing to a big enough area of
allocated memory.

Joe Lee

>>> davem@xxxxxxxx 12/16/2004 16:28:59 >>>
Thanks Bob,

This data structure is one of many that can be filled in by an API.  I

guess I didn't previously understand about no storage being allocated
when 
using BASED.

Let me rephrase your answer.

If I declare TextData as a 32K variable then assign a value to the
textPtr, 
as long as I don't excede the textLen (as returned by the API) when I 
reference TextData, I should be okay. Any TextData characters beyond
the 
TextLen specified can be anything in that happens to be in that area of

memory, but I do not have a full 32K field allocated.  Do I have this
right?

I thought about a VARYING field, but since this is a structure returned
by 
an API, I didn't think the variable field would be populated correctly
by 
the API (it would return data in the two length bytes).

At 03:40 PM 12/16/2004, you wrote:
>Are you trying to simulate a VARYING field? Looks like it to me.
>
>D TextDS    DS                       BASED(textPtr)
>D  TextLen                     5I 0
>D  TextData                32766A
>
>
>If you use BASED, no storage is allocated for TEXTDS, so it does not
matter
>if you declare TEXTDATA as a 32K variable. That way SUBST and other
>operation will work the way you want.
>
>If you want to NOT use this suggestion, and you simply want to copy
from
>that memory location, use this:
>
>   Eval     memcpy(%addr(target) : textPtr + 2: some-length-here )
>
>
>
>But why not just use a VARYING field?

Dave Murvin
DRM Enterprises, Inc.


-- 
This is the RPG programming on the AS400 / 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.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.