String color sets

Strings are specified by sequences of printable ASCII characters surrounded with double quotes. The string color set is large unless restricted by the with … and clause, in which case it is small.

Declaration syntax

colset name = string [with string-exp1..string-exp2 [and]];


lexicographic (with the ASCII ordering)

Optional ''with'' clause

Restricts the character set of string color sets. The character set is specified by the string expressions string-exp1 and string-exp2.

Each string expression must evaluate to a string of length 1, and it must be the case that string-exp1<=string-exp2.

Optional ''and'' clause

Restricts the length of string color sets. The minimum and maximum length of the string is specified by the integer expressions int-exp1 and int-exp2. It must be the case that 0<=int-exp1<=int-exp2.

Declaration examples

colset S = string;

A string color set is used in the example CP-net Simple protocol example.

colset LowerString = with “a”..”z”;

var lowerString : LowerString;

The CPN variable lowerString may contain only the lowercase letters a,b,…,z . For example, “ab” and “lowercase” are legal values, but “Lowercase letters” and “ab345” are not.

colset SmallString = with “a”..”d” and 3..9

var smallString : SmallString;

The CPN variable smallString may contain only the letters a,b,c and d. Its length must be >=3 and <=9. For example, “abcd” and “bbacdab” are legal values, but “ab” and “bcde” are not.


concatenate the strings s1 and s2
String.size s
number of characters in s
substring (s,i,len)
extract a substring of length len starting at position i in s, first position is 0
explode s
convert string s to list of chars
implode l
convert list l of chars to a string

See also color set functions.

For additional details and functions see the STRING signature in the SML Basis Library Manual.

All color sets

Simple color sets

Compound color sets