Lightwing features several branching commands that can alter the normal script execution order to form loops and subroutines. Previous examples use unconditional jump commands to form continuous loops of pages. This example uses a conditional jump command on the page named Loop to branch to one of seven pages depending upon the current day of the week.
The criteria for selecting the target page for the jump is defined by the index option. The Day condition selects a page for the current day of the week. The other valid condition names for the index option are, Hour, Month and Count. Up to 24 branch page names can be listed, if appropriate for the branch condition. If the value of the index condition is greater than the number of pages listed, the jump command is ignored.
The page named Pluto displays the current date and uses the count option to form a loop which repeats 3 times before falling through to exit. There are other condition options to the jump command named day, before, after and portrait which can branch based on specific dates or the orientation of the display.
Notice that the page named Loop has no time option. This is a zero-time page that serves only to perform the jump. This is necessary because only a single branching command is allowed per page.
Look at the output in the Lightwing log window or file (lightwing\Log.txt) to see the script execution flow. Also refer to the online Scripting Guide for more details about these commands.
// Scripting Tutorial - Branching version: 1.0 shadow: OpenSansBold_100 offset: 5 // Jump to one of seven planet pages based on the day of the week. page: Loop jump: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday index: Day page: Sunday time: 1, 3 image: PlanetMercuryBackground.pvr text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 50 align: CenterCenter type: "Sunday on Mercury!" jump: Pluto page: Monday time: 1, 3 image: PlanetVenusBackground.pvr text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 50 align: CenterCenter type: "Monday on Venus!" jump: Pluto page: Tuesday time: 1, 3 image: PlanetEarthBackground.pvr text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 50 align: CenterCenter type: "Tuesday on Earth!" jump: Pluto page: Wednesday time: 1, 3 image: PlanetMarsBackground.pvr text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 50 align: CenterCenter type: "Wednesday on Mars!" jump: Pluto page: Thursday time: 1, 3 image: PlanetJupiterBackground.pvr text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 50 align: CenterCenter type: "Thursday on Jupiter!" jump: Pluto page: Friday time: 1, 3 image: PlanetSaturnBackground.pvr text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 50 align: CenterCenter type: "Friday on Saturn!" jump: Pluto page: Saturday time: 1, 3 image: PlanetUranusBackground.pvr text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 50 align: CenterCenter type: "Saturday on Uranus!" // Display current date and loop to repeat 3 times. page: Pluto time: 1, 3 transition: Radar image: PlanetPlutoCharonBackground.pvr text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 50 align: CenterCenter type: "Today is:" text: OpenSansBold_100 time: 1, 2 fade: 1, 1 position: 50, 70 align: CenterCenter type: DateLong jump: Loop count: 3