6 Replies Latest reply: Oct 8, 2015 10:16 AM by neetha P RSS

    Problem with peek()

    Nicolas MARTIN

      Hello,

       

      I would like to loop on every value of a field, with the "peek" function.

       

      The following code works:

       

       

      Table1:
      LOAD * INLINE [
      Field1
      Aaa
      Bbb
      Ccc
      ];
      
      LET nbVal = FieldValueCount('Field1');
      
      FOR _i = 0 TO nbVal - 1
        LET _val = peek('Field1', _i);
        LET _res = MsgBox('$(_val)');
      NEXT _i
      
      

       

      This will pop up "Aaa", "Bbb" and "Ccc".

       

       

      But if I load another table between the table and the loop, it doesn't work anymore:

       

      Table1:
      LOAD * INLINE [
      Field1
      Aaa
      Bbb
      Ccc
      ];
      
      LET nbVal = FieldValueCount('Field1');
      
      Table2:
      LOAD * INLINE [
      Field2
      1
      2
      3
      ];
      
      FOR _i = 0 TO nbVal - 1
        LET _val = peek('Field1', _i);
        LET _res = MsgBox('$(_val)');
      NEXT _i
      
      

       

       

      I don't understand why loading another table prevents the "peek()" to succeed.

       

      If I'm adding the table:

       

      LET _val = peek('Field1', _i, 'Table1');
      

       

      it works.

       

      Does that means the function "peek" with 2 parameters is not reliable?