Yahoo! search interface: Difference between revisions

Content added Content deleted
(→‎{{header|Tcl}}: Corrections and improvements)
m (→‎{{header|Tcl}}: remove ugliness in first example)
Line 232: Line 232:
lappend results [fix $title] [fix $content] [fix $url]
lappend results [fix $title] [fix $content] [fix $url]
}
}

# set up the call for the next page
interp alias {} Nextpage {} YahooSearch $term [incr page]

return $results
return $results
}

# Ugly; uses global state variable but works with all current Tcl versions
proc Nextpage {term} {
incr ::page
return [YahooSearch $term $::page]
}
}


# Usage: get the first two pages of results
# Usage: get the first two pages of results
foreach {title content url} [YahooSearch "test"] {
set ::page 1
puts $title
set term "test"
}
foreach result_set [list [YahooSearch $term] [Nextpage $term]] {
foreach {title content url} $result_set {
foreach {title content url} [Nextpage] {
puts $title
puts $title
}
}</lang>
}</lang>
{{works with|Tcl|8.6}}
{{works with|Tcl|8.6}}