New method: getKeyWord

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

New method: getKeyWord

Jeff Hennick-3

For NetRexx Pipelines, I am going to add a new method to utils.nrx.  It is to search an argument string for a key word or abbreviation.

/*
   getKeyWord(argString, key, minKeyLength = 0, type = 'K')

 This searches a string for a word or its abbreviation.  It is for searching argument strings
 for key words.  A minKeyLength of '' or 0 means the full length is needed.
 The search is case independent.  What it returns depends on the Key.

 Key values (Only the first character is used):
  -- Key: return boolean exists;
  -- Subword: return next word;
  -- Dstring: return DString
  -- Qword: return QWord

 It returns a Rexx Indexed string of what it found including the
 original string with the keyword (and Subword, Dstring, or Qword) removed.
 If the key word is not found the original string is returned.

 returns:
 [0] 5 -- number of return strings
 [1] the argString without the keyword & subkeyword(s)
 [2] the subkeyword(s) value (or for type Key 1: keyword found | 0: keyword not found)
 [3] the actual keyword found, this may be an abbreviation or mixed case
 [4] the delimiter for types Dstring and Qword
 [5] the word number of the keyword, 0 for not found
*/

An alternative way of presenting this function (less Rexx-like and more Java-like) would be to make it a class with getter methods.

Your comments, ideas, etc. are all requested and welcomed.

Jeff


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: New method: getKeyWord

ThSITC

Jeff, sounds EXCELLECENT for me (as all from Your shop :-))

One question (sorry): What is a DString and a QWord ?

Sorry for my ignorance :-(

Tom.

==================================================================================

Am 30.08.2020 um 20:36 schrieb Jeff Hennick:

For NetRexx Pipelines, I am going to add a new method to utils.nrx.  It is to search an argument string for a key word or abbreviation.

/*
   getKeyWord(argString, key, minKeyLength = 0, type = 'K')

 This searches a string for a word or its abbreviation.  It is for searching argument strings
 for key words.  A minKeyLength of '' or 0 means the full length is needed.
 The search is case independent.  What it returns depends on the Key.

 Key values (Only the first character is used):
  -- Key: return boolean exists;
  -- Subword: return next word;
  -- Dstring: return DString
  -- Qword: return QWord

 It returns a Rexx Indexed string of what it found including the
 original string with the keyword (and Subword, Dstring, or Qword) removed.
 If the key word is not found the original string is returned.

 returns:
 [0] 5 -- number of return strings
 [1] the argString without the keyword & subkeyword(s)
 [2] the subkeyword(s) value (or for type Key 1: keyword found | 0: keyword not found)
 [3] the actual keyword found, this may be an abbreviation or mixed case
 [4] the delimiter for types Dstring and Qword
 [5] the word number of the keyword, 0 for not found
*/

An alternative way of presenting this function (less Rexx-like and more Java-like) would be to make it a class with getter methods.

Your comments, ideas, etc. are all requested and welcomed.

Jeff


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


Virus-free. www.avg.com

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: New method: getKeyWord

Jeff Hennick-3

DString: Delimited string has been a Pipeline staple. It is used as in Xedit's locate.  Usually as /some string/ but any character can be the delimiter, although a non-alphanumeric is recommended.

QWord: Quoted word, as a name, has recently been introduced by me.  It is "a word, optionally in quotes, if there spaces are within it, it must be quoted."  A use of this is for a file name; it is often a single word, but could contain spaces, and might include a path that has spaces, but the program treats it syntactically as a single word.

(In the training business, we used to say "We cure ignorance, but stupidity is forever."  And it is wise to recognize the difference, especially in oneself.)

I have been using a variant of this Method in some of the stages I have written, and think it is (past) time to factor it out, standardize it, and make it available to all stage programmers.

On 8/30/2020 5:18 PM, Thomas Schneider wrote:

Jeff, sounds EXCELLECENT for me (as all from Your shop :-))

