## ConditionalReader

`ConditionalReader` (clip, string filename, string variablename, bool "show")

`ConditionalReader` allows you to import information from a text file, with different values for each frame - or a range of frames.

### Parameters

Parameter | Description | Default
clip | The input clip. It is not touched, unless you specify show=true. | Not optional
filename | The file with the variables you want to set. | Not optional
variablename | The name of the variable you want the information inserted into. | Not optional
show | When set to true, the value given at this frame will be overlayed on the image. | false

### File format

The file is plain text. All separation is done by spaces, and newline indicates a new data set. It is not case sensitive!
TYPE (int|float|bool)

You can only have one type of data in each file. Currently it is possible to have float, int or bool values. You specify this by using the TYPE keyword. You should always start out by specifying the type of data, as nothing is saved until this keyword has been found. It is not possible to change type once it has been set!

DEFAULT <value>

This specifies the default value of all frames. You should do this right after specifying the type, as it overwrites all defined frames. You can ommit this setting, you you must be sure to specify a setting for all frames, as it will lead to unexpected results otherwise.

<framenumber> <value>

This will set the value only for frame <framenumber>.

R <startframe> <endframe> <value>

This will apply a value to a range of frames. You should note that both start AND end-frame are included.

I <startframe> <endframe> <startvalue> <stopvalue>

This will interpolate between two values over a range of frames. This only works on int and float values. You should note that both start AND end-frame are included.

### Types

As mentioned, the types can be either float, int or bool.
Int numbers is a number optionally preceeded with a sign.
Float is a decimal number containing a decimal point, optionally preceded by a sign and optionally followed by the e or E character and a decimal number. Valid entries are -732.103 or 7.12e4.
Bool can either be true or false.

### Examples

#### Basic usage

File.txt:

    Type float
    Default 3.45567

    R 45 300 76.5654
    2 -671.454
    72 -671.454

The file above will return float values. It will by default return 3.45567. However frames 45 to 300 it will return 76.5654. And frame 2 and 72 will return -671.454.
As you might notice - later changes overrule settings done earlier in the file. This is illustrated by frame '72' - even though it is inside the range of 45-300, the later value will be returned. On the other hand - if the range was specified AFTER '72 -671.454' - it would return 76.5654.
A script to invoke this file could be:

    colorbars(512,512)
    trim(0,500)
    ScriptClip("subtitle(string(myvar))")
    ConditionalReader("file.txt", "myvar", false)

This will put the values into the variable called "myvar", which is used by Subtitle, invoked by ScriptClip to display the conditional value.

#### Adjusting Overlay

AviSynth script:

    colorbars(512,256)
    a1 = trim(0,600)
    a2 = MessageClip("Text clip")
    overlay(a1,a2, y = 100, x = 110, mode="subtract", opacity=0, pc_range=true)
    ConditionalReader("opacity.txt", "ol_opacity_offset", false)
    ConditionalReader("xoffset.txt", "ol_x_offset", false)

xoffset.txt:

    Type int
    Default -50

    I 25 50 -50 100
    R 50 250 100
    I 250 275 100 250

opacity.txt:

    Type float
    Default 0.0

    I 25 50 0.0 1.0
    R 50 250 1.0
    I 250 275 1.0 0.0

Basically it defines keyframes for an x-offset and the opacity. Frame 25->50 the opacity is scaled from 0.0 to 1.0, while the text is moving from left to right. The text is then kept steady from frame 50 to 250, whereafter it moves further to the right, while fading out.
It is easier to watch the clip above than completely describe what it does.

`$Date: 2005/10/03 16:31:31 $`