User Tools

Site Tools


Sidebar

Passage markup

basics

coding

extra

list

section

whitespace

Macros

basics

colour

data structure

date and time

game state

live

maths

number

revision

saving

showing and hiding

string

styling

url

deprecated

Types of data

Special keywords

Special passage tags

harlowe:dataset

Array are useful for dealing with a sequence of related data values, especially if they have a particular order. There are occasions, however, where you don't really care about the order, and instead would simply use the Array as a storage place for values - using contains and is in to check which values are inside.

Think of datasets as being like arrays, but with specific restrictions:

  • You can't access any positions within the dataset (so, for instance, the 1st, 2ndlast and last aren't available, although the length still is) and can only use contains and is in to see whether a value is inside (or, by using any and all, many values).
  • Datasets only contain unique values: adding the string “Go” to a dataset already containing “Go” will do nothing.
  • Datasets are considered equal (by the is operator) if they have the same items, regardless of order (as they have no order).

These restrictions can be helpful in that they can stop programming mistakes from occurring - you might accidentally try to modify a position in an array, but type the name of a different array that should not be modified as such. Using a dataset for the second array, if that is what best suits it, will cause an error to occur instead of allowing this unintended operation to continue.

Operator Meaning Example
is Evaluates to boolean true if both sides contain equal items, otherwise false. (ds:1,2) is (ds 2,1) (is true)
is not Evaluates to true if both sides differ in items. (ds:5,4) is not (ds:5) (is true)
contains Evaluates to true if the left side contains the right side. (ds:“Ape”) contains “Ape”, (ds:(ds:99)) contains (ds:99), (ds: 1,2,3) contains all of (a:2,3), (ds: 1,2,3) contains any of (a:3,4)
is in Evaluates to true if the right side contains the left side. “Ape” is in (ds:“Ape”), (a:3,4) is in (ds:1,2,3)
+ Joins datasets. (ds:1,2,3) + (ds:1,2,4) (is (ds:1,2,3,4))
- Subtracts datasets. (ds:1,2,3) - (ds:1,3) (is (ds:2))
When used in a macro call, it separates each value in the right side., The dataset's values are sorted before they are spread out. (a: 0, …(ds:1,2,3,4), 5) (is (a:0,1,2,3,4,5))
harlowe/dataset.txt · Last modified: 2017/06/18 23:36 by l