One question (sorry): What is a DString and a QWord ?

Sorry for my ignorance :-(

Tom.

==================================================================================

Am 30.08.2020 um 20:36 schrieb Jeff Hennick:

For NetRexx Pipelines, I am going to add a new method to utils.nrx.  It is to search an argument string for a key word or abbreviation.

/*
   getKeyWord(argString, key, minKeyLength = 0, type = 'K')

 This searches a string for a word or its abbreviation.  It is for searching argument strings
 for key words.  A minKeyLength of '' or 0 means the full length is needed.
 The search is case independent.  What it returns depends on the Key.

 Key values (Only the first character is used):
  -- Key: return boolean exists;
  -- Subword: return next word;
  -- Dstring: return DString
  -- Qword: return QWord

 It returns a Rexx Indexed string of what it found including the
 original string with the keyword (and Subword, Dstring, or Qword) removed.
 If the key word is not found the original string is returned.

 returns:
 [0] 5 -- number of return strings
 [1] the argString without the keyword & subkeyword(s)
 [2] the subkeyword(s) value (or for type Key 1: keyword found | 0: keyword not found)
 [3] the actual keyword found, this may be an abbreviation or mixed case
 [4] the delimiter for types Dstring and Qword
 [5] the word number of the keyword, 0 for not found
*/

An alternative way of presenting this function (less Rexx-like and more Java-like) would be to make it a class with getter methods.

Your comments, ideas, etc. are all requested and welcomed.

Jeff


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


Virus-free. www.avg.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/

Reply | Threaded
Open this post in threaded view
|

Re: New method: getKeyWord

jlturriff
In reply to this post by Jeff Hennick-3
On 2020-08-30 13:36:57 Jeff Hennick wrote:

> <html>
>   <head>
>
>     <meta http-equiv="content-type" content="text/html; charset=UTF-8">
>   </head>
>   <body>
>     <p>For NetRexx Pipelines, I am going to add a new method to
> <b>utils.nrx</b>.  It is to search an argument string for a key word or
> abbreviation.</p> <p>/*<br>
>          getKeyWord(argString, key, minKeyLength = 0, type = 'K')<br>
>       <br>
>        This searches a string for a word or its abbreviation.  It is for
>       searching argument strings<br>
>        for key words.  A minKeyLength of '' or 0 means the full length
>       is needed.<br>
>        The search is case independent.  What it returns depends on the
>       Key.<br>
>       <br>
>        Key values (Only the first character is used):<br>
>         -- Key: return boolean exists;<br>
>         -- Subword: return next word;<br>
>         -- Dstring: return DString<br>
>         -- Qword: return QWord<br>
>       <br>
>        It returns a Rexx Indexed string of what it found including the<br>
>        original string with the keyword (and Subword, Dstring, or Qword)
>       removed.<br>
>        If the key word is not found the original string is returned.<br>
>       <br>
>        returns:<br>
>        [0] 5 -- number of return strings<br>
>        [1] the argString without the keyword &amp; subkeyword(s)<br>
>        [2] the subkeyword(s) value (or for type Key 1: keyword found |
>       0: keyword not found)<br>
>        [3] the actual keyword found, this may be an abbreviation or
>       mixed case <br>
>        [4] the delimiter for types Dstring and Qword<br>
>        [5] the word number of the keyword, 0 for not found<br>
>       */<br>
>     </p>
>     <p>An alternative way of presenting this function (less Rexx-like
>       and more Java-like) would be to make it a class with getter
>       methods.</p>
>     <p>Your comments, ideas, etc. are all requested and welcomed.</p>
>     <p>Jeff<br>
>     </p>
>   </body>
> </html>

        You are calling it getKeyWord instead of abbrev to avoid a collision?

Leslie
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: New method: getKeyWord

Jeff Hennick-3

Leslie,

Thank you for your interest.

I'm not clear on your question, but will try to answer it as I read it.  Yes, any new method should avoid name collision, in the program, and more important, in the mind of both the reader and writer.  But this is so much more than abbrev, either the NetRexx method or the Pipeline stage and used under different circumstances than either of those.  It is convenience method for scanning the argument string passed to a Pipeline stage, just as that string is scanned for ranges, etc.  Yes, it uses the abbrev method as needed, internally.  But it returns so much more, including the now excised string for further processing.

As an example of where it could be used, here is part of the diagram for the DATECONVERT stage:

                 +-- 1-* ------------------------+
>>--DATECONVert--+-------------------------------+--------------------------->
                 +-| Separator |--| Inputrange |-+

    +-SHOrtdate ISOdate---------------------+  +-WINDOW -50------------+
>---+---------------------------------------+--+-----------------------+------>
    |                    +-ISOdate----------+  +-WINDOW--signednumber--+
    +-| Inputformat |-+--+------------------+  +-BASEYEAR--yearnumber--+
    |     +-PREFACE-+ |  +-| Outputformat |-+
    +-NOW-+-(5)-----+-+
          +-APPEND--+
                  +--MIDNIGHT--(4)-+
>--+-----------+--+----------------+---------------------------------------->>
   +--TIMEOUT--+  +--NOON--(4)-----+

It would be used in processing the argString for the stage to see if the keyword TIMEOUT, MIDNIGHT, NOW, or WINDOW, etc. is present and get the value for WINDOW.  None of these would be using the abbrev method part at all, but if it were used to see if SHOrtdate were in there, it would use abbrev.

It, in its current iteration, has limitations that I will add to the comments.  This includes that in searching for a given keyword, it does not know about quoted or delimited strings, so looks inside them too, stopping at the first instance of the key. I will also add that, if given "" for a key, and searching for a DString, it will look at the left end of the string, that is, after word[0].

If this does not answer your question, it is because of my faulty reading of your question.  In that case, please help me with it.

Jeff

On 8/30/2020 6:43 PM, J Leslie Turriff wrote:
On 2020-08-30 13:36:57 Jeff Hennick wrote:
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>For NetRexx Pipelines, I am going to add a new method to
<b>utils.nrx</b>.  It is to search an argument string for a key word or
abbreviation.</p> <p>/*<br>
         getKeyWord(argString, key, minKeyLength = 0, type = 'K')<br>
      <br>
       This searches a string for a word or its abbreviation.  It is for
      searching argument strings<br>
       for key words.  A minKeyLength of '' or 0 means the full length
      is needed.<br>
       The search is case independent.  What it returns depends on the
      Key.<br>
      <br>
       Key values (Only the first character is used):<br>
        -- Key: return boolean exists;<br>
        -- Subword: return next word;<br>
        -- Dstring: return DString<br>
        -- Qword: return QWord<br>
      <br>
       It returns a Rexx Indexed string of what it found including the<br>
       original string with the keyword (and Subword, Dstring, or Qword)
      removed.<br>
       If the key word is not found the original string is returned.<br>
      <br>
       returns:<br>
       [0] 5 -- number of return strings<br>
       [1] the argString without the keyword &amp; subkeyword(s)<br>
       [2] the subkeyword(s) value (or for type Key 1: keyword found |
      0: keyword not found)<br>
       [3] the actual keyword found, this may be an abbreviation or
      mixed case <br>
       [4] the delimiter for types Dstring and Qword<br>
       [5] the word number of the keyword, 0 for not found<br>
      */<br>
    </p>
    <p>An alternative way of presenting this function (less Rexx-like
      and more Java-like) would be to make it a class with getter
      methods.</p>
    <p>Your comments, ideas, etc. are all requested and welcomed.</p>
    <p>Jeff<br>
    </p>
  </body>
</html>
	You are calling it getKeyWord instead of abbrev to avoid a collision?

Leslie
_______________________________________________
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/

Reply | Threaded
Open this post in threaded view
|

Re: New method: getKeyWord

jlturriff
On 2020-08-30 21:58:30 Jeff Hennick wrote:

> <html>
>   <head>
>     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>   </head>
>   <body>
>     <p>Leslie,</p>
>     <p>Thank you for your interest.<br>
>     </p>
>     <p>I'm not clear on your question, but will try to answer it as I
>       read it.  Yes, any new method should avoid name collision, in the
>       program, and more important, in the mind of both the reader and
>       writer.  But this is so much more than abbrev, either the NetRexx
>       method or the Pipeline stage and used under different
>       circumstances than either of those.  It is convenience method for
>       scanning the argument string passed to a Pipeline stage, just as
>       that string is scanned for ranges, etc.  Yes, it uses the abbrev
>       method as needed, internally.  But it returns so much more,
>       including the now excised string for further processing.</p>
>     <p>As an example of where it could be used, here is part of the
>       diagram for the DATECONVERT stage:</p>
>     <p><font face="monospace">                 +-- 1-*
>         ------------------------+<br>
> &gt;&gt;--DATECONVert--+-------------------------------+-------------------
>--------&gt;<br> +-| Separator |--| Inputrange |-+<br>
>         <br>
>             +-SHOrtdate ISOdate---------------------+  +-WINDOW
>         -50------------+<br>
> &gt;---+---------------------------------------+--+-----------------------+
>------&gt;<br> |                    +-ISOdate----------+
>         +-WINDOW--signednumber--+<br>
>             +-| Inputformat |-+--+------------------+ 
>         +-BASEYEAR--yearnumber--+<br>
>             |     +-PREFACE-+ |  +-| Outputformat |-+<br>
>             +-NOW-+-(5)-----+-+<br>
>                   +-APPEND--+<br>
>                           +--MIDNIGHT--(4)-+<br>
> &gt;--+-----------+--+----------------+------------------------------------
>----&gt;&gt;<br> +--TIMEOUT--+  +--NOON--(4)-----+<br>
>       </font></p>
>     <p>It would be used in processing the argString for the stage to see
>       if the keyword TIMEOUT, MIDNIGHT, NOW, or WINDOW, etc. is present
>       and get the value for WINDOW.  None of these would be using the
>       abbrev method part at all, but if it were used to see if SHOrtdate
>       were in there, it would use abbrev.<br>
>     </p>
>     <p>It, in its current iteration, has limitations that I will add to
>       the comments.  This includes that in searching for a given
>       keyword, it does not know about quoted or delimited strings, so
>       looks inside them too, stopping at the first instance of the key.
>       I will also add that, if given "" for a key, and searching for a
>       DString, it will look at the left end of the string, that is,
>       after word[0].</p>
>     <p>If this does not answer your question, it is because of my faulty
>       reading of your question.  In that case, please help me with it.</p>
>     <p>Jeff<br>
>     </p>
>     <div class="moz-cite-prefix">On 8/30/2020 6:43 PM, J Leslie Turriff
>       wrote:<br>
>     </div>
>     <blockquote type="cite"
>       cite="mid:[hidden email]">
>       <pre class="moz-quote-pre" wrap="">On 2020-08-30 13:36:57 Jeff
> Hennick wrote: </pre>
>       <blockquote type="cite">
>         <pre class="moz-quote-pre" wrap="">&lt;html&gt;
>   &lt;head&gt;
>
>     &lt;meta http-equiv="content-type" content="text/html;
> charset=UTF-8"&gt; &lt;/head&gt;
>   &lt;body&gt;
>     &lt;p&gt;For NetRexx Pipelines, I am going to add a new method to
> &lt;b&gt;utils.nrx&lt;/b&gt;.  It is to search an argument string for a key
> word or abbreviation.&lt;/p&gt; &lt;p&gt;/*&lt;br&gt;
>          getKeyWord(argString, key, minKeyLength = 0, type = 'K')&lt;br&gt;
>       &lt;br&gt;
>        This searches a string for a word or its abbreviation.  It is for
>       searching argument strings&lt;br&gt;
>        for key words.  A minKeyLength of '' or 0 means the full length
>       is needed.&lt;br&gt;
>        The search is case independent.  What it returns depends on the
>       Key.&lt;br&gt;
>       &lt;br&gt;
>        Key values (Only the first character is used):&lt;br&gt;
>         -- Key: return boolean exists;&lt;br&gt;
>         -- Subword: return next word;&lt;br&gt;
>         -- Dstring: return DString&lt;br&gt;
>         -- Qword: return QWord&lt;br&gt;
>       &lt;br&gt;
>        It returns a Rexx Indexed string of what it found including
> the&lt;br&gt; original string with the keyword (and Subword, Dstring, or
> Qword) removed.&lt;br&gt;
>        If the key word is not found the original string is
> returned.&lt;br&gt; &lt;br&gt;
>        returns:&lt;br&gt;
>        [0] 5 -- number of return strings&lt;br&gt;
>        [1] the argString without the keyword &amp;amp;
> subkeyword(s)&lt;br&gt; [2] the subkeyword(s) value (or for type Key 1:
> keyword found | 0: keyword not found)&lt;br&gt;
>        [3] the actual keyword found, this may be an abbreviation or
>       mixed case &lt;br&gt;
>        [4] the delimiter for types Dstring and Qword&lt;br&gt;
>        [5] the word number of the keyword, 0 for not found&lt;br&gt;
>       */&lt;br&gt;
>     &lt;/p&gt;
>     &lt;p&gt;An alternative way of presenting this function (less Rexx-like
>       and more Java-like) would be to make it a class with getter
>       methods.&lt;/p&gt;
>     &lt;p&gt;Your comments, ideas, etc. are all requested and
> welcomed.&lt;/p&gt; &lt;p&gt;Jeff&lt;br&gt;
>     &lt;/p&gt;
>   &lt;/body&gt;
> &lt;/html&gt;
> </pre>
>       </blockquote>
>       <pre class="moz-quote-pre" wrap="">
> You are calling it getKeyWord instead of abbrev to avoid a collision?
>
> Leslie
> _______________________________________________
> Ibm-netrexx mailing list
> <a class="moz-txt-link-abbreviated"
> href="mailto:[hidden email]">[hidden email]</a>
> Online Archive : <a class="moz-txt-link-freetext"
> href="https://urldefense.proofpoint.com/v2/url?u=http-3A__ibm-2Dnetrexx.215
>625.n3.nabble.com_&amp;d=DwMDaQ&amp;c=jf_iaSHvJObTbx-siA1ZOg&amp;r=_6rXNpPJ1
>fYV-3bV1za02NiR4PUelvicfHXwtnTXpXE&amp;m=anS2nJ4rX_Xz-iUDU3PRo80FjjLWZRyPapT
>7HQlXmf8&amp;s=c4TR4WgKLEvClmVLk7bFncN-MIlMETcmBqpYpr80Xw4&amp;e="><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__ib&amp;d=DwQFaQ&amp;c=jf_iaSHvJObTbx-siA1ZOg&amp;r=_6rXNpPJ1fYV-3bV1za02NiR4PUelvicfHXwtnTXpXE&amp;m=xJFGAuf2dZo_QsR0Vt6hFcyqei01sdWdH7sVBUR82tI&amp;s=weRKkkc3eLwdMHjS_ll5u5ScIxTn2d8t9qiIMuyZmjk&amp;e=">http://ib</a>
>m-netrexx.215625.n3.nabble.com/</a>
>
> </pre>
>     </blockquote>
>   </body>
> </html>

        No, I understand now that this is an internal function that the user does not
actually invoke.

        Thanks,
Leslie
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/