ScriptEdit user’s guide

This document is currently being drafted

Basic Principles


Editor Interface

Main window

The interface consists of an icon toolbar for accessing editor functions, a setting panel on the left, a main entry window on the right and a status bar at the bottom of the window.

We will now see in detail the various elements of the interface.

The toolbar

Icon Usage 
TestOpen the search internet window to test the script. 
PrecompileCompile the 4 parts of the script and display errors. 
New scriptCreate a new script. 
Open scriptOpen a script. 
SaveSave the current script. 
Save AsSave the current script with a new name. 
SearchSearch text in the current edited text. 
HelpShow help. 
SettingsUser settings. 
QuitQuit the script editor. 

The sidebar

Information on the script

Information on the website

Input Help

The edit field

The status bar


Implementing a script

Exchanges between scripts and Filmotech

Analysis of received HTML pages

When an HTML page is received, it is then cut in lines, each being separate HTML tag. So for the next page :

<html>
  <head>
    <title>Page title</title>
  </head>
  <body>
    <h1>Main title</h1>
    <p>Here is a <strong>bold</strong> word.</p>
  </body>
</html>

Filmotech ScriptEdit will decode the page like this

<html>
<head>
<title>
Page title
</title>
</head>
<body>
<h1>
Main title
</h1>
<p>
Here is a
<strong>
bold
</strong>
word.
</p>
</body>
</html>

The fmt_ValeurLigne function retrieves each row of the page received. Thus cut, the analysis of the page will be easier.

When running the script, ScriptEdit displays a window containing the HTML analyzed. Use this window to search a text in the page, or a line number, to facilitate the development of the script.

Sequence of Actions


Script example

As an example let’s take the case of searching Filmstarts.

Title request

dim chaine as string
chaine = "http://www.filmstarts.de/suche/1/?q=" + ReplaceAll(fmt_MotsCles," ","+") 
fmt_EncodagePage ("UTF8")
fmt_RequeteListe( "GET", chaine )

Analysis of titles

dim i,j,k,l,m,n as integer
dim strSearch as string
dim strRef, strFilm as String
dim startLink as boolean
 
for i=0 to fmt_NombreLignes  - 1
  strSearch = "href='/kritiken/"
  j = instr( fmt_ValeurLigne( i) , strSearch )
  if j<> 0 then
    k = instr( fmt_ValeurLigne( i+1) , "img src=" )
    l = instr( fmt_ValeurLigne( i+1) , "alt=" )
 
    if k<>0 and l<>0 then
      strRef =  NthField( NthField(  fmt_ValeurLigne( i ), "'" , 2 ), "/",  3)
      strRef = Left(strRef, len( strRef) -5)
      strFilm = ""
      startLink = false
      for m = i+2 to fmt_NombreLignes  - 1
        if not startLink and  instr( fmt_ValeurLigne( m) , "a href=" ) <> 0 then
          startLink = true
        end if
        if startLink and instr( fmt_ValeurLigne( m) , "<" ) = 0 then
          strFilm = strFilm +  fmt_ValeurLigne( m)
        end if
        if startLink and instr( fmt_ValeurLigne( m) , "</a>" ) <> 0 then
          exit
        end if
      next
      fmt_MemoriseTitre ( strRef , strFilm )
    end if
  end if
next

Detail request

dim chaine as string
chaine = "http://www.filmstarts.de/kritiken/" + fmt_IdentifiantDetail + ".html"
fmt_RequeteDetail( "GET", chaine )

Analysis of details

dim chaine, chaine2, chaine3, text as string
dim i, j, k, l, indice, debut_1, fin_1 as integer
dim minRun as double
 
indice = 0
'Title/Year
for i=0 to fmt_NombreLignes - 1
  chaine = "<title>"
  j = instr( fmt_ValeurLigne( i ) , chaine )
  if j<>0 then
    text = left(  fmt_ValeurLigne( i+1 ), len(fmt_ValeurLigne( i+1 )) - 28 )
    text = trim(text)
    fmt_MemoriseValeur( "TitreVF" , text )
    text = mid( fmt_ValeurLigne( i+1 ), len(fmt_ValeurLigne( i+1 ))- 20, 4 )
    text = trim(text)
    fmt_MemoriseValeur( "Annee" , text )
    indice = i
    exit
  end if
