choices = String[4] choices[2] = 'Dog' say choices[0] say choices[1] say choices[2] say choices[3] picked = 'Bug' check = 1 loop J=0 to 3 by 1 say picked say choices[J] say check if picked = choices[J] then check = 0 end /*===== Exception running class bug: java.lang.NullPointerException ===== --- in bug.main(String[]) [bug.nrx:7] 24 +++ if picked = choices[J] then check = 0 +++ ^ Processing of 'bug.nrx' complete*/ /*NetRexx portable processor, version NetRexx 3.01RC2, build 1-20110925-2337*/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Answer=tired. 'choices' is a Java String array. You cannot access
uninitialized slots as you could for an indexed Rexx variable. On 1/9/2012 2:00 AM, Jason Monroe Martin wrote: > > choices = String[4] > > choices[2] = 'Dog' > > say choices[0] > say choices[1] > say choices[2] > say choices[3] > > picked = 'Bug' > > check = 1 > > loop J=0 to 3 by 1 > say picked > say choices[J] > say check > if picked = choices[J] then check = 0 > end > > /*===== Exception running class bug: java.lang.NullPointerException ===== > --- in bug.main(String[]) [bug.nrx:7] > 24 +++ if picked = choices[J] then check = 0 > +++ ^ > Processing of 'bug.nrx' complete*/ > > /*NetRexx portable processor, version NetRexx 3.01RC2, build > 1-20110925-2337*/ > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > > _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Thanks, I read through the docs but missed it.
On 01/09/2012 05:27 AM, Kermit Kiser wrote: > Answer=tired. 'choices' is a Java String array. You cannot access > uninitialized slots as you could for an indexed Rexx variable. > > On 1/9/2012 2:00 AM, Jason Monroe Martin wrote: >> >> choices = String[4] >> >> choices[2] = 'Dog' >> >> say choices[0] >> say choices[1] >> say choices[2] >> say choices[3] >> >> picked = 'Bug' >> >> check = 1 >> >> loop J=0 to 3 by 1 >> say picked >> say choices[J] >> say check >> if picked = choices[J] then check = 0 >> end >> >> /*===== Exception running class bug: java.lang.NullPointerException >> ===== >> --- in bug.main(String[]) [bug.nrx:7] >> 24 +++ if picked = choices[J] then check = 0 >> +++ ^ >> Processing of 'bug.nrx' complete*/ >> >> /*NetRexx portable processor, version NetRexx 3.01RC2, build >> 1-20110925-2337*/ >> >> _______________________________________________ >> Ibm-netrexx mailing list >> [hidden email] >> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ >> >> >> > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by Kermit Kiser
Hi Kermit,
thanks for the clarification! To add my comment (as always :() BUT: Wouldn't it be NICE or recommended that this HUMAN ORIENTED NetRexx Langue does make a DEFAULT INITIALIZATION (by DEFAULT *or* by a speciasl OPTION) ??? Massa Thomas. ================================================================================ Am 09.01.2012 11:27, schrieb Kermit Kiser: > Answer=tired. 'choices' is a Java String array. You cannot access > uninitialized slots as you could for an indexed Rexx variable. > > On 1/9/2012 2:00 AM, Jason Monroe Martin wrote: >> >> choices = String[4] >> >> choices[2] = 'Dog' >> >> say choices[0] >> say choices[1] >> say choices[2] >> say choices[3] >> >> picked = 'Bug' >> >> check = 1 >> >> loop J=0 to 3 by 1 >> say picked >> say choices[J] >> say check >> if picked = choices[J] then check = 0 >> end >> >> /*===== Exception running class bug: java.lang.NullPointerException >> ===== >> --- in bug.main(String[]) [bug.nrx:7] >> 24 +++ if picked = choices[J] then check = 0 >> +++ ^ >> Processing of 'bug.nrx' complete*/ >> >> /*NetRexx portable processor, version NetRexx 3.01RC2, build >> 1-20110925-2337*/ >> >> _______________________________________________ >> Ibm-netrexx mailing list >> [hidden email] >> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ >> >> >> > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > -- Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org) _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Thomas Schneider, Vienna, Austria (Europe) :-)
www.thsitc.com www.db-123.com |
> Wouldn't it be NICE or recommended that this HUMAN ORIENTED NetRexx Langue does > make a DEFAULT INITIALIZATION (by DEFAULT *or* by a speciasl OPTION) ??? It does : choices = "uninitialized" choices[2] = 'Dog' say choices[0] say choices[1] say choices[2] say choices[3] picked = 'Bug' check = 1 loop J=0 to 3 by 1 say picked say choices[J] say check if picked = choices[J] then check = 0 end _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Great, thanks, didn't know ...
BUT: Does this also work for STRING arrays ?? As I see it, your sample would use (implicitely) a Rexx Stem. As I see it currently... Massa Thomas. ================================================================= Am 09.01.2012 16:14, schrieb Marc Remes: > >> Wouldn't it be NICE or recommended that this HUMAN ORIENTED NetRexx >> Langue does >> make a DEFAULT INITIALIZATION (by DEFAULT *or* by a speciasl OPTION) ??? > > > It does : > > choices = "uninitialized" > > choices[2] = 'Dog' > > say choices[0] > say choices[1] > say choices[2] > say choices[3] > > picked = 'Bug' > > check = 1 > > loop J=0 to 3 by 1 > say picked > say choices[J] > say check > if picked = choices[J] then check = 0 > end > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > -- Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org) _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Thomas Schneider, Vienna, Austria (Europe) :-)
www.thsitc.com www.db-123.com |
In reply to this post by Jason Monroe Martin
NetRexx defines the behavior of Rexx strings but the behavior of a Java
String object is defined by Java. A Java String which does not exist is not the same as a zero length Java String, and the default value for a String is a null pointer. It would not be appropriate for NetRexx to override that behavior, so it should NOT work. Certainly it is reasonable for a Java programmer (using NetRexx) to expect an uninitialized Java String to be a null pointer and distinct from a String containing zero characters since that is how Java defines it. A NetRexx programmer who is not familiar with the behavior of Java String objects might do well to avoid them. Rexx string behavior is defined by NetRexx, and Rexx strings are generally more "human oriented". Original Message: ----------------- From: Thomas Schneider [hidden email] Date: Mon, 09 Jan 2012 18:06:39 +0100 To: [hidden email] Subject: Re: [Ibm-netrexx] Bug or just tired? Great, thanks, didn't know ... BUT: Does this also work for STRING arrays ?? As I see it, your sample would use (implicitely) a Rexx Stem. As I see it currently... Massa Thomas. ================================================================= Am 09.01.2012 16:14, schrieb Marc Remes: > >> Wouldn't it be NICE or recommended that this HUMAN ORIENTED NetRexx >> Langue does >> make a DEFAULT INITIALIZATION (by DEFAULT *or* by a speciasl OPTION) ??? > > > It does : > > choices = "uninitialized" > > choices[2] = 'Dog' > > say choices[0] > say choices[1] > say choices[2] > say choices[3] > > picked = 'Bug' > > check = 1 > > loop J=0 to 3 by 1 > say picked > say choices[J] > say check > if picked = choices[J] then check = 0 > end > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > -- Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org) _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ -------------------------------------------------------------------- myhosting.com - Premium Microsoft® Windows® and Linux web and application hosting - http://link.myhosting.com/myhosting _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Bill,
I can't imagine improving upon this explanation; it should find its way into The NetRexx Tutorial. On Mon, Jan 9, 2012 at 5:43 PM, [hidden email] <[hidden email]> wrote: NetRexx defines the behavior of Rexx strings but the behavior of a Java _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On 01/09/2012 08:11 PM, George Hovey wrote:
> Java programmer I agree that Bill's explanation should be documented somewhere, I am not a Java programmer but I have spent time converting some of my code to pure Java. Just like the extra curly braces it's a pain to add all the extra code to ensure it's safe. I think NetRexx makes it so simple that when you start mixing it with Java itself you get confounded at how tedious it is. _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
> BUT: Does this also work for STRING arrays ??
From nrldef.pdf, in MFC's clear concise wording : << If a reference does not find a sub-value, then the non-indexed value of the variable is used. >> Note that NetRexx indexed strings are not only 'initialized' but are thus also protected from going 'out of range'. And - what I like the most - indexes do not need to be numbers. Marc _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |