Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, everybody.
I have a table [URLS] with a field [URL], which contains the web address.
I want to make a script, which would proceed through this table and load a certain data, for example, age information from web addresses in each field.
I made script similar to this:
set i = 0;
for i = 0 to 1000
let v_url = PEEK('URL',i,'URLS');
[Data]:
LOAD [Age:] as [Age]
FROM
$(v_url)
(html, unicode, embedded labels, table is @4);
next i
Script works only for the first iteration. After that it for some reason does not recreate v_url variable, it is empty and script fails.
What am I doing wrong?
Thanks in advance!
Hi
I've had problems using peek in situations like this. Can't really remember why but I've used fieldvalue instead successfully.
Something like this:
let noOfRows = noOfRows('URLS');
for i=1 to $(noOfRows)
let v_url = fieldvalue('URL', $(i));
LOAD [Age:] as [Age]
FROM
$(v_url)
(html, unicode, embedded labels, table is @4);
next
Note that fieldvalue returns the value from the field itself, not the value on a specific row within the table.
If you have duplicate values in the URL field you won't get the expected result.
I've solved this by adding a rownumber to the URL field to create unique values and then remove the rownumber when reading from the url.
/Fredrik
Hello,
Try
LET v_url = PEEK('URL, $(i), 'URLS')
Same result, unfortunately.
First, sorry for my syntax errors in my previous post. Have you tried with
instead of LET?SET v_url = PEEK('URL', $(i), 'URLS');
To variable v_url in this case is assigned the string ' PEEK('URL', $(i), 'URLS')' itself, instead of the value from URL field.
Indeed. That's what you assign, but then it will be evaluated via macro expansion with $(v_url). LET evaluates expression before being assigned. As far as I understand, you want to look for the name of the record. So thus should work.
Well, it did not evaluate. I received the error message, which notified that table PEEK can' t be opened (instead of web address there was PEEK('URL', $(i), 'URLS') string in FROM part of LOAD statement).
Hi
I've had problems using peek in situations like this. Can't really remember why but I've used fieldvalue instead successfully.
Something like this:
let noOfRows = noOfRows('URLS');
for i=1 to $(noOfRows)
let v_url = fieldvalue('URL', $(i));
LOAD [Age:] as [Age]
FROM
$(v_url)
(html, unicode, embedded labels, table is @4);
next
Note that fieldvalue returns the value from the field itself, not the value on a specific row within the table.
If you have duplicate values in the URL field you won't get the expected result.
I've solved this by adding a rownumber to the URL field to create unique values and then remove the rownumber when reading from the url.
/Fredrik
This worked, thanks!
Still, it was a strange problem.