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



I use a dynamic array with a two integer numbers. Current count and
allocated. Each time I add another value I increment current count and check
to see if bigger than allocated. If yes, allocate or reallocate the array.
Each time before I call, I deallocated the memory if needed from previous
time and clear counters.

d ElementArray...
d ds Qualified
d Dim(32767)
d Based(ptrElementArrary)
d // Your fields.

d cInitialNumberOfEntries...
d c 10
d cAdditionalNumberOfEntries...
d c 5
d CurrentCount...
d s 10i 0
d AllocatedCount...
d s 10i o0

CurrentCount += 1;
If CurrentCount > AllocatedCount;
If AllocateCount = 0;
AllocatedCount = cInitialNumberOfEntries;
ptrElementArray = %Alloc(%Size(ElementArray) * AllocatedCount);
Else;
AllocatedCount += cAdditionalNumberOfEntries;
ptrElementArray = %Realloc(ptrElementArray:%Size(ElementArray) *
AllocatedCount);
EndIf;
EndIf;
// Code to load array.

On Wed, Oct 13, 2010 at 1:57 PM, Robert Rogerson <rogersonra@xxxxxxxxx>wrote:

Hi All,

I am using Scott's HTTPAPI program to consume a web service. I consume the
web service with
rc = http_url_post_xml(
urlEndPoint
: %addr(SOAP) + 2
: %len(SOAP)
: *NULL
: %paddr(Incoming)
: *NULL
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml'
: SoapAction);

Procedure Incoming is called for each element of the returned XML document.

I have created an array
d gs1Attribute s 256a varying Dim(600)
which I wish to populate with the (XML) element Incoming is currently
processing.

My question is how is the best way to populate the next element in the
array
when Incoming is called.

Before calling http_url_post_xml I Clear gs1Attribute so all elements are
blank,
Then on each call of Incoming I want to add the (XML) element(attribute) to
the next element in the array.

The way in which I thought to do this was

nextElement = %Lookup(*blanks : gs1Attribute);
gs1Attribute(nextElement) = xmlElement;

Can anyone suggest an alternative way of doing this or is this a good
method?

Thanks,

Robert Rogerson
--
This is the RPG programming on the IBM i / System i (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 ...

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.