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





HashMap reportParameters = new HashMap();
reportParameters.put("selectName", "BALL");

I understand it to mean that I create a new HashMap object called "reportParameters". It is basically a container into which I can put key/value pairs. So, after creating a new "empty" object, I add the key/value pair I want to assign using "put".

Correct. That's what it does. However, consider the following Java code:

Consider this Java code:

HashMap reportParameters = new HashMap();
Object retval = reportParameters.put("selectName", "BALL");

If you displayed the value of 'retval' after running this code, you'd find that it's set to null, because that's what the 'put' method is returning... it's returning null. For some reason you seem to want to blame the RPG prototypes for this behavior, but it's not the RPG prototypes fault, because the Java code has the same exact result. The only difference was, you weren't checking the return value from the put method (until I added the code, above)


The assignment of the key/value pairs is what I am after so this

lReParam = new_jMap();


...and it does.


is supposed to create the object, and this code:

lkey = new_String('selectName');
lvalue = new_String('BALL');
lReParam = rre_jMap_put(lReParam:lkey:lvalue);

Okay, let's modify your RPG code slightly to look like this:

lkey = new_String('selectName');
lvalue = new_String('BALL');
retval = rre_jMap_put(lReParam:lkey:lvalue);

Assuming that retval is defined as like(jObject) this code does exactly the same thing as the Java code, above. If you check the value of 'retval' you'll see that it's set to *NULL.

What I didn't notice when I read your previous message (but I see it now) is that you're replaces lReParam with the return value from the put method. i.e. you're doing this:

lReParam = rre_jMap_put(lReParam:lkey:lvalue);

This will, quite correctly, assign the key & value to the hash map. However, and here's the problem, it then sets the hashmap object to the return value of the put method, which will be *NULL -- so you're effectively discarding the hashmap.

If you wanted to do the same thing in Java, you'd be doing this:

HashMap lReParam = new HashMap();
lReParam = lReParam.put("selectName", "BALL");

See what I mean? You're replacing the value of lReParam with whatever the 'put' method returns. The put method will return the prior value of "selectName", but since there was no prior value, it'll return null.

Effectively, you're wiping out the value of lReParam.

If you want your RPG code to work like the Java code, do this instead:

lReParam = new_jMap();
lkey = new_String('selectName');
lvalue = new_String('BALL');
rre_jMap_put(lReParam:lkey:lvalue);

You don't want to assign the return value from rre_jMap_put to lReParam, because if you do that, you're setting lReParam to null.

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.