2 Replies Latest reply on Aug 23, 2013 12:55 AM by try67

    Problem with javascript in Action

    Peter Hvirring

      I have a small problem with this script, I can not get it to work.

       

      function GreateLink()
      {
         {
             for (var p = 0; p < this.numPages; p++)
                {
                 var numWords = this.getPageNumWords(p);
                 for (var i=0; i<numWords; i++)
                      {
                       var ckWord = this.getPageNthWord(p, i, true);
                       if (ckWord == catWord)
                          {
                              var q = this.getPageNthWordQuads(p, i);
                              // Convert quads in default user space to rotated
                              // User space used by Links.
                              m = (new Matrix2D).fromRotated(this,p);
                              mInv = m.invert()
                              r = mInv.transform(q)
                              r = r.toString()
                              r = r.split(",");
                              l = addLink(p, [r[4], r[5], r[2], r[3]]);
                              l.borderColor = color.red;
                              l.borderWidth = 1;
                              l.setAction("this.getURL('http://www.molehunter.com/')");
                          }
                      }
                  }
              }

          {
             catWord == "Electricity"
             l
          }
          {
             catWord == "drill"
             l
          }

       

      }

       

       

      Here is the same but in a different variant where I want to make a string that is global

       

      Package
        {
            public var catWord;
        }

       

         for (var p = 0; p < this.numPages; p++)

          {
             var numWords = this.getPageNumWords(p);
             for (var i=0; i<numWords; i++)
             {
                var ckWord = this.getPageNthWord(p, i, true);
                if (ckWord == catWord)
                {
                   var q = this.getPageNthWordQuads(p, i);
                   // Convert quads in default user space to rotated
                   // User space used by Links.
                   m = (new Matrix2D).fromRotated(this,p);
                   mInv = m.invert()
                   r = mInv.transform(q)
                   r = r.toString()
                   r = r.split(",");
                   l = addLink(p, [r[4], r[5], r[2], r[3]]);
                   l.borderColor = color.red;
                   l.borderWidth = 1;
                   l.setAction("this.getURL('http://www.molehunter.com/')");
                 }
               }
             }
          }


      this.pageNum = 0;
       

      function GreateLink()
      {
          {
             catWord == "Electricity"
             l
          }
          {
             catWord == "drill"
             l
          }

       

      }

       

      Some suggestions on how I can get it to work