Problem with loop of array elements
Jim Ault
JimAultWins at yahoo.com
Tue Nov 15 23:04:12 EST 2005
On 11/15/05 6:58 AM, Thomas Fischer <fischer at mail.sub.uni-goettingen.de>
wrote:
Original email was about looping arrays and debugging.
Along a different line, I am offering a more universal way of getting URL
links.
Thomas, another technique you might try is locating and using the href =
³www.url.com² string.
This may not be suitable for your purpose, however.
It also does not explain the debugger anomaly you saw.
Unless you have a web page that contains thousands of urls, this should be
fast enough for you.
This assumes there could be various forms of HTML code, where the programmer
uses returns to make it look good to the eye, but the browser simply ignores
them. Thus the following (3) URL variations are identical to the browser
-------------
<a href=²www.bigbusiness.com/product334.html² name = ³Lamp334²>Desk Lamp,
black</a>
<a href=²www.bigbusiness.com/
product334
.html² name = ³Lamp334²>Desk Lamp, black</a>
<a name=³Lamp334² href = ²www.bigbusiness.com/
product334.html² >Desk Lamp, black</a>
------------------
--putting all of the above lines in the same container will resolve to 3
lines of
www.bigbusiness.com/product334.html
www.bigbusiness.com/product334.html
www.bigbusiness.com/product334.html
----------------- start copy here
on mousedoubleup
put cd fld "SaveFile" into theSearchFileName
put url ("file:/" & theSearchFileName) into theSearchResult
replace numtochar(13) with empty in theSearchResult --we definitely don't
WANT returns
replace return with empty in theSearchResult --we definitely don't WANT
returns
replace numtochar(210) with quote in theSearchResult curly quote
replace numtochar(211) with quote in theSearchResult curly quote
put numtochar(160) into sep --
--Thomas, you used "<p class=g>" but I am not sure of the reason
--using the power of regular expressions [regex]...
--we are looking for either (href=") or (href = ") or (href =") or
(href=")
-- case INsensitive
put "(?i)href[^\" "e& "]+." into strToReplace -- -> (?Ui)href[^\"]+.
put replaceText(theSearchResult,strToReplace,(return&"MMMM"&sep)) into
crudeLines
--now only the lines we want all begin with MMMM
filter crudeLines with ("MMMM"&sep&"*")
--we now have only those lines we want
replace quote with sep in crudeLines --sets the trailing quote to sep
set the itemDel to sep
--keep only item 2 of each line
repeat with x = 1 to the number of lines in crudeLines
put item 2 of line x of crudeLines into line x of foundURLs
end repeat
breakpoint
put "file:" & theSearchFileName & "-Links" into theSearchFileName
put foundURLs into URL theSearchFileName
end mousedoubleup
----------------- end copy
Jim Ault
Las Vegas
More information about the use-livecode
mailing list