Hello NetRexx experts :-)
Is there a Rexx builtin method to decide *at run-time* whether a Rexx String is an ordinary String or an INDEXED string? Tom. -- Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
> Is there a Rexx builtin method to decide *at run-time* > whether a Rexx String is an ordinary String or an INDEXED string? Not really -- because all Rexx objects (strings) can be indexed. However, I suspect that looking at the owner or parent of a Rexx object might tell you if it is part of a collection of strings -- but whether that collection is itself a property of a Rexx object might be needed, too. I forget the implementation details ... But possibly what you want is the exists() BIM? This tells you if a given index has been used. Mike _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Hmm, how about looping some variable over the Rexx instance. Its final value should tell you if there are any indexed sub-strings.
Not tested and probably not very efficient but it might be worth a try. - Saludos / Kind regards, David Requena -----Original Message----- From: "Mike Cowlishaw" <[hidden email]> Sender: [hidden email] Date: Tue, 24 Aug 2010 10:56:27 To: <[hidden email]>; 'IBM Netrexx'<[hidden email]> Reply-To: IBM Netrexx <[hidden email]> Subject: RE: [Ibm-netrexx] Rexx Strings vs. Rexx Indexed strings > Is there a Rexx builtin method to decide *at run-time* > whether a Rexx String is an ordinary String or an INDEXED string? Not really -- because all Rexx objects (strings) can be indexed. However, I suspect that looking at the owner or parent of a Rexx object might tell you if it is part of a collection of strings -- but whether that collection is itself a property of a Rexx object might be needed, too. I forget the implementation details ... But possibly what you want is the exists() BIM? This tells you if a given index has been used. Mike _______________________________________________ Ibm-netrexx mailing list [hidden email] _______________________________________________ Ibm-netrexx mailing list [hidden email] |
> Hmm, how about looping some variable over the Rexx instance. > Its final value should tell you if there are any indexed sub-strings. > > Not tested and probably not very efficient but it might be > worth a try. Yes that would work .. and could be used to count the number of indexed strings. Expensive for large sets of indices because it will always generate the full set. Just testing whether there are any there or not would be much simpler (but would need a new one-line method). But I'm not sure what that would be useful for? Mike _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Hi Mike & David,
first I did reply to your first reply without reading the other msgs... Second, I am just implementing some methods which will accept either 'standard Rexx' strings *OR* indexed Rexx Strings as the arguments (for instance TITLE, PRINT, DISPLAY etc). I want to have them implicitely looping when the arguments are Indexed Strings. I first tried a lot to define a class RexxStem extends Rexx by my own (you might remember the discussion years ago), but then I cannot use the brackets anymore ... Issue closed for the minute. hope I didn't disturbe anybody... Thomas. ====================================================================== Am 24.08.2010 12:54, schrieb Mike Cowlishaw: > >> Hmm, how about looping some variable over the Rexx instance. >> Its final value should tell you if there are any indexed sub-strings. >> >> Not tested and probably not very efficient but it might be >> worth a try. > Yes that would work .. and could be used to count the number of indexed > strings. Expensive for large sets of indices because it will always > generate the full set. > > Just testing whether there are any there or not would be much simpler (but > would need a new one-line method). But I'm not sure what that would be > useful for? > > Mike > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > -- Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
In reply to this post by Mike Cowlishaw
Actually I often need to know if a Rexx "database" variable has indexed
values or not . This is particularly true when trying to copy a
multidimensional index (copyindexed only does one index level) or
flattening the database variable for storage in external media. It
might be nice to add a method to NetRexx to test for indexed values. I
just ran the following test which seemed to work but I am not sure how
efficient it would be with a large indexed collection. Are all indexes
checked before the loop starts?
-------------------------------------------------------------- x="I am indexed" x["a"]="a" y="I am not indexed" if indexed(x) then say "x is indexed" else say "x is not indexed" if indexed(y) then say "y is indexed" else say "y is not indexed" method indexed(v=Rexx) static returns boolean r=0 loop i over v r=1 leave end return r --------------------------------------------------------------- results in: x is indexed y is not indexed -- Kermit On 8/24/2010 3:54 AM, Mike Cowlishaw wrote: Hmm, how about looping some variable over the Rexx instance. Its final value should tell you if there are any indexed sub-strings. Not tested and probably not very efficient but it might be worth a try.Yes that would work .. and could be used to count the number of indexed strings. Expensive for large sets of indices because it will always generate the full set. Just testing whether there are any there or not would be much simpler (but would need a new one-line method). But I'm not sure what that would be useful for? Mike _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Kermit,
Mike and me followed this discussion off-list inadvertently. Here is more or less what we came out with: First: method isIndexed(str=Rexx) returns Rexx indexed = 0 loop indexed over str indexed = 1 leave end return indexed Then: method isIndexed(str=Rexx) returns Rexx
loop dummy over str return 1 end return 0 Then: method isIndexed(str=Rexx) returns Rexx loop indexed over str indexed = 1 return indexed end return 0 Then: method isIndexed(str=Rexx) returns Rexx loop indexed over str return indexed\=null end return 0 And finally: method isIndexed(str=Rexx) static returns Rexx loop str over str return 1 end return 0 or: method isIndexed(str=Rexx) static returns Rexx loop str over str; return 1; end; return 0 The two latest being the same. Still not sure if this is right. It definitely works but it's looping over indexed in theory no longer existing as str is 'assigned' to its first index on entering the loop. Mike is also concerned about efficiency for large collections of indexes. The initial snapshot of all the indexes needs to be build for the LOOP OVER even when even when it will only loop over the first (or none at all). Now checking the spec. about the last implementation. Is that it, Mike? I hope I didn't forget or misinterpret anything. --- Saludos / Kind regards. David Requena El 24/08/2010 21:05, Kermit Kiser escribió: Actually I often need to know if a Rexx "database" variable has indexed values or not . This is particularly true when trying to copy a multidimensional index (copyindexed only does one index level) or flattening the database variable for storage in external media. It might be nice to add a method to NetRexx to test for indexed values. I just ran the following test which seemed to work but I am not sure how efficient it would be with a large indexed collection. Are all indexes checked before the loop starts? _______________________________________________ Ibm-netrexx mailing list [hidden email] |
thanks for the synopsis of what we can do currently. I would suggest to use the function/method isIndexed for the current minute (as described below, the variants are doing pretty the same job), and add the method IsIndexed to the Rexx class *as soon* as the source is opened. As Mike did describe, a LOOP over an indexed string builds a snapshot of the indexed string at the start of the loop, i.e. does make a COPY of it, when I understand it right, so that the contents of str are not changed during the LOOP over.... Thus the loop may add members to the str, without affecting the current loop. The same philosophy seems to be used in ooRexx, as far as I do know. I can live with that for the minute, but we shall add it to class Rexx ASAP. Thomas. ================================================================================================== Am 24.08.2010 21:52, schrieb David Requena: Kermit, --
Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
In reply to this post by David Requena
The two latest being the same. Still not sure if
this is right. It definitely works but
it's looping over indexed in theory no longer existing as str is 'assigned' to its first index on entering the loop. Mike is also concerned about efficiency for large collections of indexes. The initial snapshot of all the indexes needs to be build for the LOOP OVER even when even when it will only loop over the first (or none at all). Now checking the spec. about the last implementation. Is that it, Mike? I hope I didn't forget or misinterpret anything.
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Thomas.Schneider.Wien
As Mike did describe, a LOOP over an indexed string builds a snapshot of the indexed string at the start of the loop, i.e. does make a COPY of it, when I understand it right, so that the contents of str are not changed during the LOOP over.... Loop Over takes a snapshot of the indices (if any) of the
indexed string. It does not make a copy of the string.
Mike
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
Free forum by Nabble | Edit this page |