Using the Prop Function

In most cases, the get and prop functions return the same value. The difference between these two functions is that the get function does not always return a scriptable value, while the prop function always returns a scriptable value. A scriptable value has the same stable form for each type of property.

  1. Return the scriptable value of a property in the current node context.

    For most properties, the get and prop functions return identical values, as shown in the following example for the version property:

    > ls
    version = 2019.02.28,1-0
    > script get('version')
    '2019.02.28,1-0'
    > script prop('version')
    '2019.02.28,1-0'

    In the following example for the date property, note the difference between the value returned by the get function and the scriptable value returned by the prop function:

    > ls
    date = 2019-2-28 10:43:11
    > script get('date')
    Thu Feb 28 2019 10:43:11 GMT+0000 (UTC) (Date object)
    > script prop('date')
    '2019-02-28T10:43:11Z'
  2. Set the value of a property in the current node context to a scriptable value.

    Include a value in the prop function call to set the value of the named property. An error message is output if the given value is not in the specified scriptable form for that property. Otherwise, the set form of the prop function does not return any value.

    > ls
    date = 2019-2-28 10:43:11
    > script prop('date', '2019-03-09T12:34:56Z')
    > ls
    date = 2019-3-09 12:34:56
    > script prop('date')
    '2019-03-09T12:34:56Z'
  3. Set the value of a boolean property.

    Because the prop function can be used either to return a property value or to set a property value, the prop function does not have the ability that the set function has to set a boolean property to true without specifying the value.

    The following example shows how to use the short version of the set function to set a boolean property to the value true:

    set('booleanproperty')

    The short form of the prop function returns the value of the boolean property, either true or false:

    script prop('booleanproperty')
    'false'

    To use the prop function to set the value of a boolean property, you must provide the value:

    script prop('booleanproperty', true)
    script prop('booleanproperty')
    'true'
  4. Set the value of a List property.

    To set a scriptable value for a property with the List modifier, you must specify an array of values:

    > ls
    stringlist = a,string,list
    > script prop('stringlist', ['a', 'b', 'c', 'd'])
    > script prop('stringlist')
    ['a', 'b', 'c', 'd']
    > ls
    stringlist = a,b,c,d

    To specify a single value for a List property, specify the single value as an array of size one:

    > ls
    stringlist = a,string,list
    > script prop('stringlist', ['a'])
    > script prop('stringlist')
    ['a']
    > ls
    stringlist = a

    To specify the empty value for a property with the Empty or List modifier, specify an empty array:

    > ls
    emptystringlist = a,string,list
    > script prop('emptystringlist', [])
    > script prop('emptystringlist')
    []
    > ls
    emptystringlist =