Token Engine

The TokenEngine can process literal and numeric values, the results of call up functions, and delivers results in the form of dynamically generated strings which can be used in various places within the program.

For example, during the imposition process it is possible with the Token Engine to place dynamically generated texts on an imposition sheet.

Syntax

Literal

A literal character token is a text enclosed by quotation marks.

If quotation marks themselves are used in the text, these must be marked by a preceding '\' backslash: \ "

If the backslash '\' is used in the text, this must also be marked by a back-­slash: '\\'.

Examples of literal tokens

"This is a text"
"Date:"
"He said \"Good      morning!\""
"C:\\\\Programs\\Test.txt"

Numbers

A number is made up of the numeric characters 01234567892 and one or no decimal point .

Examples of numbers

1
1.982
5000.0
75

Operators

Calculation operators for numeric tokens: + - * / %

Combination operators for literal tokens: &

Parameter lists

A parameter list is a list of expressions separated by commas.

Exceptions to parameter lists are the empty list and the list that consists of one parameter only.

Example for parameter lists

"benjamin","britten"
1,2,3
"text and numbers",5
"today is the "&      date() , 8 , 9

Functions

There are various functions depending on the module. But the syntax for calling up functions is always the same:

functionname(parameterlist) 

Each function requires a particular number of parameters. Please see below in the documentation for each function for details.

Examples of call up functions

date()
date("DD.MM.YY")
length("text")
left("this is a text",4)

Numerical expressions

A numerical expression consists of numbers, operators and functions.

The Token Engine recognizes the four basic calculation methods +, -, * and / . Priority conventions are respected ,e.g. multiplication and division comes before addition and subtraction. All function tokens can be used in numerical expressions as long as they result in numerical values.

Expression

An expression is a string of literal tokens, numeric expressions and call up functions joined by the combination operator '&'.

Examples for expressions

"This is a simple text!      Believe me!"
"today is "&      date("DD.MM.YYYY") &"."
"5 + 5 = "& 5 + 5
fileName(docpath())
left("this is a      test",length("this"))

Function groups

Text functions

left(text,num)

gives us num characters from the beginning of text.

left("This is an example",4) 

gives us "This"

right(text,num)

gives us num characters from the end of text.

right("This is an example",3) 

gives us "ple"

middle(text,pos,num)

gives us num characters beginning with pos from the text.

middle("This is an example",6,2) 

gives us "is"

replace(text,pos,count,replacementText)

replaces count characters from Position pos in the text with replacementText and gives us the result

replace("This is an example", 10, 9 , " test") 

gives us "This is a test"

substitute(text,pattern,replacementText)

replaces all occurrences of pattern in the text with replacementText.

substitute("This is an example","s","***") 

gives us "Thi*** i*** an example"

length(text)

gives us the length of a text.

length("This is an example") 

gives us 18

position(text, searchText,pos,n)

gives us the position of the n-th occurrence of searchText from Position pos.

position("This is an example","s",3,2) 

gives us 7 .

regex(text,pattern)

gives us 1 if the regular expression pattern matches the input text text.

regex("This is an example","^(This)(.*)(example)$") 

gives us 1

regex(text,pattern,format,noMatchText)

gives us noMatchText if the regular expression pattern does not match the input text text, otherwise the text will be returned having been for-­matted with format

regex("This is an example","^(Dies)(.*)(example)$","$1","ERROR") 

gives us "This"

regex("This is an example","^(This)(.*)(example)$","$2","ERROR") 

gives us " is an"

regex("This is an example","^(This)(.*)(example)$","$3$2$1", "ERROR") 

gives us "example is an This"

regex("This is a text","^(This)(.*)(example)$","$3$2$1","ERROR") 

gives us "ERROR"

Date and time functions

date()

gives us today’s date in the format "DD.MM.YYYY" (e.g. "03.11.2008")

date(format)

gives us today’s date in any number of possible formats.

Placeholders that can be used are: D: day, M: month, Y: year.

Examples:

DD.MM.YYYY

03.11.2008

YYYY-MM-DD

2008-11-03

DD

03

D

3

time()

gives us the current time in the format "hh:mm:ss" (e.g. "10:05:49")

time(format)

gives us the current time in any number of formats.

Placeholders that can be used are: h: hour, m: minute, s: second.

Examples:

hh.mm.ss

10:05:49

mm

05

m

5

datetime()

gives us the current date and time in the format "DD.MM.YYYY hh:mm:ss" (e.g. "08.09.2003 10:05:49")

datetime(format)

gives us the current date and time in any number of formats.

Placeholders that can be used are:

D

day

M

month

Y

year

h

hour

m

minute

s

second

Examples:

YYYY-MM-DD-hh-mm-ss

2008-11-03-10-05-49

YYYYMMDDhhmmss

20081103100549

Logic functions

if(a,b,c)

If parameter a = "0" expression c will be returned, otherwise expression b:

if(var("LastPositionedPage") , "Page: " & var ("LastPositionedPage"), "Pagenumber not valid!") 

(Below you will find further explanation about the "var"-function.)

choose(a,b,c,...)

gives us independently of parameter a the a-th entry from the list (count start with 0).

choose(0,"Null","One","Two","Three") 

