Code Scope of Action:
Code First Added:
The argument to ^value^ is an expression — a value that could be assigned to an attribute. ^value^ evaluates the expression and exports the result, as a string (some data types may also require the format() operator too). This allows manipulations for export use without needing to, for instance, hold the value in a user attribute first.
^value^ is a more flexible replacement version of the now-deprecated codes ^get^ and ^getFor^ but which still allows the called attribute's value to be manipulated. For example:
exports the width of the current note, and is equivalent to
^get(Width)^ (do not use this style of code!)
So you may use the two forms interchangeably even where no manipulation of the stated attribute is required.
^value("$Name: "+$Name(parent))^: $Name: Export Codes - Full Listing
^value($Name(parent)+":"+$Name)^: Export Codes - Full Listing:^value( expression )^
Note that ^value($Text)$$ equates to ^text(plain)^.
^value($Color2)^: dark warm gray dark
^value(format($Created,"l h:mm"))^: 03/07/2007 20:54
^value($Created.format("l h:mm"))^: 03/07/2007 20:54
^value(format($Created,"*"))^: Tue, 3 Jul 2007 20:54:36 +0000
^value($Created.format("*"))^: Tue, 3 Jul 2007 20:54:36 +0000
N.B. Unformatted Date-type data returns the host OS' local "short date" format plus time (in hh:mm form). For the aTbRef author's UK-locale OS that equates to a format string of "
l h:mm" but it may vary for other OS locales. However, a date format string must be given if format() or .format() are used:
^value(format($Created))^: (no date format string!)
^value(format($Created))^: 03/07/2007, 20:54 (no date format string!)
See also ^action ( action )^ usage which allows action code to be run during export.
The ^value^ code also gives a method for using action code to retrieve attribute values. The following give the same output:
^get(SiblingOrder)^ (value here = 42)
^value($SiblingOrder)^ (value here = 42)
Another useful aspect of ^value^ is that it give access to 'raw' attribute data without any process - that is why there's the reference above to some data types needing use of format(). The upside of this raw state is attributes like HTMLMarkupText and HTMLQuoteHTML have no effect; unlike older versions non-ASCII are not encoded. If using the HTML Export process to generate/export formats other than HTML or if accessing the command line it is often necessary to use different forms of escaping. These different outputs can be achieved by using the action code formatting operators within the ^value()^ call. For exporting $Text, in HTML format, ^text^ will give a better result but for other export formats ^value($Text)^ may suffice.