!Teletext Script
Annotated version of 'eurorate'

 

This generates the following output:

             12/05/2003 18:46 GMT   
                                    
Euro:Pound rate  :   1.3928 (0.7179)
Dollar:Euro rate :   1.1559         
Euro:Austr$ rate :   0.7514         
                                    
Euro    Pound   Dollar  Australia$  
----------------------------------  
  5      3.58     5.77    3.75      
 10      7.17    11.55    7.51      
 15     10.76    17.33   11.27      
 20     14.35    23.11   15.02      
 25     17.94    28.89   18.78      
 30     21.53    34.67   22.54      
 35     25.12    40.45   26.29      
 40     28.71    46.23   30.05      
 45     32.30    52.01   33.81      
 50     35.89    57.79   37.56      
 55     39.48    63.57   41.32      
 60     43.07    69.35   45.08      
 65     46.66    75.13   48.84      
 70     50.25    80.91   52.59      
 75     53.84    86.69   56.35      
 80     57.43    92.47   60.11      
 85     61.02    98.25   63.86      
 90     64.61   104.03   67.62      
 95     68.20   109.81   71.38      
100     71.79   115.59   75.13      
                                    
                                    
             15/05/2003 20:21 GMT   
                                    
Euro:Pound rate  :   1.4246 (0.7019)
Dollar:Euro rate :   1.1383         
Euro:Austr$ rate :   0.7294         
                                    
Euro    Pound   Dollar  Australia$  
----------------------------------  
  5      3.50     5.69    3.64      
 10      7.01    11.38    7.29      
 15     10.52    17.07   10.94      
 20     14.03    22.76   14.58      
 25     17.54    28.45   18.23      
 30     21.05    34.14   21.88      
 35     24.56    39.84   25.52      
 40     28.07    45.53   29.17      
 45     31.58    51.22   32.82      
 50     35.09    56.91   36.47      
 55     38.60    62.60   40.11      
 60     42.11    68.29   43.76      
 65     45.62    73.98   47.41      
 70     49.13    79.68   51.05      
 75     52.64    85.37   54.70      
 80     56.15    91.06   58.35      
 85     59.66    96.75   61.99      
 90     63.17   102.44   65.64      
 95     66.68   108.13   69.29      
100     70.19   113.83   72.94      
                                    
                                    
             16/05/2003 20:21 GMT   
                                    
Euro:Pound rate  :   1.4023 (0.7131)
Dollar:Euro rate :   1.1581         
Euro:Austr$ rate :   0.7567         
                                    
Euro    Pound   Dollar  Australia$  
----------------------------------  
  5      3.56     5.79    3.78      
 10      7.13    11.58    7.56      
 15     10.69    17.37   11.35      
 20     14.26    23.16   15.13      
 25     17.82    28.95   18.91      
 30     21.39    34.74   22.70      
 35     24.95    40.53   26.48      
 40     28.52    46.32   30.26      
 45     32.09    52.11   34.05      
 50     35.65    57.90   37.83      
 55     39.22    63.69   41.61      
 60     42.78    69.48   45.40      
 65     46.35    75.27   49.18      
 70     49.91    81.06   52.96      
 75     53.48    86.85   56.75      
 80     57.04    92.64   60.53      
 85     60.61    98.43   64.31      
 90     64.18   104.22   68.10      
 95     67.74   110.01   71.88      
100     71.31   115.81   75.67      
What you see above represents running the script three times, on the 12th of May, the 15th of May, and on the 16th of May. Output is appended the the existing data. It would be a small matter to, say, write a little program to draw a bar chart of the currency rate fluctuations over the course of a month, or whatever.
Here's a really quick 'example' I threw together, not five minutes ago...
Currency chart example; JPEG 11K

 

When we begin, we'll select the channel, and force two polls to allow the hardware to settle. The reason for this is because we then check the channel ID ourselves, and only prompt the user if we're not tuned to CNN.

There are no further annotations, as this script is commented; save to mention that the offsets are fixed to read the 'ASK' currency rate; as CNN shows us BID, ASK, HIGH, and LOW rates. For example:

