PMDF System Manager's Guide


Previous Next Contents Index

37.8.3 Operators and Functions

Table 37-10 lists the available operators for recipe files; Table 37-11 lists the available functions for recipe files.

Table 37-10 Operators Available in Recipe Files
Operator Description
? v Force interpretation of v as a variable, (rather than as a pre-defined function)
Integer operators Description
n ++ Return n and then increment its value. n must have an integer value.
n -- Return n and then decrement its value. n must have an integer value.
++ n Increment the value of n and then return it. n must have an integer value.
-- n Decrement the value of n and then return it. n must have an integer value.
Infix operations Description
s [ i ] Return the i th character of s ; see Section 37.8.1 for additional discussion of string indexing.
l [ i ] Return the i th element of l ; see Section 37.8.1 for additional discussion of string indexing.
s [ i , j ] Return the i th through j th characters of s ; see Section 37.8.1 for additional discussion of string indexing.
l [ i , j ] Return the i th through j th elements of l ; see Section 37.8.1 for additional discussion of list indexing.

Table 37-11 Functions Available in Recipe Files
Function Description
allof( i1[ , i2...] ) Returns a nonzero value if all of i1 , i2 , ... are nonzero; returns 0 otherwise.
abs( i ) Return the absolute value of i .
any( s1 , s2 ) Return 2 if any character in s1 appears as the first character of s2 ; return 0 otherwise.
anyof( i1[ , i2...] ) Returns a nonzero value if any of i1 , i2 , ... are nonzero, returns 0 if all are zero.
bal( c1 , c2 , c3 , s ) Scan s looking for an occurence of a character in c1 that is balanced with respect to c2 and c3 . Returns the position of the first balanced c3 character in s if one is found, length( s)+1 if no c3 character is found but the string as a whole is balanced, or 0 if the string isn't balanced.
chr( i1[ , i2...] ) Returns a string containing successive characters with decimal values i1 , i2 , ...
debug( s ) Outputs s to a debug log file.
defined( s ) Returns 1 if s is defined as a variable; return 0 otherwise.
find( s1 , s2 , i , j ) Returns the position in s2 of the first occurence of s1 in s2[ i: j] .
find( s , l , i , j ) Returns the position in l of the first list element from l[ i: j] that matches s .
getenv( s ) Return value of logical name (OpenVMS) or environment variable (unix and NT) s . Returns the empty string if s is not defined. Note that s is case sensitive.
integer( e ) Converts e to an integer. If e is already an integer it is returned unchanged; if e is a string it is read as a sequence of ASCII digits. If e is a list it must contain one element and is treated in the same way a string would be.
lcase( e ) Converts any upper case characters in e to lower case. If e is a number it is converted to a string.
left( s1 , i[ , s2] ) Returns leftmost i characters of s1 . If i is greater than length( s1) the result is padded with s2 . As much of s2 as is necessary will be used; if s2 is too short it will be used multiple times. s2 defaults to a space if it is omitted.
left( l1 , i[ , l2] ) Returns leftmost i elements of l1 . If i is greater than length( l1) the result is padded with l2 . As much of l2 as is necessary will be used; if l2 is too short it will be used multiple times. l2 defaults to one empty list element if it is omitted.
length( s ) Returns the number of 8-bit characters in the string s .
length( l ) Returns the number of elements in the list l .
list( s , n ) Returns a list n elements long with each element equal to s .
list( l , n ) Returns a list consisting of n copies of l .
max( i , j[ , ...] ) Returns the largest element in a set of integers.
max( s1 , s2[ , ...] ) Returns the largest element in a set of strings.
min( i , j[ , ...] ) Returns the smallest element in a set of integers.
min( s1 , s2[ , ...] ) Returns the smallest element in a set of strings.
repl( s , j ) Returns a string consisting of j concatentations of s .
repl( l , j ) Returns a list consisting of j concatentations of l .
reverse( s ) Reverses all the characters in s and returns the result.
reverse( l ) Reverses all the elements in l and returns the result.
right( s1 , i[ , s2] ) Returns rightmost i characters of s1 . If i is greater than length( s1) the result is padded with s2 . As much of s2 as is necessary will be used; if s2 is too short it will be used multiple times. s2 defaults to a space if it is omitted.
right( l1 , i[ , l2] ) Returns rightmost i elements of l1 . If i is greater than length( l1) the result is padded with l2 . As much of l2 as is necessary will be used; if l2 is too short it will be used multiple times. l2 defaults to one empty list element if it is omitted.
sign( i ) Returns -1 if i < 0, 0 if i = 0, +1 if i > 0.
sort( l1[ , i[ , l2]] ) Sorts the elements of l1 to be in ascending order if i <> 0 and descending order if i = 0. i defaults to 1 if it is omitted. If l2 is present its elements are shifted in the same way as elements in l1 are shifted.
split( s[ , c[ , i]] ) Produces a list of elements consisting of pieces of s delineated by characters in c . If omitted c defaults to a comma. If i is 0 or 1, zero length elements are preserved; if i is 2, they are not. If omitted i defaults to 1.
split( l[ , c[ , i]] ) Produces a list of elements consisting of pieces of elements of l delineated by characters in c . If omitted c defaults to a comma. If i is 0, boundaries between the original elements aren't preserved and zero length elements can be output; if i is 1, boundaries are preserved and zero length elements can be output; if i is 2, boundaries aren't preserved and zero length elements are omitted. If omitted i defaults to 1.
string( e ) Converts e to a string. If e is already a string it is returned unchanged. If e is an integer it is converted to a string. If e is a list, the string that results from concatenating the elements of e is returned.
translate( s1 , s2 , s3 ) Interprets the string s1 as being in the character set specified by s2 and returns a version translated into the character set specified by s3 .
trim( s[ , c] ) Returns s with any trailing characters found in c removed. c defaults to space and tab if omitted.
trim( l[ , c] ) Returns l with any trailing characters found in c removed from each element. c defaults to space and tab if omitted.
type( e ) Returns "integer" if e evaluates to an integer, "string" if e evaluates to a string, and "list" if e evaluates to a list.
ucase( e ) Converts any lower case characters in e to upper case. If e is a number it is converted to a string.
Date function Description
datetimeprop( s1 , s2 ) If s1 is null, then the current date and time in RFC 822/RFC 1123 format will be returned in s2 . Otherwise, s1 should be an RFC 822/RFC 1123 date-time string, and s2 one of "month", "lmonth", "zone", "tzone", "day", "mday", "wday", "yday", "weekday", "8601", "822", or "822Z". Returns the requested component of the date-time, or the date-time in the requested format.
Directory function Description
gettag( x ) If x evalutes to a string, returns the tag character for that string. If x evaluates to a list, returns the default and per-element tags as a string. An error will be returned if x evalutes to anything other than a string or list.
makeDN( l ) Returns a canonical DN (Distinguished Name). l must be a list containing an even number of elements, organized as attribute, value, attribute, value, etc.
settag( x , y ) Sets the tag or tags of x to y . x can be either a string or a list. If x is a string, then y must be a one character string. If x is a list, then y must be a string of length length( x)+1 and the first character of y must be a space.

37.8.3.1 Site-defined Mapping Table Functions

Sites can use PMDF mapping tables to establish additional functions. Any mapping table named DIRSYNC_func-name in the PMDF mapping table establishes a new function, func-name, available within recipe files. For instance, a mapping


DIRSYNC_PO_TO_ORG 
 
  poA         org-unit1 
  poB         org-unit2        
 
makes available a function PO_TO_ORG, where PO_TO_ORG(poA) returns org-unit1 and PO_TO_ORG(poB) returns org-unit2.


Previous Next Contents Index