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




That works. Thanks again Scott.


Date: Mon, 11 Feb 2008 12:21:30 -0600
From: rpg400-l@xxxxxxxxxxxxxxxx
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Calling Java from RPG

Hi Jon.

One of the methods that I am calling has a parameter of a data type
hashtable. How on earth do I create that in RPG? Data Structure?
Array?

The Hashtable parameter from your code snippet appears to be a Java
object. From RPG, that'd be data type O, with the CLASS keyword to
describe which Java class it refers to. You've already done this with
the String data type in some of the previous code examples in this
thread -- the only difference is that you'll want to use
java.util.Hashtable in the CLASS keyword instead of the java.lang.String
that you posted before.

Personally, I prefer to create a standalone variable like this:

D Hashtable s O CLASS(*JAVA
D :'java.util.Hashtable')

Then, in your prototype for the Java method, you can declare the
parameter as "like(Hashtable)". That way, you don't have to retype the
whole CLASS thinggy on your prototype.

You'll need to have a separate prototype for the Hashtable constructor,
and another prototype for the "put" method in order to duplicate the
code from the example you posted. The following code is untested, it's
just off the top of my head, hopefully it'll give you an idea of what to do:


D new_Hashtable pr like(Hashtable)
D extproc(*JAVA
D :'java.util.Hashtable'
D :*CONSTRUCTOR)

D Hashtable_put pr like(jObject)
D extproc(*JAVA
D :'java.util.Hashtable'
D :'put')
D key like(jObject) const
D value like(jObject) const

D settings s like(Hashtable)

/free

settings = new_Hashtable();
Hashtable_put( settings
: new_String('RealName')
: new_String('Jojn X. Smith') );
Hashtable_put( settings
: new_String('MaxAccountSize')
: new_String('100K') );

.
.
.

CLI_createAccount( new_String('john@xxxxxxxxxxx')
: settings
: *NULL
: FALSE );

Hope that makes sense.
--
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.


_________________________________________________________________
Helping your favorite cause is as easy as instant messaging. You IM, we give.
http://im.live.com/Messenger/IM/Home/?source=text_hotmail_join

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.