Videotex Page Definition

For a particular Videotex service a page definition is produced for each Videotex page. The page definition defines

The page definition is a list defined within a text file -- typically, one file would contain all the page definitions for a given Videotex service.

An example page definition is as follows:

(page "LOGON"

    (neighbours "START" 
                "NewsFlash" 
                "INDEX" 
                "SpecialOffers"
    )

    (matchFields

        (0 24 "0001")
    )

    (canMap

        (20 17 "ABTA")
    )

    (inputFields

        (user       20  29  5)
        (password   21  12  5)
        (reference  21  22  3)
        (prompts    21  38  1)
    )

    (extractFields

        (user       20  29  5)
        (password   21  12  5)
        (reference  21  22  3)
        (prompts    21  38  1)
    )

    #
    ## triggers
    #

    (before

        (if (mapper.isCursorOnAt 20 29)

            (mapper.newPageEvent.set)
        )
    )

    (hotPatch 20 29 

        (mapper.detectNewPage 20 29 "hotPatch")
    )

    (messageRow 23

        (Airtours_handleError mapper)
    )
)
The page definition is
  1. a list enclosed by parentheses
  2. starts with the symbol page
  3. contains multiple page elements each of which is a list which starts with a symbol

The order of page elements is not important.

Trigger Environment

Many of the page elements can contain Carapace script expressions to evaluate. For such expressions, the evaluation environment is fixed and the following script variables are defined:

name type description
expr Object the expression to evaluate
screen Screen the screen module which contains all the text on the Videotex page and can have data extracted from it
env HashTable the mapping environment -- the contents of this persist for the lifetime of the mapping session
page VideotexMapPage the definition of the current page being mpapp
upload HashTable data loaded into the mapper for upload to the service
mapper VideotexMapper the mapper object itself

Page Elements

The following table shows the types of page elements

element type description
neighbours defines the likely neighbouring pages for this page on the Videotex service -- this improves the search for identifying an incoming page
matchFields defines fields on screen which, when they all match the supplied data, provide a way to identify this screen and discriminate it from any other on the service
match a more general way of identifying a screen than the useful, but limited, matchFields
inputFields defines the locations, sizes etc. of the input fields for supplying data to the Videotex host
extractFields defines the locations, sizes etc. of areas on the page which hold data which should be extracted
options defines the options available on this page available for selection by the user
translateOption translates the option to the correct Videotex data
canMap defines a test to determine if the page is sufficiently complete so that it can be mapped
map defines the map to extract the data from the page and convert it into a more useful format
htmlTemplate name of the HTML template which is used for mapping this page -- only of relevance if the map is from Videotex to HTML
before a trigger which fires the first time the page is identified
after a trigger which fires when a Videotex 'reset' character is received -- since this destroys the current page
home a trigger which fires when the Videotex 'home' character is received which puts the cursor to position 0,0 but which does not clear the screen
cursorOn a trigger which fires when the cursor is turned on
cursorOff a trigger which fires when the cursor is turned off
messageRow a trigger which fires when a message is received on the supplied row of the screen -- this only fires when the cursor leaves that row after having entered it
hotPatch a trigger which fires when the cursor enters the given rectangular patch of the screen
exitZone a trigger which fires when the cursor leaves the given rectangular patch of the screen
hotText a trigger which fires when the given piece of text appears on screen at the supplied position
invariant a trigger which fires when the given piece of text is no longer on screen at the supplied position

Page Element: neighbours

Defines the likely neighbouring pages for this page on the Videotex service -- this improves the search for identifying an incoming page.

The search algorithm for identifying a page is as follows:

  1. the current page definition is re-tried -- to see if the page has been repeated/refreshed
  2. if no match, the list of pages which are marked as being neighbours of the most recent page are tested
  3. if not match, the entire list of pages is tested
Listing the neighbours of a page is an optimisation -- it simply speeds up the search for a matching page definition if neighbours exist and are appropriate!

Page Element: matchFields

Many Tour Operator services have a region on screen which is used as the page identifier -- this is equivalent to the page number in a book. The matchFields element defines regions on screen where certain pieces of text must exist for this page definition to match. Multiple such regions can be defined -- in this case all such text fragments must match for the page definition itself to match.

A more complicated example which will be satisfied only when both the words "Hello" and "THERE" are matched at the given positions -- note: matching is case sensitive:

    (matchFields

        (0 10 "Hello")
        (1 11 "THERE")
    )

For those services which are more cunning about page identification, see the match page element.

Page Element: match

The match page element contains the symbol match followed by a single Carapace script expression to evaluate. If the expression evaluates to () the empty List then the page is not matched -- otherwise, the page matches.

For example, if we identify a page by the existence of the word "Special-Offers" which may appear anywhere on screen, the following match element will work:

    (match  
    
        (screen.find "Special-Offers" 0 0)
    )

Page Element: inputFields

A list of fields on screen which are used for data input is defined in the inputFields page element as follows:

    (inputFields  
    
        fieldDefinition
        ....
        fieldDefinition
    )

Page Element: extractFields

The extractFields page element labels areas of the screen to extract -- these can then be mapped further to turn the page data into a more useful format.

    (extractFields  
    
        fieldDefinition
        ....
        fieldDefinition
    )

Page Element: options

Many Videotex pages offer the user a list of options -- evaluate of the second item in the options page element returns these options.

