OneScript
  • Welcome to OneScript
  • OneScript Overview
    • Dates and Times
    • Sets
    • Types
    • Fields
      • Helper Fields
      • Labels
      • Standard Text
    • Snapshots
    • State Management
    • Future Features
  • Get OneScript
  • Macro Overview
    • Macro Virtual Machine
    • Code Instructions
  • Standard Libraries
    • Core
    • Data
    • Interview Model
  • Linker Overview
    • Objects
  • Contact Us
Powered by GitBook
On this page
  1. OneScript Overview

Sets

Unlike many other languages, OneScript supports the ability to store, combine and test options that may represent options selected by recipient of a survey. The Set type takes the following basic form:

{ident[,ident]}

For example:

{a,b,c}

Sets do not support whitespace between the ident values.

It is possible to combine sets for example:

Set e1 = {a,b,c};
Set e2 = {g,h,i};
e1 = e1 + {d};                // Result is {a,b,c,d}
e1 = e1 - {a};                // Result is {b,c,d}
e1 = e1 + e2;                 // Result is {b,c,g,h,i}

It is also possible to test whether a Set is present in a value is:

Set e1 = {a,b,c};
Set e2 = e1 & {a};            // Result is {a}
e2 = e1 & {h};                // Result {}
e2 = e1 | {h};                // Result is {a,h}

Sets are case insensitive:

Set e1 = {A,b,c};
Set e2 = {g,h,i};
e1 = e1 + {D};                // Result is {a,b,c,D}
e1 = e1 - {a};                // Result is {b,c,d}
e1 = e1 + e2;                 // Result is {b,c,g,h,i}
PreviousDates and TimesNextTypes

Last updated 3 years ago