gives us "Null"

choose(3,"Null","One","Two","Three") 

gives us "Three"

choose(date("M"),"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") 

in September gives us "Sep"

Numeric functions

a+b

gives us the sum of a and b.

1+2 

gives us 3

a-b

gives us the difference between a and b.

4-2 

gives us 2

a*b

gives us the product of a and b.

4*2 

gives us 8

a/b

gives us the division of a with b.

4/2 

gives us 2

a%b

gives us the rest of the division of a with b.

33%16 

gives us 1

abs(a)

gives us the absolute value of a

abs(-5) 

gives us 5

The basic calculation methods can, however, also be written as direct numerical expressions. Here arithmetic rules and conventions such as the use of brackets must be respected.

3 + 3 

gives us 6

4 - 2 

gives us 2

8 / 2 

gives us 4

4 * 4 

gives us 16

(6 + 2 * (3 - 1)) / 2 

gives us 5

max(a,b,c,...)

gives us the highest value from all listed values.

max(1,8,2,7,3,6,4,5) 

gives us 8

min(a,b,c,...)

gives us the lowest value from all listed values.

min(1,8,2,7,3,6,4,5) 

gives us 1

File functions

docpath()

gives us the complete path to the current PDF file including the file name.

docpath() 

gives us e.g. "/Users/callas/Documents/test.pdf" on Mac and "C:\\temp\test.pdf" on Windows.

filename(path)

gives us the file name of the currently processed PDF document.

filename("C:\PDF files\impose.pdf") 

gives us "impose.pdf"

parentfolder(path)

gives us the parent folder name of the currently processed PDF document.

parentfolder("C:\PDF files\impose.pdf") 

gives us "C:\ PDF files"

appendfileorfolder(path, file or folder name)

allows to merge a file path

appendfileorfolder("C:\PDF files\","impose.pdf") 

gives us "C:\ PDF files\impose.pdf"

readfile(path)

gives us the content of a specified file.

readfile("C:\TXT files\impose.txt") 

gives us the content of the text file "impose.txt"

lookup(path, key, selector)

allows to read values from a tab de-limited file which could be a text file containing entries separated by tabulators. Key specifies the entry in the first row. selector specifies an entry in the first line.

lookup("C:\TXT files\chart.txt", LINE2, ROW3) 

gives us the value that is listet at position LINE2 and ROW3 of the tab de-limited file chart.txt.

Systeminfo functions

username()

Gives us the user name of the user currently registered on the workstation

machinename()

gives us the name of the workstation

osversiontext()

gives us the system version of the operating system (e.g. "Mac OS X 10.5.8")

CLI functions

var(name,format)

gives us the variable name from the RunList (e.g. in the sheet configura­tion) in its format format. Any number of variables can be defined with the command set from the runlist.

Pre-defined variables of particular importance are:

ShinglingOffset

current value of the creep correction

CropMarkGap

current distance between TrimBox and cropmark

CropMarkLength

current length of the cropmarks

CropMarkWidth

current line width of the cropmarks

TextSize

current text size

TextFont

current font name

LastPositionedPage

last positioned page

CurrentSheet

current sheet number

RunListName

name of the current runlist

SheetConfigName

name of the current sheet configu-­ration

All formats are available:

Text as entered

"string" (default)

Point

"pt"

Millimeter

"mm"

Centimeter

"cm"

Inch

"'"

RunListTerminationMode(num)

defines the behaviour when FirstPage gets larger than LastPage.

Allowed values are 1 and 2, the default is 1.

  • 1 The loop stops. If the sheet is not completely imposed, it is discarded.
  • 2 If the loop stops (FirstPage > LastPage), the currently imposed sheet is stored even if not all slots are filled.

CropMarkColorSpace

Set CropMarkColorSpace {"DeviceGray" | "DeviceRGB" | "DeviceCMYK" | <Spot Color>} 

By default crop marks are using Separation color "All", also known as Registration color. This parameter allows to define a specific color space to be used for the crop marks to be created. Defining this parameters requires to also define the parameter CropMarkColorValues.

CropMarkColorValues

Set CropMarkColorValues <Color value> 
Set CropMarkColorValues "100/100/0/0" 

This parameter defines the color values to be used based on the color space defined by CropMarkColorSpace. The values have to be format-­ed in such a way that they represent the color tints of the color channels available in the defined color space. The values have to be defined in a range from 0 to 100.

  • For DeviceGray the values has to be the <Gray> tint in %
  • For DeviceRGB the values have to be <Red>/<Green>/<Blue> in %
  • For DeviceCMYK the values have to be <Cyan>/<Magenta>/<Yellow>/<Black> in %
  • For <Spot Color> the values have to be either <Gray> or <Red>/<Green>/<Blue>      or <Cyan>/<Magenta>/<Yellow>/<Black> in % and represent the alternate color space definiton

CropMarkTintValue

Set CropMarkTintValue <Spot color tint value>

Set CropMarkTintValue "50"

docinfo(key)

gives us the document information of a PDF file for a particular key.

Available keys:

  • "Title"
  • "Subject"
  • "Author"

0 Comments

Send Your Comment

E-Mail me when someone replies to this comment