next
 
'Cover
text = ""
for i=indice to fmt_NombreLignes - 1
  chaine = "<img src="
  j = instr( fmt_ValeurLigne( i ) , chaine )
  if j<>0 then
    text = NthField( fmt_ValeurLigne( i ) , "'" , 2 )
    fmt_RequeteImage( "GET" , text )
    indice = i
    exit
  end if
next
 
'Duration
text = ""
for i=indice to fmt_NombreLignes - 1
  chaine = "itemprop=""duration"
  j = instr( fmt_ValeurLigne( i ) , chaine )
  if j<>0 then
    text = NthField( fmt_ValeurLigne( i ) , """" , 4 )
    text = Replace(text,"PT","")
    text = Replace(text,"M","")
    minRun = 0
    if instr(text, "H") <> 0 then
      minRun = 60 *  Val( NthField( text, "H" , 1 ))
      minRun = minRun + Val( NthField( text, "H" , 2 ))
    else
      minRun = minRun + Val( text)
    end if
    indice = i
    exit
  end if
next
fmt_MemoriseValeur( "Duree" , Str(minRun ))

Some discussion of the analysis


The fmt_ functions

fmt_AfficheMessage

Displays a message in an alert window.

Syntax

fmt_AfficheMessagemsg )

Variable Type Description 
msg String Message to display 

Example 

fmt_AfficheMessage( "Error message" )

fmt_DebugMsg

Displays a message in the debug window when running the script.

Syntax

fmt_DebugMsgmsg , level )

Variable Type Description 
msg String Message to display 
level Integer Level of the message (optional) 

The levels

Level Icon Comment 
(No iconSimple message (default) 
Process OKOK 
Process errorError 
Process infoInformation 
Process alertWarning 

Example 

fmt_DebugMsg "Error message level 0" , 0
fmt_DebugMsg "Error message level 1" , 1
fmt_DebugMsg "Error message level 2" , 2
fmt_DebugMsg "Error message level 3" , 3
fmt_DebugMsg "Error message level 4" , 4

Display in the debug window:

fmt_DernierTitre

Returns the last title stored in the list. Can be used to add additional information.

Syntax

result = fmt_DernierTitre

Variable Type Description 
result String The last title stored 

Example 

dim last_title as String
last_title = fmt_DernierTitre

fmt_EncodagePage

Sets the encoding of the HTML page returned by the site. Currently the possible parameters are ISOLATIN1 and UTF8.

Syntax

fmt_EncodagePageencoding )

Variable Type Description 
encoding String The encoding format, ISOLATIN1 or UTF8

Example 

fmt_EncodagePage("UTF8")

fmt_EncodeURL

Encode URLs components of the string passed as parameter.

Syntax

result = fmt_EncodeURLurl_to_encode )

Variable Type Description 
result String Encoded string 
url_to_encode String String to encode 

Example 

Dim encoded_string as string
encoded_string = fmt_EncodeURL("www.Bob&Ray.com") // returns "www.bob%26ray.com"

fmt_HeaderDetail

Fill the HTTP header field before sending the detail query.

Syntax

fmt_HeaderDetailfield , value )

Variable Type Description 
field String The name of the HTTP header field
value String The value of the field 

Example 

fmt_HeaderDetail( "Accept-Language" , "en" )

fmt_HeaderListe

Fill the HTTP header field before sending the list query.

Syntax

fmt_HeaderListefield , value )

Variable Type Description 
field String The name of the HTTP header field
value String The value of the field 

Example 

fmt_HeaderListe( "Accept-Language" , "en" )

fmt_IdentifiantDetail

Returns the ID of the film selected by the user in the list.

Syntax

result = fmt_IdentifiantDetail

Variable Type Description 
result String ID of the film 

Example 

dim ID as string
ID = "http://www.filmstarts.de/kritiken/" + fmt_IdentifiantDetail + ".html"

fmt_MemoriseDernierTitre

fmt_MemoriseTitre

fmt_MemoriseValeur

fmt_MotsCles

fmt_NombreLignes

fmt_RequeteDetail

fmt_RequeteImage

fmt_RequeteListe

fmt_RequetePageSuivanteListe

fmt_Valeur

fmt_ValeurLigne