|
I'm trying to immerse myself into the RPG/Java interface. I'm trying to use an example from the ILE RPG Programmer's Guide as a vehicle for flexing some code to understand how this functionality is implemented. On page 165 of the above manual is some example code (P165 Figure 77) depicting a simple interface to the trim method of the java.lang.String class. I could not get the original version to compile until I added the class keyword to the trimString prototype. The compiler was giving me the following message: RNF3951 30 26 002600 The CLASS keyword is required with datatype O. The code in bold/italics (between lines 28-29) below is what I added and got the program to compile - and run. Did I do the right thing? Should the manual be updated? I can't understand why the class declaration is required as a separate keyword as it is already defined as one of the method parameters anyway. Is there a reason that the two might ever be different? 1 * 2 * Define field for string object 3 * ------------------------------------------------------------------------ ---------------- 4 d str s o class(*JAVA : 'java.lang.string') 5 * 6 * Prototype the constructor. 7 * Constructor expects a byte array. 8 * ------------------------------------------------------------------------ ---------------- 9 d makestring PR o extproc( *JAVA 10 d : 'java.lang.String' 11 d : *CONSTRUCTOR) 12 d class( *java 13 d : 'java.lang.String') 14 d parm 10A 15 * 16 * Prototype the string method getBytes which converts a string to a byte array. 17 * we can then store the byte array in an alpha field. 18 * ------------------------------------------------------------------------ ---------------- 19 d getBytes PR 10A EXTPROC( *JAVA 20 d : 'java.lang.String' 21 d : 'getBytes') VARYING 22 * 23 * Prototype the string method trim. It doesn't take any parameters, but since it is not a 24 * static method, it must be called using a string object. 25 * ------------------------------------------------------------------------ --------------- 26 d trimString PR O EXTPROC( *JAVA 27 d : 'java.lang.String' 28 d : 'trim') d class( *java d : 'java.lang.String') 29 * 30 d fld S 10A INZ(' hello ') VARYING 31 * 32 c eval str= makestring(fld) 33 * 34 * Trim the string. 35 * ------------------------------------------------------------------------ --------------- 36 c eval str= trimstring(str) 37 * 38 * Convert the string back into a byte array & store it in fld. 39 * ------------------------------------------------------------------------ --------------- 40 c eval fld= getBytes(str) 41 * 42 c seton lr---- Thanks again. ********************************************************************************************************* This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, any use, disclosure or copying of this message is unauthorised. If you have received this message in error, please reply using the sender's email address. This footnote confirms that this email message has been scanned for computer viruses. EIG-Ansvar Limited does not accept liability for any loss or damage, whether caused by our own negligence or not, that results from a computer virus or defect in the transmission of this email or any attached file. EIG-Ansvar Limited - Australia (A.B.N. 21 007 216 506) Email : insure@xxxxxxxxxxxxxxxx Eig-Ansvar Limited - New Zealand Email : insure@xxxxxxxxxxxxxxxx *********************************************************************************************************
As an Amazon Associate we earn from qualifying purchases.
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.