{"id":2333,"date":"2025-04-15T10:28:29","date_gmt":"2025-04-15T10:28:29","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=2333"},"modified":"2025-06-10T07:58:11","modified_gmt":"2025-06-10T07:58:11","slug":"iistrfind2-bbnnc-d29","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/","title":{"rendered":"iiStrFind2 bb#,nn,c [D>=29]"},"content":{"rendered":"\n<p>Match a string in\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o414\">RAM<\/a>\u00a0to a table in\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o2970\">NVEM<\/a>.\u00a0<em>This is subtly different to<\/em><code> <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind-bbnnc-d28\/\">iiStrFind<\/a><\/code><em>, which uses a different table format<\/em>.<\/p>\n\n\n\n<p>Consider an Xwire receive data block to be&nbsp;<code>nn<\/code>&nbsp;bytes of RAM starting at address&nbsp;<code>bb<\/code>. This instruction seeks to match the data in the block with one or more &#8220;canned&#8221; strings stored in NVEM.<\/p>\n\n\n\n<p>If argument&nbsp;<code>c<\/code>&nbsp;is zero, the instruction treats upper and lower case letters as equivalent. If&nbsp;<code>c<\/code>&nbsp;is non-zero, the case of the RAM string must match exactly the string stored in NVEM.<\/p>\n\n\n\n<p>The data in NVEM must be stored in a very specific Count\/Data format. This is best illustrated by an example. Lets say we want to detect which fruit has been requested via an Internet interface and transferred into an Xwire receive data block.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">1. NVEM: Message list<\/h6>\n\n\n\n<p>First you construct a list of all possible receive strings in NVEM. Each string must be preceded by a byte containing the length of the string itself.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">strOrange:      NV0Byte   7,\"Orange\",13\nstrApple:       NV0Byte   6,\"Apple\",13\nstrBanana:      NV0Byte   7,\"Banana\",13\nstrLemon:       NV0Byte   6,\"Lemon\",13\nstrPear:        NV0Byte   5,\"Pear\",13\nstrGrape:       NV0Byte   6,\"Grape\",13\n;   Byte count ___________^<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">2. NVEM: Pointer table<\/h6>\n\n\n\n<p>Next you construct a table, in NVEM, of pointers to the individual strings. This must be terminated in two 255 bytes. The 255s tell ii<code>StrFind2<\/code>&nbsp;that it has come to the end of the table.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">FruitNames:     NV0Ptr    strOrange\t;Entry #1\n                NV0Ptr    strLemon \t;Entry #2\n                NV0Ptr    strApple \t;Entry #3\n                NV0Ptr    strPear  \t;Entry #4\n                NV0Ptr    strBanana\t;Entry #5\n                NV0Ptr    strGrape \t;Entry #6\n                NV0Byte   255,255      ;&lt;&lt;&lt;&lt;&lt; Essential!!!<\/pre>\n\n\n\n<p>You will notice that the order of entries is different to the order of the strings themselves. They can be in any order you like. You can have several such tables, with different ordering. You can even use different sub-sets of strings at<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">3. Code: Wait for a message string<\/h6>\n\n\n\n<p>Before trying to extract or recognize a string, you must know that a string has actually been received. How you do this will depend on the particular source of the data that is being stored in RAM. We cannot therefore provide such detail here. (See\u00a0<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/default-serial-port\/comrx_strfind2-c-d29\/\">ComRx_StrFind2<\/a><\/code>\u00a0to see how it&#8217;s done for serial data). Here we&#8217;ll just have example code for defining the Rx data block.:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">XWRxBlock\tdefBYTE\t30\nXWRxBlkLen\tEQU\t\t30<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">4. Code: Find a string match.<\/h6>\n\n\n\n<p>This is where we use the actual&nbsp;<code>iiStrFind2<\/code>&nbsp;instruction. First we have to make sure the NVEM access is correctly set up.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">                <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/non-volatile-memory\/nvsetptr-pppp-d15\/\">NVSetPtr<\/a>    FruitNames<br>                NVSetPage   0           ;0 is the default, so playing very safe!<br>                LoadI\t 0\t\t ;Start the search at the start of the buffer<br>                iiStrFind2  XWRxBlock,XWRxBlkfLen,0<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">5. Code: Evaluate the result.<\/h6>\n\n\n\n<p>The&nbsp;<code>iiStrFind2<\/code>&nbsp;returns its result in&nbsp;<code><a href=\"https:\/\/www.splatco.com\/skb\/352.htm#o3808\">X<\/a><\/code>, as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If a match is found, the&nbsp;<code>X<\/code>-register contains the number of the entry in the pointer table,&nbsp;<em>counting from 1<\/em>. Thus, if in this case the received string was&nbsp;<code>\"Apple\",13<\/code>,&nbsp;<code>X<\/code>&nbsp;would contain 3.<\/li>\n\n\n\n<li>If a match is not found,&nbsp;<code>X<\/code>&nbsp;will contain 0 (which makes&nbsp;<code>Branch<\/code>&nbsp;instruction very appropriate).<\/li>\n<\/ul>\n\n\n\n<p>If a match is found, the index register&nbsp;<code>I<\/code>&nbsp;is incremented to point to the first character in RAM after the string (auto-index).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">                <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/number-comparison-and-testing-instructions\/comparison-and-testing-for-byte-values\/branch\/\">Branch<\/a><br>                Target     NoMatch<br>                Target     RxOrange<br>                Target     RxLemon<br>                Target     RxApple<br>                Target     RxPear<br>                Target     RxBanana<br>                Target     RxGrape<br><br>RxOrange:   ;Do the orange thing ....<br>RxLemon:    ;Do the lemon thing ....<br>RxApple:    ;Do the apple thing ....<br>RxPear:     ;Do the pear thing ....<br>RxBanana:   ;Do the banana thing ....<br>RxGrape:    ;Do the grape thing ....<br>You would place your own code to respond to each of the strings at <code>RxOrange<\/code>, <code>RxLemon<\/code>, etc. <br>Quite likely you would then go back to waiting for the next incoming message.<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">Notes\/reminders:<\/h6>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The instruction only moves&nbsp;<code>I<\/code>&nbsp;past the characters of any string it matches.<\/li>\n\n\n\n<li>The string must start at the position initially pointed to by&nbsp;<code>I<\/code>.<\/li>\n\n\n\n<li>The 3rd instruction argument controls case sensitivity<\/li>\n\n\n\n<li>Each string in NVEM must be preceded by a count byte.<\/li>\n\n\n\n<li>The table of pointers must end in two 255 bytes.<\/li>\n\n\n\n<li>The record length and record number pointers are not involved in this instruction. Only the page and pointer matter.<\/li>\n\n\n\n<li>The\u00a0<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/default-serial-port\/comrx_strfind2-c-d29\/\">ComRx_StrFind<\/a><\/code><a href=\"https:\/\/www.splatco.com\/skb\/5454.htm\">2<\/a>\u00a0instruction has very similar behaviour, only it works on data received via the serial port.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Match a string in\u00a0RAM\u00a0to a table in\u00a0NVEM.\u00a0This is subtly different to iiStrFind, which uses a different table format. Consider an Xwire receive data block to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2256,"menu_order":16,"template":"","class_list":["post-2333","spl_knowledgebase","type-spl_knowledgebase","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>iiStrFind2 bb#,nn,c [D&gt;=29] - SPLat Controls<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"iiStrFind2 bb#,nn,c [D&gt;=29] - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"Match a string in\u00a0RAM\u00a0to a table in\u00a0NVEM.\u00a0This is subtly different to iiStrFind, which uses a different table format. Consider an Xwire receive data block to...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T07:58:11+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/\",\"name\":\"iiStrFind2 bb#,nn,c [D>=29] - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-15T10:28:29+00:00\",\"dateModified\":\"2025-06-10T07:58:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Programming reference\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Instructions arranged by function\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Communications instructions\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"iiStrFind2 bb#,nn,c [D>=29]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"name\":\"SPLat Controls\",\"description\":\"OEM Embedded Machine Controllers\",\"publisher\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\",\"name\":\"SPLat Controls\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"contentUrl\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"caption\":\"SPLat Controls\"},\"image\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"iiStrFind2 bb#,nn,c [D>=29] - SPLat Controls","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"iiStrFind2 bb#,nn,c [D>=29] - SPLat Controls","og_description":"Match a string in\u00a0RAM\u00a0to a table in\u00a0NVEM.\u00a0This is subtly different to iiStrFind, which uses a different table format. Consider an Xwire receive data block to...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T07:58:11+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/","name":"iiStrFind2 bb#,nn,c [D>=29] - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-15T10:28:29+00:00","dateModified":"2025-06-10T07:58:11+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/iistrfind2-bbnnc-d29\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"Programming reference","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/"},{"@type":"ListItem","position":3,"name":"Instructions arranged by function","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/"},{"@type":"ListItem","position":4,"name":"Communications instructions","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/"},{"@type":"ListItem","position":5,"name":"iiStrFind2 bb#,nn,c [D>=29]"}]},{"@type":"WebSite","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","name":"SPLat Controls","description":"OEM Embedded Machine Controllers","publisher":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization","name":"SPLat Controls","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","contentUrl":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","caption":"SPLat Controls"},"image":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/2333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase"}],"about":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/types\/spl_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/users\/1"}],"up":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/2256"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=2333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}