|
Sample Progams Overview
Writing and Running the Sample Programs
Menu Program
A Simple Quiz
Headline News Reader
Expression Evaluator
SheerPower 4GL Home
|
Headline News Program
Grab and display the latest Headline News! SheerPower 4GL makes
accessing Internet-based data easy. Very easy!
// To present the top news story from CNN.COM
// Note: From time to time CNN changes its format, so the
// main$ and end_main$ sometimes have to be changed.
main$ = '<div class="cnnT1Hd'
end_main$ = '</div>'
begin_form$ = '<form>' +
'<h1><font color=green>' +
'Top News from CNN' +
'</font></h1>' +
'<br><h2>'
news_ch = _channel
open #news_ch: name 'http://www.cnn.com'
crlf$=chr$(13)+chr$(10)
state$ = 'find_main'
do
line input #news_ch, eof eof?: text$
if eof? then exit do
select case state$
case 'find_main'
z0 = pos(text$, main$)
if z0 = 0 then repeat do
z0$ = mid(text$, z0+len(main$))
z0 = pos(z0$, '>')
if z0 = 0 then repeat do
z0$ = mid(z0$, z0+1)
dbox$ = begin_form$ +z0$
state$ = 'gather_news'
case 'gather_news'
z0 = pos(text$, end_main$)
if z0 > 0 then
dbox$ = dbox$ + left(text$, z0-1)
state$ = 'show_news'
repeat do
end if
dbox$ = dbox$ + text$ + crlf$
repeat do
case 'show_news'
// first add in the http://www.cnn.com to any anchors
dbox$ = replace$(dbox$, '<a href="==<a href="http://www.cnn.com/',',', '==')
// now finish off the input form with a single "submit" button
dbox$ = dbox$ + '</h2><p><input type=submit></form>'
line input dialogbox dbox$: ans$
exit do
end select
loop
end
|
Questions, comments and suggestions are welcome!
|