This annotation is provided with the StrongHelp version of the script interpreter documentation.
This script will read the weather in Nantes, from the CNN european cities weather report.
It displays the weather as is shown in the teletext frame. It then reads the celsius temperature,
and calculates from it a Fahrenheit temperature. While these latter functions are not strictly
necessary, it does allow us to demonstrate the find() command, and various
mathematical functions.
The output is written to a file which is updated each time the script is run. It is written as:
Mon 12 May NANTES 15 59 partly sunny Temperature for Nantes : 15, in Fahrenheit: 59.0
This script has the comments colourised, but there are no further explanations. Hopefully it'll be fairly simple to see what is happening, and why.
; WthrNantes
channel(5)
.channelcheck
channelid(A)
if (A ! &804F) message("Please set satellite receiver to CNN.")
if (A ! &804F) go("channelcheck")
getframes(463)
set F to status(frames)
; turn off polling to speed it up a little
poll_nomessages()
poll_disable()
fileupdate("<Teletext$Temp>.WthrNantes")
set G to 2
.frameloop
selectframes(463, G)
set L to 2
.lineloop
find(B,"NANTES",L) ; case sensitive
if (B = 0) go("continue") ; no Nantes here...
; got Nantes
setchar(35,5,32) ; remove 'x/x' pagecount
setchar(36,5,32)
setchar(37,5,32)
appendline(5,2) ; the date
filewritebyte(10)
appendline(L,2) ; the report line
filewritebyte(10)
; work out the temperature
add(B,15)
readvalue(M,B,L)
filewritestring("Temperature for Nantes : ")
filewritevar(M,2) ; allows "-9" to "99"
filewritestring(", in Fahrenheit: ")
set Z to M ; Fahrenheit is...
add(Z,40) ; Celsius plus 40
mul(Z,Z,9) ; multiplied by nine
div(Z,Z,5) ; divided by five
sub(Z,40) ; minus 40
filewritevar(Z,1)
filewritebyte(10)
filewritebyte(10)
go("finish") ; don't need to scan any further
.continue
L++
if (L [ 24) go("lineloop")
G++
if (G [ F) go("frameloop")
.finish
fileclose()
; re-pollify
poll_enable
; reopen "the usual" windows
getframe(100) ; force it back to 'index'
showviewer()
showcontrols()
poll_now() ; extra poll for windowopens
; ensure file is Text, then run file (loads into !Edit (etc))
filetype("<Teletext$Temp>.WthrNantes", &FFF)
oscall("Filer_Run <Teletext$Temp>.WthrNantes")
poll_now() ; poll, so file has a chance to load
pushkey(&1AE) ; Ctrl-cursordown
; we're done
terminate()