Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
srihitha
Contributor III

Peek function

tab1:

load * Inline
[Dat, Countr, Produc, Amoun
2022-01-20, Canada, Washer, 6];


tab12:
load Dat,Peek('Dat') resident tab1;       //gives null value
let v1=Peek('Dat');        //gives date value
trace v1 is $(v1);

How are these two different : Peek in load statement and Peek in variable

 

Labels (4)
1 Solution

Accepted Solutions
hic
Former Employee

The Load statement loops over the tab1 table, so when it reads row 1, the Peek() function will try to read from the previous row. But since this doesn't exist, Peek() will return NULL. If there had been a 2nd row, the Peek() would have returned the "Dat" from row 1.

The Let statement does not loop over the tab1 table. Instead the Peek() just looks in the existing table, and picks out an existing value. If no row number is specified, it will pick the last row, i.e. '2022-01-20'.

View solution in original post

1 Reply
hic
Former Employee

The Load statement loops over the tab1 table, so when it reads row 1, the Peek() function will try to read from the previous row. But since this doesn't exist, Peek() will return NULL. If there had been a 2nd row, the Peek() would have returned the "Dat" from row 1.

The Let statement does not loop over the tab1 table. Instead the Peek() just looks in the existing table, and picks out an existing value. If no row number is specified, it will pick the last row, i.e. '2022-01-20'.