Data Channels

Lightwing can import dynamic data from files in CSV (Comma Separated Values) format via data channels and display that information with text or ticker commands. Use data channels for dynamic data which may change frequently or is easier to edit with a spreadsheet app such as Excel or GoogleDocs. A later tutorial shows how to use data channels to store user input from touch controls.

Lightwing can be configured to automatically restart when updated content is found in the updates folder, or data channels can be configured to periodically reload from updated files in the data folder, while the script continues to run.

In this example, the data command opens the CSV file named DataTutorial, creates a data channel of the same name and defines a periodic update time interval of one hour for this channel with the update option. An extension of .csv is assumed for data file names and they are located in the data folder. This command can be repeated for any number of data files and their corresponding channels will remain open throughout the entire script. Since this command is global in nature, it should appear before the first page, as shown. These data channels can then be used by commands on subsequent pages.

The limit option defines the maximum dimensions of the array for this channel in columns and rows, respectively. Any data items which exceed these dimensions will not be read from the file.

To display information from the data channel, text or ticker commands must use the data option with the name of an open data channel and use type options with text variable names (rather than the usual string constants in double quotes). Valid data text variables have names that begin with Data, such as DataItem, DataRow, DataColumn and DataBlock. These variables display individual items, rows of items, columns of items and blocks of items, respectively. Additionally, the index option can be used to index specific rows and columns in a data channel’s array, as shown.

The lines option defines the maximum number of lines (rows) that can be displayed by the text command. So, even though the data channel’s array might contain more rows (as read from the file), only the number of lines specified can be displayed. The default for this option is one line. Therefore, this option is required to enable the DataColumn and DataBlock variables to display multiple lines. The DataItem and DataRow variables can only display one line per text command, regardless.

Also refer to the online Lightwing script documentation for more details about these commands.

// Scripting Tutorial - Data Channels

version: 1.2
shadow: OpenSansRegular_30     offset: 4

// Open a data channel and read from CSV file.
data: DataTutorial     update: 1:00:00     limit: 3, 20

page: Menu time: 1 5 image: PlanetMercuryBackground.pvr

    // Menu with prices are in columns 0 and 1 of the data array.
      text: OpenSansRegular_30     fade: 1, 1     position: 40, 15      lines: 20     data: DataTutorial     type: DataColumn     index: 0, 0
      text: OpenSansRegular_30     fade: 1, 1     position: 60, 15      lines: 20     data: DataTutorial     type: DataColumn     index: 1, 0

    // Section labels in yellow are in column 2 of the data array.
     text: GalatiaRegular_40     fade: 1, 1     position: 38, 10     lines: 1     data: DataTutorial     type: DataItem     index: 2, 0 color: 1, 1, 0
     text: GalatiaRegular_40     fade: 1, 1     position: 38, 50     lines: 1     data: DataTutorial     type: DataItem     index: 2, 1 color: 1, 1, 0
     text: GalatiaRegular_40     fade: 1, 1     position: 38, 69     lines: 1     data: DataTutorial     type: DataItem     index: 2, 2 color: 1, 1, 0
     jump: Menu

 

 

<   RSS Channels                                             Introduction                                            Touch Branching  >