2 Replies Latest reply on Mar 6, 2015 10:12 AM by PeterMontague

    What is wrong with my Case calculation?

    PeterMontague

      Title

      What is wrong with my Case calculation?

      Post

      I'm writing a recursive calculation to look through the source code of a web page to find the book sellers that have the cheapest price. I want to exclude ourselves from the calculation. So I am using the PatternCount function and a Case function to keep moving through the booksellers who do not have one of our two names. Our names are Tolka Unused, Tolka Unused Books and Book-Fare. The cheapest price always comes at the top of the list. I want to isolate the price that is not our price that is the cheapest.

      Let ( [
      Seller1 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 1 ) ;
      Seller2 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 2 ) ;
      Seller3 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 3 ) ;
      Seller4 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 4 ) ;
      Seller5 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 5 ) ;
      Seller6 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 6 ) ;
      Seller7 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 7 ) ;
      Seller8 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 8 ) ;
      Seller9 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 9 ) ;
      Seller10 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 10 ) ;
      Seller11 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 11 ) ;
      Seller12 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 12 ) ;
      Seller13 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 13 ) ;
      Seller14 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 14 ) ;
      Seller15 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 15 ) ;
      Seller16 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 16 ) ;
      Seller17 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 17 ) ;
      Seller18 = Parse ( Inventory::source_bookfinder ; "<tr valign=\"top\" class=\"results-table-LogoRow\" >" ; "onmouseover" ; 18 ) ; 
      Price1 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 1 ) ;
      Price2 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 2 ) ;
      Price3 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 3 ) ;
      Price4 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 4 ) ;
      Price5 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 5 ) ;
      Price6 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 6 ) ;
      Price7 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 7 ) ;
      Price8 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 8 ) ;
      Price9 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 9 ) ;
      Price10 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 10 ) ;
      Price11 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 11 ) ;
      Price12 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 12 ) ;
      Price13 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 13 ) ;
      Price14 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 14 ) ;
      Price15 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 15 ) ;
      Price16 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 16 ) ;
      Price17 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 17 ) ;
      Price18 = Parse ( Inventory::source_bookfinder ; "26pound\x3b" ; "\\" ; 18 )   
      ]
      ;
      Case ( 
      PatternCount ( Seller1 ; "Book-Fare")  or PatternCount ( Seller1 ; "Tolka") < 1 ; Price1 ; 
      PatternCount ( Seller2 ; "Book-Fare")  or PatternCount ( Seller2 ; "Tolka") < 1 ; Price2 ;
      PatternCount ( Seller3 ; "Book-Fare")  or PatternCount ( Seller3 ; "Tolka") < 1 ; Price3 ;
      PatternCount ( Seller4 ; "Book-Fare")  or PatternCount ( Seller4 ; "Tolka") < 1 ; Price4 ;
      PatternCount ( Seller5 ; "Book-Fare")  or PatternCount ( Seller5 ; "Tolka") < 1 ; Price5 ;
      PatternCount ( Seller6 ; "Book-Fare")  or PatternCount ( Seller6 ; "Tolka") < 1 ; Price6 ;
      PatternCount ( Seller7 ; "Book-Fare")  or PatternCount ( Seller7 ; "Tolka") < 1 ; Price7 ;
      PatternCount ( Seller8 ; "Book-Fare")  or PatternCount ( Seller8 ; "Tolka") < 1 ; Price8 ;
      PatternCount ( Seller9 ; "Book-Fare")  or PatternCount ( Seller9 ; "Tolka") < 1 ; Price9 ;
      PatternCount ( Seller10 ; "Book-Fare")  or PatternCount ( Seller10 ; "Tolka") < 1 ; Price10 ;
      PatternCount ( Seller11 ; "Book-Fare")  or PatternCount ( Seller11 ; "Tolka") < 1 ; Price11 ;
      PatternCount ( Seller12 ; "Book-Fare")  or PatternCount ( Seller12 ; "Tolka") < 1 ; Price12 ;
      Price1 
      )
      )

      I want to use this 

      PatternCount ( Seller1 ; "Book-Fare")  or PatternCount ( Seller1 ; "Tolka") < 1 ; Price1
       
      to choose Price1 if there is no "Book-Fare” or “Tolka” in the parsed text. But it is choosing Price1 even if "Book-Fare” or “Tolka” is in the parsed text. What is wrong with my Case calculation?
       
      FYI here is the long html code which I am parsing:

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

      <html lang="en-us">

      <head>

      <script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>

      <script type="text/javascript" src="/js/jquery.cookie.js"></script>

      <script type="text/javascript" src="/js/readmore.min.js"></script>

      <script type="text/javascript" src="/js/pageload.js"></script>

      <script type="text/javascript" async="" src="https://ssl.google-analytics.com/ga.js"></script>

      <script type="text/javascript">

          function trackOutboundLink(event, link, category, action) {

              try {

                  _gaq.push(['_trackEvent', category , action,,,true]);

              } catch(err){}

           

              if(event.button === 0 && !event.ctrlKey && !event.metaKey){

                  event.preventDefault();

                  setTimeout(function() {

                      document.location.href = link.href;

                  }, 100);

                return false;

              } else {

                return true;

              }

          }

      </script>

      <title>

      ISBN 9780863272103

      </title>

      <meta http-equiv="Content-Script-Type" content="text/javascript">

      <meta name="y_key" content="c6e31ad0992202fc" >

      <meta name="msvalidate.01" content="7A4771BDEBD5D8ACF487F0F26B961C43" />

      <meta name="keywords" content="Books, Used Books, Rare Books, Out of print books, textbooks, used textbooks, college textbooks, antiquarian books, cheap books, antique books, hard to find books, online book stores, buy books, antique books, online used books, book store, online book sellers, book search, old books." />

      <link rel="stylesheet" media="all" href="http://i.bookfinder.com/site/style/" type="text/css">

      <!-- Latest compiled and minified CSS -->

      <link rel="home" href="http://www.bookfinder.com/">

      <link rel="help" href="http://www.bookfinder.com/help/">

      <link rel="glossary" href="http://www.bookfinder.com/help/glossary/">

      <link rel="P3Pv1" href="http://www.bookfinder.com/site/p3p/prf/">

      <link rel="shortcut icon" href="http://i.bookfinder.com/images/icon/favicon.bf.ico">

      <link rel="apple-touch-icon" href="http://i.bookfinder.com/images/icon/apple-touch-icon.bf.png">

      <link rel="search" type="application/opensearchdescription+xml" href="http://www.bookfinder.com/site/opensearch/" title="BookFinder.com">

      <link rel="canonical" href="http://www.bookfinder.com/book/9780863272103/" />

      <meta name="description" content="Find ISBN 9780863272103. Compare book prices from over 100,000 booksellers">

      <meta name="robots" content="noodp">

      <script language="JavaScript1.2" type="text/javascript" src="http://i.bookfinder.com/site/js/overlib/overlib_mini.js"></script><script type="text/javascript">var ol_fgcolor = "#ccccff";</script>

      <script type="text/javascript">

      function deallocation(name) {

          var cell = $.cookie('ab-test-' + name);

          if (cell) {

              $.removeCookie('ab-test-'+ name);

          }

      }

      $(document).ready(function(){

          deallocation('isbn-results');

          $("#search_form").submit(function(e) {

              optinForm = this;

              if (window._gat) {

                  e.preventDefault();

                  var minYear = $("#min_year").val();

                  var maxYear = $("#max_year").val();

                  var eventLabel = "";

                  if ($("#author").val()) {

                      eventLabel = "|author:" + $("#author").val();

                  }

                  if ($("#title").val()) {

                      eventLabel = eventLabel + "|title:" + $("#title").val();

                  } 

                  if ($("#keywords").val()) {

                      eventLabel = eventLabel + "|keywords:" + $("#keywords").val();

                  } 

                  if (minYear && maxYear) {

                      _gaq.push(['_trackEvent', 'PubDate', 'min-max',minYear + '-' + maxYear + eventLabel,,true]);     

                  } else if (minYear) {

                      _gaq.push(['_trackEvent', 'PubDate', 'min',minYear + eventLabel,,true]);     

                  } else if (maxYear) {

                      _gaq.push(['_trackEvent', 'PubDate', 'max',maxYear + eventLabel,,true]);     

                  }

                  setTimeout(function() { optinForm.submit();}, 25);

              }

          });

      });

      var cell = $.cookie('session_id');

      if (cell === undefined) {

         var seed = Math.floor(Math.random() * 100);

         $.cookie('session_id', seed, {path : '/'});

      }

      </script>

      <script type="text/javascript">

      var _gaq = _gaq || [];

              _gaq.push (['_setAccount', "UA-93775-1"]);

              _gaq.push (['_gat._anonymizeIp']);

                  _gaq.push (['_trackPageview', "/search/_results/"]);

      (function() {

          var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

          ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';

          var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

        })();

      </script>

      </head>

      <!-- SI:/hn=/hp=8/cp=45/mu=36/la=0.6/df=21/bx=2xeoncpux5.2667.17084/up=87/ -->

      <body class="">

      <!-- start yui grids doc, 1 section across -->

      <div id="doc3" class="yui-t7"

      >

      <div id="hd"> <!-- start yui grids header -->

        <div align="center" id="header">

          <!-- 10.30.142.177 -->

      <script type="text/javascript">

          _gaq.push(['_trackEvent', 'AB-Testing', 'ebooks-sws-' + "b_b",,, true]);

      </script>

      <table border="0" width="100%" cellspacing="0" cellpadding="0">

      <tr id="header-row-1">

        <td align="left" id="header-section-logo">

          <a href="http://www.bookfinder.com/?ref=bf_s3_hd_1" rel="home" title="BookFinder.com: Search for New & Used Books, Textbooks, Rare Books & Out-of-Print Books">

              <img src="http://i.bookfinder.com/images/site/title/sites/www.bookfinder.com.gif" alt="BookFinder.com" id="header-site-logo" title="BookFinder.com: Search for New & Used Books, Textbooks, Rare Books & Out-of-Print Books"></a>

      </td><td>

       

        </td>

        <td align="right" id="header-section-links">

      <a href="http://www.bookfinder.com/?ref=bf_s3_hd_2" title="">Search</a> |

      <a href="http://www.bookfinder.com/about/?ref=bf_s3_hd_3" title="Information about BookFinder.com and the folks who run it">About</a> |

      <a href="http://www.bookfinder.com/my/preferences/?ref=bf_s3_hd_4" title="">Preferences</a> |

      <a href="http://www.bookfinder.com/interact/?ref=bf_s3_hd_5" title="Find out how to interact with the folks at BookFinder.com">Interact</a> |

      <a href="http://www.bookfinder.com/help/?ref=bf_s3_hd_6" title="How to use the BookFinder.com web site -- FAQs and tips">Help</a>

        </td>

      </tr>

      <tr style="height: 7px" bgcolor="black"><td height="7" colspan="3" style="height: 7px; background-color: black; padding: 0; margin: 0" bgcolor="black"></td></tr>

      <tr bgcolor="#8888ff" id="header-row-2">

        <td align="left" id="header-section-context">

      <span class="page-breadcrumb">Search Results (Matching Books)</span>

        </td>

        <td align="left" id="header-section-search" width=70% colspan=2>

      <form action="http://www.bookfinder.com/search/" method="GET" accept-charset="iso-8859-1"name="header-search-form" id="header-search-form" class="header-search-form" >

      <div style="padding: 2px; font-size: small">

      <label style="display: none">Search Author, Title or ISBN   </label>

      <input style="font-size: small" id="header-search-form-input" name="keywords" type="text" value=""  size="45" tabindex="200">

          <input type="hidden" value="*" name="new_used">

        <input type="hidden" value="en" name="lang">

      <input type="hidden" name="st" value="sh">

      <input type="hidden" name="ac" value="qr">

      <button style="background-color: #ececff; font-size: small" type="submit" name="submit" tabindex="201">Go</button>

      </div>

      </form>

      <script type="text/javascript" language="javascript">

       $(document).ready(function(){

             $('#header-search-form').on('submit', function(){

                  var languageInputField = $("[name|=lang]");

                  if (languageInputField.length > 0) {

                     var language = $(languageInputField[0]).val();

                      if (language === 'any') {

                          var prefs = $.cookie('search_prefs');

                          if (!prefs) {

                              lang = 'no cookie';

                          } else {

                              var langIndex = prefs.indexOf('lang&');

                              if (langIndex === -1) {

                                  lang = 'not set';

                              } else {

                                  var searchStringLength = 'lang&'.length;

                                  var MAX_LANG_LENGTH = 3;

                                  var lang = prefs.substring(langIndex + searchStringLength, langIndex + searchStringLength + MAX_LANG_LENGTH);

                                  if (lang.indexOf('&') !== -1) { //language preference has a '&' on the end of it

                                    lang = lang.substring(0, lang.indexOf('&'));

                                  }

                              }

                          }

                          _gaq.push(['_trackEvent', 'AnyLanguage', lang,,,true]); 

                      }

                  }

              }); 

       });

       if (document && document.getElementById &&

          document.getElementById('header-search-form-input')) {

          var def = 'Search Author, Title or ISBN   ';

          var def_query = '';

          if (!def_query) {

            document.getElementById('header-search-form-input').style.color = '#8888ff';

            document.getElementById('header-search-form-input').value = def;

          }

          document.getElementById('header-search-form-input').onfocus =

              function() {

            if (this.value == def) {

      this.value = '';

      this.style.color = '';

          }

              };

          document.getElementById('header-search-form-input').onblur =

              function() {

          if ((! this.value) && (! this.value.length)) {

      this.style.color = '#8888ff';

      this.value = def;

          }

              };

          document.getElementById('header-search-form').onsubmit =

              function() {

          var input = document.getElementById('header-search-form-input');

          if (input && input.value && (input.value == def)) {

      input.value = '';

              input.focus();

      return false;

          }

              };

      }

      </script>

        </td>

      </tr>

      </table>

      <br>

        </div> <!-- end div header -->

      </div> <!-- end yui grids header -->

      <div id="bd-isbn"

      > <!-- start yui grids body -->

       

       

       

      <div itemscope itemtype="http://schema.org/Book">

          <div id="coverImageContainer" class="imageContainer">

          <img itemprop="image" id="coverImage" src="http://ecx.images-amazon.com/images/I/41X8h%2B0A9AL._SL250_.jpg" />

      </div>

      <div class="attributes"> 

          <div>

          ISBN is <h1 style="display: inline; font-size: 123.1%;">978-0-86327-210-3 / <span itemprop="isbn">9780863272103</span></h1>

          </div>

          <meta itemprop="name" content="9780863272103" />

          <div class="shipping-info-isbn">

              <strong>Prices INCLUDE standard shipping to United Kingdom</strong>

          </div>

          <div>

              <a href="http://www.bookfinder.com/search/?author=&title=&lang=en&isbn=086327210X&submit=Search&new_used=*&destination=gb&currency=GBP&mode=basic&st=sr&ac=qr&ps=bp" rel="nofollow">Show prices without shipping</a>

          </div>

          <div>

              <a href="http://www.bookfinder.com/?signed=&new=&destination=gb&search_level_us=0&min_year=&max_year=&maxprice=&isbn=086327210X&search_form_mode=basic&ebooks=&keywords=&lang=en&binding=&classic=&minprice_orig=&query_hash=%7B%27ac%27%20%3D%3E%20%27qr%27%2C%27author%27%20%3D%3E%20%27%27%2C%27currency%27%20%3D%3E%20%27GBP%27%2C%27destination%27%20%3D%3E%20%27gb%27%2C%27isbn%27%20%3D%3E%20%27086327210X%27%2C%27lang%27%20%3D%3E%20%27en%27%2C%27mode%27%20%3D%3E%20%27basic%27%2C%27new_used%27%20%3D%3E%20%27%2A%27%2C%27search_ebooks%27%20%3D%3E%201%2C%27search_new%27%20%3D%3E%201%2C%27search_used%27%20%3D%3E%201%2C%27st%27%20%3D%3E%20%27sr%27%2C%27title%27%20%3D%3E%20%27%27%7D&no_cache=0&search_type=isbn&author=&price_sort_order=tp&new_used=&currency=GBP&used=&title=&destination_country=gb&first_ed=&minprice=&id_query=&maxprice_orig=&numresults=100&&form_highlight=destination" rel="nofollow">Change shipping destination/currency</a>

          </div>

          <div class="shipping-info-isbn">

          Shipping prices may be approximate. Please verify cost before checkout.

          </div>

      </div>

      <div class="description">

      <h4 style="color: #8888FF; font-size:108%;">About the book:</h4>

      <div itemprop="description" id="bookSummary"><p>(What then of Ireland s future? What sort of society will exist here in the 1990s? This book raises some of the many crucial questions about that future. The contributors are leading Irish intellectuals, politicians and artists, known for their radical and innovative questioning - over half of whom are in their twenties or thirties, well-equipped to speak for a new generation of Irish people.</br>Among the issues examined here are these: what will the movement towards European integration mean for our status as an independent Nation State? Ho will it affect sovereignty, Northern Ireland, relationships with between the Republic and the North and Britain) </p></div>

      </div>

      <script type="text/javascript">

      $("#bookSummary").readmore({ moreLink: '<a href="#">Show more</a>',

                                       lessLink: '<a href="#">Show less</a>',

                                       maxHeight:222,

                                       afterToggle: function(trigger, element, expanded) {

                                          if (expanded) {

                                              $(element).css("overflow","visible");

                                          } else {

                                              $('html, body').animate( { scrollTop: element.offset().top }, {duration: 100 } );

                                              $(element).css("overflow", "hidden");

                                        }}});

      </script>

       

       

      <div id="progressbar-block" align="center" style="text-align: center; padding-bottom: 5em;">

       

        <div align="center">

          <div id="progressbar-outer">

            <div id="progressbar-completed"></div>

          </div>

        </div>

       

        <p><strong>Search under way...</strong></p>

       

       

       

       

      <noscript><small>20% done</small><br></noscript>

      <script language="JavaScript1.2" type="text/javascript">

      <!--

      if ((document.getElementById) && (document.getElementById('progressbar-completed')) && (document.getElementById('progressbar-completed').style)) {