× 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'm not sure exactly what Java function the compiler "encapsulates" when
constructing strings but it is posisble in utilzies the JNI "NewString"
function.  This would enable the compiler to construct the string based
on the RPG prototype.

The prototype for NewString looks like the following:

D*--------------------------------------------------------------------- 
D*      jstring (*NewString)                                            
D*        (JNIEnv *env, const jchar *unicode, jsize len);               
D*--------------------------------------------------------------------- 
D NewString       PR                  LIKE(jstring)                     
D                                     EXTPROC(*CWIDEN                   
D                                     : JNINativeInterface.             
D                                       NewString_P)                    
D env                                 LIKE(JNIEnv_P) VALUE              
D unicode                             LIKE(jchar) CONST                 
D len                                 LIKE(jsize) VALUE

While it is entirely conceivable that the compiler generates the required
code to "trim" your string dynamically, you could also use BIF's to determine
your exact requirements THEN use JNI to construct your string.  It is the
"long way" around but probably addresses your storage concerns.

Michael Rooney
Citigroup International

                    

-----Original Message-----
From: rpg400-l-bounces+michael.p.rooney=citigroup.com@xxxxxxxxxxxx
[mailto:rpg400-l-bounces+michael.p.rooney=citigroup.com@xxxxxxxxxxxx]On
Behalf Of Bob Cozzi
Sent: Tuesday, June 01, 2004 8:30 AM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: Prototyping a constructor of java String class


But if the temp that is generated is also VARYING, wouldn't that offset the
value by two bytes in the Java method; hence throwing it off?
-Bob

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Scott Klement
Sent: Tuesday, June 01, 2004 2:50 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Prototyping a constructor of java String class


Hi Otto,

> D String...
> d                 PR              O   extproc( *JAVA
> d                                            : 'java.lang.String'
> d                                            : *CONSTRUCTOR)
> d  chars                     65535A   varying
> d                                     options(*VARSIZE)
> d                                     const
[SNIP]
> If I understand RPG Reference manual correctly RPG compilator generates
> a temporary for the literal that further passes to the method. What is
> the format of the temporary? Is the format 65535A (and varying ?) which
> would be rather unpleasant of the compiler, or 5A (and varying ?) which
> would be nice I suppose ??

Because yu included "options(*varsize)" it should generate a "5A varying"
temp field.  If you had excluded the "options(*varsize)" it would've used
65535A instead.  At least, that's how I understand it.

Unless the fact that you're calling Java causes it to be treated
differently?  But I doubt it.

Another copy of the data is probably created in ASCII in order to pass it
off to Java -- but that data is most likely also going to be a 5
characters long.

> I am just deducing using information in RPG manuals; maybe I got lost in
> my deductions. The prototypes I found on the web vary in both the length
> of char parameter and the applied keywords.

I don't think the actual JVM knows what length you put on your prototype,
so I don't think it matters much, as long as you give the maximum length
that you're intending to use.

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



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