PMDF System Manager's Guide


Previous Next Contents Index

37.8.1 Data Structures: Strings and Lists

As recipe files are intended for manipulating directory attributes, which are generally thought of most naturally as strings or lists of strings, the recipe language is rather string oriented. In addition to regular C type data structures, the recipe language includes strings and lists.

A string is written simply as characters within double-quote characters, e.g.,


string = "a sample string" 

A list is written as a comma-separated list of elements, delimited by braces, e.g.,


list = {"e1", "e2", "e3", "e4"} 

All lists or strings have associated tags. These tags can be set using the settag function, or inspected using the gettag function, described further in Section 37.8.3. Tag values correspond to the !, +, * markings in LDIF files. The default value for tags is a space, meaning in the case of a context variable, that this is an "add" entry. The meanings of !, +, and * are "delete", "modify", and "advisory", respectively.

The indices into strings and lists point not at characters, but between characters, as for strings in the Icon programming language. That is, 1 points just before the first character, 2 between the first and second character, etc., and 0 points just after the last character, -1 points between the penultimate and last characters, -2 between the antepenultimate and penultimate characters, etc. The expression s[i] returns the character immediately following the interstice pointed to by the index.

For instance, if


string = "abcdef" 
then the following expressions are true:


string[1] = "a" 
string[3] = "c" 
string[6] = "f" 
string[-1] = "f" 
string[-4] = "c" 
string[-6] = "a" 
whereas string[0] is illegal as it is trying to return the character after the last one in the string.

When a range is specified, then the substring between the two indices is returned. There is no question about whether this is inclusive or exclusive as the indices point at interstices. Thus again taking as a sample string


string = "abcdef" 
the following expressions are true:


string[1,0] = string 
string[1,0] = "abcdef" 
string[1,2] = "a" 
string[2,0] = "bcdef" 
string[2,-1] = "bcde" 
string[-3, -1] = "de" 
string[i,i] = ""  # when 1 <= i <= length(string)+1 
                  # or -length(string) <= i <= 0 
string[1,i+1] = left(string,i) 
string[-i,0] = right(string) 


Previous Next Contents Index