{"id":161,"date":"2011-12-02T20:05:40","date_gmt":"2011-12-02T20:05:40","guid":{"rendered":"http:\/\/www.lorenzcom.com\/?p=161"},"modified":"2020-12-03T07:31:30","modified_gmt":"2020-12-03T13:31:30","slug":"getvalueindex","status":"publish","type":"post","link":"http:\/\/lorenzcom.com\/?p=161","title":{"rendered":"GetValueIndex"},"content":{"rendered":"<h3>GetValueIndex ( valueList , valueString , matchCase , occurrence )<\/h3>\n<p>GetValueIndex returns the index number of the first matching valueString in the valueList. Returns 0 if not found. Toggle case-sensitive searching by passing a boolean through matchCase. And, search for a specific valueString occurrence (a negative occurrence number causes backward search from the end of the valueList).<\/p>\n<h4>Parameters<\/h4>\n<ul>\n<li>valueList &#8211; List of values against which valueString will be compared.<\/li>\n<li>valueString &#8211; Text of value to look for in valueList.<\/li>\n<li>matchCase &#8211; Boolean true forces valueString to be an exact case-sensitive match in valueList before returning an index nummber.<\/li>\n<li>occurrence &#8211; Directs which instance of the valueString is required to be found. A negative number causes a backward search from the end of valueList.<\/li>\n<\/ul>\n<h4>Examples<\/h4>\n<ul>\n<li>ValueListIndex (\u201cAlpha\u00b6Bravo\u00b6Charlie\u00b6Echo\u201d, \u201ccharlie\u201d, False, 1) = 3<\/li>\n<li>ValueListIndex (\u201cAlpha\u00b6Bravo\u00b6Charlie\u00b6Echo\u201d, \u201ccharlie\u201d, True, 1) = 0<\/li>\n<li>ValueListIndex (&#8220;Danial\u00b6Daniel\u00b6Bill\u00b6daniel\u00b6Frank\u00b6daniel\u00b6Ed&#8221;, &#8220;Daniel&#8221;, True, -1) = 2<\/li>\n<\/ul>\n<h4>NOTICE:<\/h4>\n<p>This function is a recursive function. If you change the name of it, then change the name references inside the code.<\/p>\n<p><strong>GetValueIndex code:<\/strong> Copy the selected code (click on Select All to highlight all the code) to the clipboard and paste it into a newly created Custom Function. <a href=\"\/docs\/FileMaker\/GetValueIndex.zip\">Download code as a text file from here.<\/a><\/p>\n<form><textarea id=\"&lt;?php\"> style=&#8221;width:100%; height:180px; font-family:Arial,Helvetica; font-size:.90em; line-height:normal;&#8221;&gt;&lt;!&#8211;raw&#8211;&gt;Let ([ vlist = &#8220;\u00b6&#8221; &amp; valueList &amp; &#8220;\u00b6&#8221;; vtext = &#8220;\u00b6&#8221; &amp; valueString &amp; &#8220;\u00b6&#8221;;&lt;br \/&gt;<br \/>\npos = If ( occurrence = 0; 0; Position( vlist; vtext; If ( occurrence &lt; 0; Length ( vlist ); 1 ); If ( occurrence &lt; 0; -1; 1 ) ) );<br \/>\nindex = If ( pos; ValueCount ( Left ( vlist; pos ) ); 0 );<br \/>\nmatch = Exact ( GetValue ( valueList; index ); valueString );<br \/>\noccurrence = Case ( pos = 0; 0; matchCase; If ( match; occurrence + If ( occurrence &gt; 0; -1; 1 ); occurrence); occurrence + If ( occurrence &gt; 0; -1; 1 ) );&lt;br \/&gt;<br \/>\nvlist = Case ( occurrence &lt; 0; Left ( valueList; pos &#8211; 1 ); occurrence &gt; 0; Right ( valueList; Length ( valueList ) &#8211; ( pos + Length ( valueString ) )); &#8220;&#8221; );&lt;br \/&gt;<br \/>\nidx2 = If ( occurrence \u2260 0; GetValueIndex ( vlist ; valueString ; matchCase ; occurrence ); 0 );&lt;br \/&gt;<br \/>\nindex = Case ( occurrence &lt; 0; idx2; occurrence &gt; 0; If ( idx2 = 0; 0; index + idx2); index )];&lt;\/p&gt;<br \/>\n&lt;p&gt;index&lt;\/p&gt;<br \/>\n&lt;p&gt;)&lt;\/p&gt;<br \/>\n&lt;p&gt;\/*&lt;br \/&gt;<br \/>\nGetValueIndex (valueList, valueString, matchCase, occurrence)&lt;\/p&gt;<br \/>\n&lt;p&gt;by Lewis C. Lorenz.&lt;\/p&gt;<br \/>\n&lt;p&gt;9-20-2011: Created&lt;br \/&gt;<br \/>\n9-22-2011: Updated.&lt;\/p&gt;<br \/>\n&lt;p&gt;Retrieve the index of the matching valueString in the valueList. Returns 0 if not found.&lt;br \/&gt;<br \/>\nOptionally toggle case-sensitive searching by passing a boolean through matchCase.&lt;br \/&gt;<br \/>\nOptionally search for specific valueString occurrence (a negative occurrence number causes backward search from the end of the valueList).&lt;\/p&gt;<br \/>\n&lt;p&gt;Examples:&lt;br \/&gt;<br \/>\nValueListIndex (&#8220;Alpha\u00b6Bravo\u00b6Charlie\u00b6Echo&#8221;, &#8220;charlie&#8221;, False, 1) = 3&lt;br \/&gt;<br \/>\nValueListIndex (&#8220;Alpha\u00b6Bravo\u00b6Charlie\u00b6Echo&#8221;, &#8220;charlie&#8221;, True, 1) = 0&lt;br \/&gt;<br \/>\nValueListIndex (&#8220;James\u00b6Bill\u00b6James\u00b6Frank\u00b6James\u00b6Ed&#8221;, &#8220;james&#8221;, False, -2) = 3&lt;br \/&gt;<br \/>\n*\/&lt;!&#8211;\/raw&#8211;&gt;<\/textarea><!--<?php echo '\"this.form.te_'.get_the_ID().'.focus();this.form.te_'.get_the_ID().'.select();\"';?>--><br \/>\n<input form=\"\" type=\"text\" \/> type=&#8221;button&#8221; value=&#8221;Select All&#8221; \/&gt; <input type=\"reset\" value=\"Reset\" \/><\/form><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GetValueIndex ( valueList , valueString , matchCase , occurrence ) GetValueIndex returns the index number of the first matching valueString in the valueList. Returns 0 if not found. Toggle case-sensitive searching by passing a boolean through matchCase. And, search for <span class=\"excerpt-dots\">&hellip;<\/span> <a class=\"more-link\" href=\"http:\/\/lorenzcom.com\/?p=161\"><span class=\"more-msg\">Continue reading &rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,15,14],"tags":[37,36,21,22,20],"_links":{"self":[{"href":"http:\/\/lorenzcom.com\/index.php?rest_route=\/wp\/v2\/posts\/161"}],"collection":[{"href":"http:\/\/lorenzcom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/lorenzcom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/lorenzcom.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/lorenzcom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=161"}],"version-history":[{"count":27,"href":"http:\/\/lorenzcom.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions"}],"predecessor-version":[{"id":880,"href":"http:\/\/lorenzcom.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions\/880"}],"wp:attachment":[{"href":"http:\/\/lorenzcom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/lorenzcom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/lorenzcom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}