If this expression is a Symbol it is taken to be the name of a function which has the following prototype:

    (defun List functionName ( (screen Screen)
                               (page VideotexMapPage)
                               (env HashTable)
                             )
    )
In all other cases, the item is just evaluated an the resultant expression is required to be a List.

Some pages have a fixed list of options -- others require looking at the page data to determine if an option is available.

A simple options element is as follows:

    (options        (list "more" "previous" "index")
    )

Page Element: translateOption

The second item in the translateOption page element is an expression which takes the selected option and converts it into the relevant data to send to the Videotex host.

If this expression is a Symbol it is taken to be the name of a function which has the following prototype:

    (defun List functionName ( (option String)
                               (screen Screen)
                               (page VideotexMapPage)
                               (env HashTable)
                             )
    )
The resultant List must be an attribute-value list of values where the attributes match the names of input fields on the current Videotex page.

In all other cases, the item is evaluated. The evaluation result is allowed to be a String provided there is only one input field on the current page. Otherwise, the value must be an attribute-value list where the attributes match the names of input fields on the current Videotex page.

Page Element: canMap

The canMap page element forms the test to see if the page is sufficiently complete for mapping to take place -- the second item in the page element is the test expression.

If the test expression starts with an Integer, then it is required to identify a piece of text on screen e.g.

    (canMap

        (20 17 "ABTA")
    )
will test for the text ABTA appearing on screen at row 20, column 17.

In all other cases the test expression is evaluated -- if the result is the empty List () then mapping cannot proceed, otherwise the page is deemed complete.

One common such test is to check if the page cursor is on i.e.

    (canMap

        (screen.isCursorOn)
    )

Page Element: map

The map page element defines the mapping for the Videotex page -- e.g. this could extract the page data and turn it into an XML object. The second element in the page element is the map expression.

If the map expression is a Symbol it must be the name of a function with the following prototype:

    (defun Object functionName ( (screen Screen)
                                 (page VideotexMapPage)
                                 (env HashTable)
                               )
    )
In all other cases, the map expression is evaluated and the result returned as the extracted page information.

When used in conjunction with the XML Videotex Translator the returned object should be of type Xml.

Page Element: htmlTemplate

The htmlTemplate page element names the HTML template to be used for mapping this page -- only of relevance if the map is from Videotex to HTML.

E.g.

    (htmlTemplate       "logonPage.htm")

Page Element: before

The before page element defines the trigger which fires the first time the page is identified. The second element in the page element is the trigger expression.

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

A common before trigger is to record the detection of a new page e.g.

    (before

        (if (mapper.isCursorOnAt 20 29)

            (mapper.newPageEvent.set)
        )
    )
sets the new page event within the mapper when the cursor is on at row 20, column 29.

Page Element: after

The after page element defines the trigger which fires when the 'reset' Videotex character is received. This character moves the cursor to row 0, column 0 and clears the screen. The second element in the page element is the trigger expression.

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

A common after trigger is to store the extracted data from the page e.g.

    (after

        (env.set "history" (cons (mapper.mapCurrentPage) (env.get "history")))
    )

Page Element: home

The home page element defines the trigger which fires when the 'home' Videotex character is received. This character moves the cursor to row 0, column 0 without clearing the screen. The second element in the page element is the trigger expression.

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

Page Element: cursorOn

The cursorOn page element defines the trigger which fires when the Videotex service turns the cursor on for the current page. The second element in the page element is the trigger expression.

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

Page Element: cursorOff

The cursorOff page element defines the trigger which fires when the Videotex service turns the cursor off for the current page. The second element in the page element is the trigger expression.

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

Page Element: messageRow

The messageRow page element defines the row where messages are received and the trigger which fires when the Videotex service sends a message. Typically, Videotex services reserve a row (e.g. row numger 23) for the display of messages to the user.

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

A common messageRow trigger is one which ignores certain messages and raises an error on any others e.g.

    (messageRow 23

        (handleXYZserviceError mapper screen)
    )

Page Element: hotPatch

The hotPatch page element defines a rectangular region on screen where the trigger fires when the cursor enters that region. There are two forms of the hotPatch page element e.g.

    (hotPatch 10 20     (messageBox "HERE"))

    (hotPatch 10 20 2 3 (messageBox "HERE AGAIN"))
The first example defines a region which is a single character position -- the second defines one which is 2 rows by 3 columns in size.

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

Page Element: exitZone

The exitZone page element defines a rectangular region on screen where the trigger fires when the cursor leaves that region. There are two forms of the exitZone page element e.g.

    (exitZone 10 20     (messageBox "LEAVING HERE"))

    (exitZone 10 20 2 3 (messageBox "LEAVING HERE AGAIN"))
The first example defines a region which is a single character position -- the second defines one which is 2 rows by 3 columns in size.

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

This is a particularly useful trigger for extracting and storing the data from a page.

Page Element: hotText

The hotText page element defines a position on screen and a text fragment such that the trigger fires when that piece of text appears on screen at the given position e.g.

    (hotText 10 20 "Error"      (messageBox "GOT IT!!!"))

The result of the trigger expression evaluation is ignored -- the trigger is useful by its side effects.

Page Element: invariant

The invariant page element defines a position on screen and a text fragment such that the trigger fires when that piece of text is no longer on screen at the given position e.g.

    (invariant 10 20 "Error"      (messageBox "LOST IT!!!"))

The result of the optional trigger expression evaluation is ignored -- the trigger is useful by its side effects.


Contents Current topic: videotex Related topics: Carapace Hub