This version is out of date, covering development from v7.0.0 to v7.5.6. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox 7 Icon

^value( expression )^


Code Type: 

Code Scope of Action: 

Code First Added: 

Code Altered: 

 Data Include   [other codes of this type]

 n/a   [codes with similar scope]

 Baseline

 format"


^value(expression)^

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:

^value($Width)^

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.

Examples

Number-type data:

^value(sqrt($Width))^: 1.732050807568877 

^value(sqrt($Width).format(2))^: 1.73 

String-type data:

^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)^.

Color-type data:

^value($Color2)^: dark warm gray dark

^value(format($Color2))^: #403a35

^value($Color2.format())^: #403a35

Date-type data:

^value($Created)^: 2007-07-03T20:54:36+01:00  

^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,"l"))^: 03/07/2007 

^value($Created.format("l"))^: 03/07/2007 

^value(format($Created,"*"))^: Tue, 3 Jul 2007 20:54:36 +0100 

^value($Created.format("*"))^: Tue, 3 Jul 2007 20:54:36 +0100 

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 = 43) 

^value($SiblingOrder)^ (value here = 43)

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.