Problem with loop of array elements
JimAultWins at yahoo.com
Tue Nov 15 22:04:12 CST 2005
On 11/15/05 6:58 AM, Thomas Fischer <fischer at mail.sub.uni-goettingen.de>
Original email was about looping arrays and debugging.
Along a different line, I am offering a more universal way of getting URL
Thomas, another technique you might try is locating and using the href =
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,
.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
----------------- start copy here
put cd fld "SaveFile" into theSearchFileName
put url ("file:/" & theSearchFileName) into theSearchResult
replace numtochar(13) with empty in theSearchResult --we definitely don't
replace return with empty in theSearchResult --we definitely don't WANT
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
-- case INsensitive
put "(?i)href[^\" "e& "]+." into strToReplace -- -> (?Ui)href[^\"]+.
put replaceText(theSearchResult,strToReplace,(return&"MMMM"&sep)) into
--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
put "file:" & theSearchFileName & "-Links" into theSearchFileName
put foundURLs into URL theSearchFileName
----------------- end copy
More information about the use-livecode