This version is out of date, covering development from v5.0.0 to v5.12.2. It is maintained here only for inbound reference links from elsewhere.

Jump to the current version of aTbRef.

Tinderbox 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]

 Already in v5.0.0

 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 in effect a version of ^get^/^getFor^ but which allows the called attribute's value to be manipulated; the older 'get' codes are now deprecated. For example:

^value($Width)^

exports the width of the current note, and is equivalent to

^get(Width)^

So you may use the two forms interchangeably even where no manipulation of the target attribute is required.

Examples

Number-type data:

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

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

^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:00 +0000 

^value($Created.format("*"))^: Tue, 3 Jul 2007 20:54:00 +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))^:   (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. 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.


Possible relevant notes (via "Similar Notes" feature):


A Tinderbox Reference File : Export Codes : Export Codes - Full Listing : ^value( expression )^