Tinderbox v9 Icon

document[[keyStr]]


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

Operator Has Optional Arguments: 

 Function  [other Function type actions]

 Document  [operators of similar scope]

 Document configuration  [other Document configuration operators]

 Baseline

 As at baseline

 [More on optional operator arguments]


document[[keyStr]]

document() or document returns a dictionary of useful properties of the current document. The properties of the document are exposed this way (in this order in the dictionary):

Importantly, The document() Dictionary object is read-only.

The operator returns the document Dictionary object as a single string:

$Text = document(); 

Although trailing parentheses are not needed, when calling the 'bare' operator, add parentheses—i.e. document()— may help the user and parse not mistake the operator document for the literal string "document".

As reading the Dictionary data as a single string can be hard, a neater and more easily understood method is use the Dictionary.keys method of document() and iterate thus:

	$Text =;
	document.keys.each(aKey){
		var:list vKey = document[aKey];
		$Text += aKey + ": " + vKey.format(", ") +"\n\n";
	};

which will list in $Text of the current note each key name and then its value with a blank line in between. For multi-item values like user-attributes and link-types list formatting applies a ', ' delimiter for legibility.

document[keyStr]

More normal use will be to address the document Dictionary to access a particular key using the optional keyStr argument. The values for the above properties can be accessed individually by supplying the relevant key. Quotes around the key are optional, both forms are illustrated below:

$MyURL = document["url"]; 

$MyFile = document["path']; 

$MyString = document["name"]; 

$MyList = document["user-attributes"]; 

$MyList = document[link-types]; 

All properties return a string value but the are more usable when passed to attributes (or variables) of the precise data types shown.

Calling document with no other handling, returns the entire, unformatted Dictionary contents. To split the items onto separate lines as discrete key:value pairs:

$MyString = document.format("\n"); 

To get the three values (without their keys) on separate lines:

$MyString = document.format("\n").replace("\n[^:]+:","\n").replace("^[^:]+:","");