is specified Full Description |
|
Syntaxshelf-type argument-name (is | isnt) specified Purpose Used to test if the value of a variable or attribute has been specified. It has two applications: pattern variables and optional arguments of functions. You can test a pattern variable to see if any value was assigned to it. Note that there is a difference between having no value assigned and having a value of empty string ("") assigned. A pattern variable is only unspecified if it is inside a pattern that is matched zero times. If it is assigned the value of a whole pattern that is matched zero times, it has the value of empty string (""). Thus this program:
process submit "aaaaaazzzzzz" find "a"+ ("b" => found-1)? => found-2 "z"+ output "found-1 is unspecified%n" when found-1 isnt specified output "found-2 is empty string%n" when found-2 = ""will output: found-1 is unspecified found-2 is empty string If you write a function that has optional arguments, you should test to make sure that the optional argument was specified in the function call before you attempt to use the argument:
define function foo ( value stream first, value stream second optional) as output first output second when second is specified process foo("one%n") foo("two%n", "three%n") If you supplied a default value for the argument, you can use it safely even if it is not specified. The The |