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



Robert,

You have two options.

1) You can use a global variable, and reset it before calling http_post_xml.

2) You can use the "user defined" field to pass a data structure containing the nextElement and gs1Attribute fields. This eliminates the need to use global variables, but is perhaps slightly more complex (or at least unfamiliar) for many RPGers.

I didn't mention this issue in my original response because you must already be handling the issue with regards to the gs1attribute array -- so I figured you would just do nextElement the same way.



On 10/14/2010 1:28 PM, Robert Rogerson wrote:
Scott,

I'm adding the xmlElement to the array within the Incoming (callback)
procedure. So if I used your suggestion

nextElement = nextElement + 1;
gs1Attribute(nextElement) = xmlElement;

would the value of nextElement not be reset for each call/element
processed?
I originally used a similiar approach where I coded variable nextElement as
Static which retained its value between calls.

The problem was that http_url_post_xml was being called multiple times in
the program and I had no way to reset the nextElement Statis variable. I
checked google and what I read recommended against the resetting of a Static
variable.

Not being able to use a Static variable and having a local
variable...duh...thanks Scott, sometimes just talking it out solves the
problem. I can define nextElement externally to Incoming and reset it it
prior to the first call.

Thanks Scott.

Robert Rogerson

On Thu, Oct 14, 2010 at 1:04 PM, Scott Klement<rpg400-l@xxxxxxxxxxxxxxxx>wrote:

I'm confused. Are you saying that you're going to use %lookup(*blanks)
instead of just adding 1 to a number?

i.e. you have a choice between this (as you suggested)

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

and this:

nextElement = nextElement + 1;
gs1Attribute(nextElement) = xmlElement;

So I find myself wondering why you'd ever use %lookup? Why search the
array when you can simply add 1 to a number? Not only is adding more
obvious to the person reading the code, it's also much more efficient
for the computer.

You make a big deal about the fact that you're running HTTPAPI's XML
parser, but as far as I can tell, that's completely irrelevant to your
question. Whether the input is coming from an XML parser or a database
file, or data entered by a user, or whatever... it really doesn't
matter. The point is that for every new piece of data you receive, you
want to advance to the next array element... a common scenario that
happens all the time in programming.

Or, perhaps I didn't understand the question...


On 10/13/2010 2:57 PM, Robert Rogerson 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.