8.18/6/2018

Definemeta (function)

Defines a field when running a PlanetPress Design Document with metadata file creation. In every cases, the name of the field is case-insensitive and must begin with a letter (A-Z, a-z), followed by any number of letters, numbers (0-9), underscore ('_') or dash ('-') characters.

Syntax

definemeta(name: string, data: string, [flags: integer, path: string])

Argument

name

The name of the metadata field to define. Unless the path argument specifies otherwise, the new field is defined at page level.

data

An initial string value of the defined metadata field. This value can also be a valid PlanetPress Talk expression.

flags

Optional integer value to define the behavior of the command when a field with the same name already exists in the current level. The default behavior uses 0 and overwrites the old value with the new one.

Name Value Behavior
DefineOverwrite 0 The content of the value parameter overwrites the current value of the field if it exists, or creates it if it does not.
DefineAppend 1 The content of the value parameter is appended to the existing field.
DefineDuplicate 2 A new field with the same name is created, appending an index at the end of its name.
DefineError 3 The command fails and the job crashes, yielding an error dialog.

path

Optional string value to specify the level where to create the metadata field. Path components cannot be indexed, and if no path is provided, the field is created at the current page level.

The node names of the path argument can have an optional zero-based index, indicated between square brackets ('[ ]'), to access a specific node. If no index is provided, the first node is used.

Code Sample Example

This example illustrates how to assign data from the current line printer data file to a document-based metadata field, specifying the level where the field will be created.


% Create simple 'InvoiceNumber' holding the value found on line 10,
% between columns 35 and 42 of a line printer emulation data file.
definemeta('InvoiceNumber', @(10,35,42))
% Create the same 'InvoiceNumber' field but duplicating it if it already exists.
definemeta('InvoiceNumber', @(10,35,42), 2)
% Create the same 'InvoiceNumber' field but at the Document level this time,
% and raising an error if it already exists.
definemeta('InvoiceNumber', @(10,35,42), 3, 'Job.Group.Document')