#201 Please add method \\\"caselessAbbrev\\\" to \\\"String\\\" class

v3.2.0
closed
Classes (154)
5
2012-08-14
2007-07-03
No

Please add a caseless version of the 'abbrev' method, named 'caselessAbbrev' to the String class. (This would really make "Abbrev" useful in many new contextes.)

Discussion

  • Rick McGuire

    Rick McGuire - 2007-07-03

    Logged In: YES
    user_id=1125291
    Originator: NO

    Committed revision 553.

     
  • Rick McGuire

    Rick McGuire - 2007-07-03

    Logged In: YES
    user_id=1125291
    Originator: NO

    caselessAbbrev <indexterm><primary>caselessAbbrev method</primary> <secondary>of String class</secondary></indexterm> <indexterm><primary>method</primary> <secondary>caselessAbbrev method</secondary> <tertiary>of String class</tertiary></indexterm> <indexterm><primary>default</primary> <secondary>selecting with caselessAbbrev method</secondary></indexterm> <indexterm><primary>selecting a default with caselessAbbrev method</primary></indexterm> <indexterm><primary>testing</primary> <secondary>abbreviations with caselessAbbrev method</secondary></indexterm> <programlisting> >-caselessAbbrev(info-+---------+-)----------------------------------->< +-,length-+ ]]> </programlisting> <para>Returns <computeroutput>1</computeroutput> if <emphasis role="italic">info</emphasis> is equal to the leading characters of the receiving string and the length of <emphasis role="italic">info</emphasis> is not less than <emphasis role="italic">length</emphasis>. Returns <computeroutput>0</computeroutput> if either of these conditions is not met. The characters are tested using a caseless comparison. </para> <para>If you specify <emphasis role="italic">length</emphasis>, it must be a positive whole number or zero. The default for <emphasis role="italic">length</emphasis> is the number of characters in <emphasis role="italic">info</emphasis>.</para> <para><emphasis role="bold">Examples:</emphasis></para> <indexterm><primary>examples</primary> <secondary>abbrev method</secondary></indexterm> <programlisting> 1 "PRINT"~caselessAbbrev("Pri") -> 1 "PRINT"~caselessAbbrev("PRI",4) -> 0 "PRINT"~caselessAbbrev("PRY") -> 0 "PRINT"~caselessAbbrev("") -> 1 "PRINT"~caselessAbbrev("",1) -> 0 ]]> </programlisting> <note>Note <para>A null string always matches if a length of <computeroutput>0</computeroutput>, or the default, is used. This allows a default keyword to be selected automatically if desired.</para></note> <para><emphasis role="bold">Example:</emphasis></para> <programlisting> say "Enter option:"; parse pull option . select /* keyword1 is to be the default */ when "keyword1"~caselessAbbrev(option) then ... when "keyword2"~caselessAbbrev(option) then ... ... otherwise nop; end; </programlisting>
     
  • David Ashley

    David Ashley - 2007-07-07

    Logged In: YES
    user_id=931756
    Originator: NO

    Updated the docs in revision 562 and 563.

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks