Data List Structures in SCL

Alternatively, read about data pairs here.

It is not uncommon to want to provide a list of data that your animations can use. This can be done with "create data as list". For now, only 'list' is supported but it provides a rudimentary column/row mechanism. 'data' also provides several methods with which to access your data. First, an example data statement:
Example:
create data from list as MyList
    where completion=Done
    set
      1 2 3
      4 5 6
end
Data lists are accessed through by referencing the list, plus an access method. For example:
x=data.MyList.next and y=data.MyList.next
The above code will retrieves the next 2 consecutive numbers in the list. The access methods are:
Each access method can be followed by a period then a number. That number is called the 'skip'. Therefore, if I want every third number, I skip 3:
image=data.ImageList.next.3
You can also use a skip for for pluck, prev, and select.
There is also a "completion" event that fires when the list is completed. However this is a little wonky at the moment:
Example
create data from list as grid
  where completion=Done
  set
    a b
    c d
end

create routine as Start
  trace into "mytrace" where value=data.grid.pluck.2
  trace into "mytrace" where value=data.grid.next
  trace into "mytrace" where value="-------------------------------"
  trace into "mytrace" where value=data.grid.pluck.2
  trace into "mytrace" where value=data.grid.next
  trace into "mytrace" where value="-------------------------------"
end

create routine as Done
  trace into "mytrace" where value="DONE"
end
In the above example, either row will be chosen at random. The first item of a row is selected with 'pluck', then the rest of the row can be retrieved with 'next'. Note however that the completion event will fire twice: once when the last pluck is retrieved, and since when the last next is retrieved.

Iteratoring Items to a Routine

You may want to iterate over an entire list passing each item to a routine. This can be done by referencing the list in the repeat parameter:
run routine ships where repeat=data.BCList.3
The trailing number indicates the list should advance by 3 data values each time the routine is run. If you do not include a skip number, then you must advance the list processing using one of the ways listed above.

Random Access

You can access any value in data to view or change it. To view any value in a list simple call the routine getdata(listname,position).
// set TitleName to the 3 value of the list
update var TitleName where value=getdata(myList,3)
To set a value in a list use "update".
// change the 4th value to "dog"
update data myList set 4="dog"

Changing Lists

create routine as Example
    update data LISTNAME push "shirt"
    update var NAME set data.LISTNAME.pop
    update data LISTNAME fush "dog"
    update var NAME set data.LISTNAME.fop
end

Getting List Information

Data also supports some information requests:

Passing Data to Routines

Sometime you don't know which data to use until the game is playing. In this case you can pass a reference to your chosen data to a routine. See the example below (which you can use in the scratchpad):
create data from list as myList1
set
  a b c
end
create data from list as myList2
set
  x y z
end
var someVar=1
create routine as Start
  if (someVar==1)
    UseList(data.myList1)
  else
    UseList(data.myList2)
  endif
end
create routine as UseList
  var whiList=arg.1 // necessary to use data
  log(whiList.next)
end

Important Points: