3 Replies Latest reply: Apr 3, 2017 7:32 PM by Brian MacDonald RSS

    Strange problem with script

    Brian MacDonald

      Here is a snippet of a script that I am working on:

      DataRaw:

      LOAD * Inline [

      path, path_count

      'String1',2

      'String2',1

      'String3',1

      'String4',2

      'String5',1

      'String6',1

      ];

       

      Let numRows = NoOfRows('DataRaw');

      For myRow = 1 to NoOfRows('DataRaw')

        Let vFld = FieldValue('path',myRow);

          Let vCount = FieldValue('path_count',myRow);

          Let myPlace = 1;

      Next myRow

       

      The first two rows of the data process just fine but I am getting Null for the value of vCount at the third row and every row after that.  Here is my debug output.

       

      2017-04-03_17-27-58.jpg

       

      What am I doing wrong?

        • Re: Strange problem with script
          Craig Sutton

          I got the same result.  What about using Peek?  I had better luck with Peek.

           

          DataRaw:
          LOAD * Inline [
          path, path_count
          'String1',2
          'String2',1
          'String3',1
          'String4',2
          'String5',1
          'String6',1
          ]
          ;


          Let numRows = NoOfRows('DataRaw');

          For myRow = 0 to (NoOfRows('DataRaw')-1)
          Let vFld = Peek('path', myRow, 'DataRaw');
          // Let vFld = FieldValue('path',myRow);
          Let vCount = Peek('path_count', myRow, 'DataRaw');
          // Let vCount = FieldValue('path_count',myRow);

          Let myPlace = 1;

          Next myRow

          • Re: Strange problem with script
            Brian MacDonald

            Well after much hair pulling the solution seemed to be to use the Peek function instead of FieldValue and also specify the table name.  Additionally the first record for use with Peek is record 0.

             

            So the script should look like this...

             

            For myRow = 0 to NoOfRows('DataRaw')-1

              Let vFld = Peek('path',myRow,'DataRaw');

                Let vCount = Peek('path_count',myRow,'DataRaw');

                Let myPlace = 1;

            Next myRow

            • Re: Strange problem with script
              Brian MacDonald

              We were typing at the same time.  I'll mark yours as correct.