733.4H  CNNTEXT P748 Fri 16 May 22:56:20
 x,,hl0<thh  CURRENCIES 
 5>£j+52oj Euro Spot Rates             
 5mpzjm0?tj  16/05/2003 20:21 GMT  4/9  
 +,,,. -%*. 
      BID      ASK      HIGH     LOW    
 USD  1.1578   1.1581   1.1579   1.1371 
 JPY  134.17   134.24   135.00   131.73 
 GBP  0.6163   0.6161   0.6143   0.6193 
 CHF  1.5134   1.5142   1.5344   1.4856 
 ASIA/PACIFIC ,,,,,,,,,,,,,,,,,,,,,,,,,,
 AUD  0.7560   0.7567   0.7564   0.7278   <--- AUD on line 12
 HKD  9.0298   9.0324   9.0310   8.8629 
 INR    -        -        -        -    
 JPY  134.17   134.24   135.00   131.73 
 MYR    -        -        -        -    

              /|\
               |
               '--- coming in 15 places brings us here

So, here's the script:
; EuroRate

channel(5)
poll_now()                    ; let it take effect
poll_now()                    ; before channel check

.channelcheck
  channelid(A)
  if (A ! &804F) message("Please set satellite receiver to CNN.")
  if (A ! &804F) go("channelcheck")


; First we want to get the pound/euro spot (asking) rate.
; At 2003/05/12, the -Euro rate was 1.3920 and the
; Euro- rate was 0.6211. Eagle-eyed observers may
; notice a rather large discrepancy, as the -Euro
; rate, worked in reverse, comes out to be 0.7165!
; So we look for each induhvidual rate, for a "worst
; case" (and thus, more reliable) result.
getframe(734)                 ; any will do
find(B,"EUR",7)
if (B = 0) error("Can't find GBP rate")
readvalue(R,15,7)             ; pound ask in R

; Now we look for the Australian dollar rate.
getframe(733)
.getaustralia
  find(B,"AUD",12)
  if (B = 0) getframe(733)
  if (B = 0) go("getaustralia")
readvalue(T,15,12)            ; australian $ in T

; Now get the dollar/euro spot (asking) rate.
; At 2003/05/12, the $-Euro is 1.1569 and the Euro-$
; is given as 1.1569. I can only imagine both are
; quoted in the Euro-$ direction!

find(B,"USD",7)
if (B = 0) error("Can't find US$ rate")
readvalue(S,15,7)             ; dollar ask in S

; turn off polling, now, to speed it up a little
poll_nomessages()
poll_disable()

; remove mosaic characters and page count
set A to 1
.clearloop
  setchar(A,4,32)
  A++
  if (A [ 11) go("clearloop")
setchar(35,4,32)
setchar(36,4,32)
setchar(37,4,32)
setchar(38,4,32)

; open file
fileupdate("<Teletext$Temp>.EuroConv")

; the header
appendline(4,2)
filewritebyte(10)
filewritebyte(10)
filewritestring("Euro:Pound rate  : ")
filewritefloat(R,3,4)
filewritestring(" (")
div(V,1,R)
filewritefloat(V,1,4)
filewritestring(")")
filewritebyte(10)
filewritestring("Dollar:Euro rate : ")
filewritefloat(S,3,4)
filewritebyte(10)
filewritestring("Euro:Austr$ rate : ")
filewritefloat(T,3,4)
filewritebyte(10)
filewritebyte(10)

filewritestring("Euro    Pound   Dollar  Australia$")
filewritebyte(10)
filewritestring("----------------------------------")
filewritebyte(10)

; the conversion loop
set L to 5
.convloop
  div(X,L,R)                  ; Y = euro->pound
  mul(Y,L,S)                  ; X = euro->dollar
  mul(Z,L,T)                  ; Z = euro->aus$

  filewritevar(L,3)
  filewritestring("     ")
  filewritefloat(X,2,2)
  filewritestring("   ")
  filewritefloat(Y,3,2)
  filewritestring("  ")
  filewritefloat(Z,3,2)
  filewritebyte(10)

  add(L,5)
  if (L [ 100) go("convloop")

.finish
filewritebyte(10)
filewritebyte(10)
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>.EuroConv", &FFF)
oscall("Filer_Run <Teletext$Temp>.EuroConv")
poll_now()                    ; poll, so file has a chance to load
pushkey(&1AE)                 ; Ctrl-cursordown

; we're done
terminate()

Return to !Teletext index
Copyright © 2003 Richard Murray