Вы находитесь на странице: 1из 12

Printcore : Expression Engine Specification

This page last changed on 2006-03-10 by anka.

Under Construction
This document is under construction, and its contents will be expanded as time permits.

Introduction
This document is a specification of the Expression Engine (EE) syntax.

Glossary
See Abbreviations

Definitions
The default data range is -32768 to 32767.
The contents for a variable used in a date/time operation has to be of the internal date format. The
internal date and time format follows the ISO 8601 notation YYYY-MM-DD hh:mm:ss
(YYYY-MM-DDThh:mm:ss is also allowed). See ISO 8601 for more information.
Both numbered and named variables are supported. Syntax for variable number 10, used in a
function: %10V. Syntax for a variable named 'Pluto' used in a function: %'Pluto'V. Note: %101V is
identical with %'101'V.
A variable name can only consists of alphanumerical characters (a-z, A-Z, 0-9).
There is no fixed maximum number of variables. The variables are dynamically allocated, so it is the
amount of available memory that sets the limit.
There is no no fixed maximum number of characters for a variable name.
There is no no fixed maximum number of functions.
Plain text shall be used for the function names as long as possible. Plain text names increases the
comprehension and, in this case, does not affect the EE performance.
The string <CLEAR> shall act as a general command string in order to delete the contents of a
service command.
The string <END> shall act as the end character string for a service command that returns more
than one line. The <END> character string is the last line returned from the printer and it is the
only characters on the line.
The contents for a variable can be received with the service command !V3206. See Get variable
content.
Counter, parameters and service commands can be added to a variable. See Parameter as a
variable, Service command as a variable and Counter as a variable.
An array can be stored in a single variable. The user defined array can then be used in order to
receive date strings on the local language. See Array as a variable.
A variable can be used for the offset type argument in a date function. See Offset type as a variable.

Service commands for the Expression Engine

Document generated by Confluence on 2007-02-27 14:02

Page 1

Set function
!V<a> <b> <c> "<d>"
a = Service command number, 5000
b = Function number, from 0 to the last used function
c = Variable number / name. A variable name is always surrounded with the double quotes character
(ASCII 34)
d = Function, always surrounded with the double quotes character (ASCII 34)
Example:
!V5000 1 20 "%1C" Specify function number 1, the result shall be stored in variable no 20
!V5000 1 "Pluto" "%'Goofy'V" Copy the variable "Goofy" contents to variable "Pluto"
The set function is also used in order to delete function(s), then with the following syntax:
!V<a> <b> <c>
a = Service command number, 5000
b = Function number. If the function number is omitted, all functions will be cleared.
c = The general clear service command string: <CLEAR>
Example:
!V5000 10 <CLEAR> Clear function number 10
!V5000 <CLEAR> Clear all declared functions

Get function formula


!V<a> <b>
a = Service command number, 5001
b = Function number, from 0 to the last used function
Example:
!V5001 1 Get formula for function number 1
1 100 "%1C"
!V5001 Get a list with all declared functions
1 100 "%1C"
2 101 "%2C"
3 102 "%3C"
10 150 "%date()"
11 151 "%date.weekday(%150V)"
<END>

Check functions
!V<a>
a = Service command number, 5002

Document generated by Confluence on 2007-02-27 14:02

Page 2

Check all functions, from the first declared function until the last one. The result from a function
operation will be returned. Used counters will not be modified by this operation.
One of the following error codes is returned if an error is detected:
"E00:Syntax Error" - Impossible to parse a line of code.
"E01:Run-time Error" - An error detected at run-time by the EE.
"E02:Function does not exist" - The refered function does not exist.
"E03:Variable <number/name> does not exist" - The variable <number/name> does not exist.
"E04:Variable <number/name> is empty" - The variable <number/name> is empty
"E05:Incorrect variable contents" - The variable contents is not in the correct format
Note: This service command is intended to be use for test during the EE function declaration.
Example:
!V5002 Check all functions. Return value of format: function number, variable number/name, result
1 100 000005
2 101 E00:Syntax Error
<END>

Refresh
!V<a>
a = Service command number, 5003
Run all declared EE functions. All date and time references are updated.

Trig
!V<a>
a = Service command number, 5004
Run all declared EE functions. All date, time and counter references are updated.

Expression Engine functions


%date('<a>',<b>)
a = Offset type: 'day', 'week', 'month', 'year'
b = The offset value. Default data range
The internal date format follows the ISO 8601 date and time standard, YYYY-MM-DD hh:mm:ss, (ISO
8601).
Example:
!V5000 1 20 "%date()" Set variable 20 to today's date, present time

Document generated by Confluence on 2007-02-27 14:02

Page 3

!V5000 1 12 "%date('day',10)" Set variable 12 to a ten days expiration date

%date.add(<a>,'<b>',<c>)
a = Variable number / name
b = Offset type: 'second', 'minute', 'hour', 'day', 'week', 'month', 'year'
c = The offset value. Default data range
Example:
!V5000 1 60 "%date()" Set variable 60 to today's date, present time
!V5000 2 61 "%date.add(%60V,'year',2)" Add two years to variable 60, store the result in variable
61
!V5000 1 70 "%date()" Set variable 70 to today's date, present time
!V5000 2 71 "%date.add(%70V,'month',-5)" Subtract five months from variable 70, store the result
in variable 71

%date.ampm(<a>,<b>)
a = Variable number / name
b = Variable number / name. The contents has to be an array with two user defined AM / PM strings
If argument b argument is omitted, the default strings will be used: "AM" or "PM"
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.ampm(%10V)" Present time of the day with default AM / PM strings
!V5000 1 20 "['a.m.','p.m.']" User defined strings for AM / PM stored in variable 20
!V5000 2 21 "%date()" Set variable 21 to today's date, present time
!V5000 3 22 "%date.ampm(%21V,%20)" Present time of the day with user defined AM / PM strings

%date.hour(<a>,<b>)
a = Variable number / name
b = 12 - 12-hour clock. 24 - 24-hour clock (default)
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.hour(%10V)" Present time, 24-hour clock in variable 11

%date.juliandate(<a>)
a = Variable number / name

Document generated by Confluence on 2007-02-27 14:02

Page 4

Example:
!V5000 1 30 "%date()" Set variable 30 to today's date, present time
!V5000 2 31 "%date.juliandate(%30V)" Add present Julian date to variable 31

%date.minute(<a>)
a = Variable number / name
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.hour(%10V):%date.minute(%10V)" Store present time hh:mm in variable
11

%date.month(<a>,<b>,<c>)
a = Variable number / name
b = User defined monthnames or one of the EE supported monthnames (see below)
c = User defined monthnames stored in a variable
The EE supports the following monthname strings:
0 - User defined monthnames
1 - English months (January, February, March, April, May, June, July, August, September, October,
November, December).
2 - English months, three character presentation (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
Dec)
3 - Month as one character (A, B, C, D, E, F, G, H, I, J, K, L)
4 - Month as a digit. (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
Note: Month has as default a two digits presentation; 01, 02, ..., 11, 12.
Example:
!V5000 1 50 "%date()" Set variable 50 to today's date, present time
!V5000 2 51 "%date.month(%50V)" Add present month to variable 51. Two digits month
presentation
!V5000 1 50 "%date()" Set variable 50 to today's date, present time
!V5000 2 51 "%date.month(%50V,2)" Add present month to variable 51. English months, three
character
!V5000 1 50 "['Tam','Hel','Maa','Huh','Tou','Kes','Hei','Elo','Syy','Lok','Mar','Jou']" Store a user
defined array with Finnish monthnames (three characters) in variable 50
!V5000 2 51 "%date()" Set variable 51 to today's date, present time
!V5000 3 52 "%date.month(%51V,0,%50V)" Add present month to variable 52. Use the user
defined months stored in variable 50

%date.monthday(<a>,<b>)

Document generated by Confluence on 2007-02-27 14:02

Page 5

a = Variable number / name


b = One of the EE supported monthdays (see below)
The EE supports the following monthday strings:
1 - Day of month as one or two digits. (1, 2, ..., 30, 31)
Note: Day of month with a two digits presentation is the default setting. (01, 02, ..., 30, 31)
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.year(%10V,4)/%date.month(%10V)/%date.monthday(%10V)" Store
present date, YYYY/MM/DD, in variable 11

%date.second(<a>)
a = Variable number / name
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.hour(%10V):%date.minute(%10V):%date.second(%10V)" Store present
time hh:mm:ss in variable 11

%date.truncateday(<a>,<b>)
a = Variable number / name
b = Date truncation day. Specifies what day in the month to truncate the date to the first of next month.
Valid values are {0, 1, ..., 31} and specifies what day in the month to truncate the date. b = 0 means no
truncation.
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.add(%10V,'month',2)" Set a two months expiration date, store the result in
variable 11
!V5000 3 12 "%date.truncateday(%11V,14)" The resulting expiration date shall be rounded to the
first of next month when it reaches the 14th
Note: Truncation of an expiration date with an offset in days will be updated every day until the specified
truncate day in the month is reached. Maybe the following example explains this:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.add(%10V,'day',5)" Set a five days expiration date, store the result in variable
11
!V5000 3 12 "%date.truncateday(%11V,15)" The resulting expiration date shall be rounded to the
first of next month when it reaches the 15th
The calculated expiration date will be updated every day when it is between the 1st and the 15th in a
month. The calculated expiration date will be updated to the first of the next month when it reaches the
15th and until the 1st of the next month.
For this reason, IAB does not recommend usage of the truncateday function on a expiration date with an
offset in days!

Document generated by Confluence on 2007-02-27 14:02

Page 6

%date.updateday(<a>,<b>)
a = Variable number / name
b = Date update day. Specifies what day in the month to update the date. Valid values are {0, 1, ..., 31}
and specifies what day in the month to do the update. b = 0, will update the date every day. It is not
recommended to use a value of b > 28 for obvious reasons.
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.updateday(%10V,15)" The expiration date shall be updated the 15th, every
month
!V5000 3 12 "%date.add(%11V,'day',10)" Set a ten days expiration date, store the result in variable
12

%date.week(<a>)
a = Variable number / name
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.week(%10V)" Store present week in variable 11

%date.weekday(<a>,<b>,<c>)
a = Variable number / name
b = User defined weekday names or one of the EE supported weekday names (see below)
c = User defined weekday names stored in a variable
The EE supports the following weekday name strings:
0 - User defined weekday names
1 - English weekday names (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday).
Default
2 - English weekday names, three character presentation (Mon, Tue, Wed, Thu, Fri, Sat, Sun)
3 - Weekday as one digit (1, 2, 3, 4, 5, 6, 7)
Example:
!V5000 1 50 "%date()" Set variable 50 to today's date, present time
!V5000 2 51 "%date.weekday(%50V)" Add present weekday to variable 51. The default English
weekdays names in plain text will be used
!V5000 1 50 "%date()" Set variable 50 to today's date, present time
!V5000 2 51 "%date.weekday(%50V,3)" Add present weekday to variable 51. Weekday as one digit
!V5000 1 50 "['maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag','zondag']"
Store a user defined array with Dutch weekday names in variable 50
!V5000 2 51 "%date()" Set variable 51 to today's date, present time
!V5000 3 52 "%date.weekday(%51V,0,%50V)" Add present weekday to variable 52. Use the user
defined months stored in variable 50

Document generated by Confluence on 2007-02-27 14:02

Page 7

%date.year(<a>,<b>)
a = Variable number / name. Contents has to be of the internal date format
b = 1 - one digit year presentation. 2 - two digits year presentation. 4 - four digits year presentation.
Example:
!V5000 1 50 "%date()" Set variable 50 to today's date, present time
!V5000 2 51 "%date.year(%50V,2)" Add present year to variable 51, two digits presentation

%format.digits(<a>,<b>)
a = Variable number / name
b = Variable number / name. The contents has to be an array with string replacements for the ASCII
numbers zero to nine
Example:
!V5000 1 60 "%date()" Set variable 60 to today's date, present time
!V5000 2 61 "%date.year(%60V,4)-%date.month(%60V)-%date.monthday(%60V)" Store
present date, 2005-10-03, in variable 61
!V5000 3 62 "['zero','one','two','three','four','five','six','seven','eight','nine']" User defined
strings for the ASCII numbers zero to nine
!V5000 4 63 "%format.digits(%61V,%62V)" Apply the user defined number system on variable 61,
store the result in variable 63
twozerozerofive-onezero-zerothree The result

%format.numbersystem(<a>,'<b>')
a = Variable number / name. Contents has to be ASCII numbers
b = The new number system. Today, ASCII can be transformed to: 'Arabic', 'Farsi' or 'Chinese'
Example:
!V5000 1 80 "%date()" Set variable 80 to today's date, present time
!V5000 2 81 "%date.week(%80V)" Add present week to variable 81
!V5000 3 82 "%format.numbersystem(%81V,'Chinese')" Format present week to the Chinese
number system
!V5000 1 90 "%date()" Set variable 90 to today's date, present time
!V5000 2 91 "%date.year(%90V,4)/%date.month(%90V/%date.monthday(%90V)" Add
present year, month and monthday (YYYY/MM/DD) to variable 91
!V5000 3 92 "%format.numbersystem(%91V,'Arabic')" Format the YYYY/MM/DD string to the
Arabic number system. YYYY, MM and DD will be transformed separately, the '/' character will remain
untouched

%format.string(<a>,<b>)
a = Variable number / name
b = Variable number / name. The format string, untouched characters marked with the '#' character. Use

Document generated by Confluence on 2007-02-27 14:02

Page 8

'\#' in order to add a '#' character and '\\' in order to add a '\' character. New characters are added to
the variable in argument <a>. <Space> characters are added if the string length of variable <a> is less
then the string length of variable <b>.
Example:
!V5000 1 53 "20051212"
!V5000 1 54 "####-##-##" The format string
!V5000 1 55 "%format.string(%53V,%54V)" Format variable 53 (add two '-' characters), store the
result in variable 55
2005-12-12 The result

%format.width(<a>,<b>,<c>)
a = Variable number / name
b = Variable number / name. The character(s) to be used as fill characters, before the printed variable
from argument <a>
c = The total string length
Example:
!V5000 1 40 "%date()" Set variable 40 to today's date, present time
!V5000 2 41 "%date.weekday(%40V)" Add present weekday to variable 41
!V5000 3 42 "*" Add the fillcharacter (*) to variable 42
!V5000 4 43 "%format.width(%41V,%42V,9)" The total string length shall always be nine
characters. Store the result in variable number 43
********5 The result
!V5000 1 50 "%date()" Set variable 50 to today's date, present time
!V5000 2 51 "%date.juliandate(%50V)" Add present Julian date to variable 51
!V5000 3 52 "NOP" Add the fillcharacters (NOP) to variable 52
!V5000 4 53 "%format.width(%51V,%52V,9)" The total string length shall always be 10 characters.
Store the result in variable number 53
NOPNOPNO58 The result

%math.add(<a>,<b>)
a = Variable number / name
b = The offset value, or another variable. Default data range.
The variable contents has to be an integer.
Example:
!V5000 1 12 "%math.add(%10V,%11V)" Add variable 10 and variable 11, store the result in
variable 12
!V5000 1 40 "%date()" Set variable 40 to today's date, present time
!V5000 2 41 "%date.juliandate(%40V)" Add present Julian date to variable 41
!V5000 3 42 "%math.add(%41V,400)" Add 400 to Julian date, store the result in variable 42
!V5000 1 11 "%math.add(%10V,-105)" Subtract 105 from variable 10, store the result in variable

Document generated by Confluence on 2007-02-27 14:02

Page 9

11

Extra functions
Counter as a variable
Example:
!V5000 1 10 "%1C" Add the counter 1 value to variable 10

Parameter as a variable
Example:
!V5000 1 10 "%!2X" Add present print speed to variable 10

Service command as a variable


Example:
!V5000 1 10 "%!100V" Add IP address to variable 10

Variable copy
Example:
!V5000 1 11 "%10V" Copy the result of variable 10 to variable 11

Array as a variable
A user defined array can easily be added to a variable using the following EE function. An EE array is
always surrounded with square brackets "[]". Each post in the array is surrounded with the single quotes
character and two posts is separated with the comma character:
['one','two','three']
Example:
!V5000 1 30 "['Tam','Hel','Maa','Huh','Tou','Kes','Hei','Elo','Syy','Lok','Mar','Jou']" Store a user
defined array with Finnish monthnames (three characters) in variable 30
!V5000 1 70 "['Lun','Mar','Mer','Gio','Ven','Sab','Dom']" Store a user defined array with Italian
weekday names (three characters) in variable 70
It is also possible to add an array using the ordinary variable set command (!W<number> "<string>"). It
is though preferable to use a EE function, because the contents of a variable is always cleared after the
Labelpoint commands !C and !R.

Get variable content


Document generated by Confluence on 2007-02-27 14:02

Page 10

This can be done by using the string translation service command, !V3206.
Example:
!V3206 "%10V" The user do want to reveive the contents for variable 10.
12345 Variable 10, return value from the printer.
For more information about !V3206, see String translation.

Offset type as a variable


The offset type stored in variable can be used as an argument for some of the date functions.
Available offset types are: 'second', 'minute', 'hour', 'day', 'week', 'month', 'year'
Example:
!V5000 1 30 "day" Store the offset type 'day' in variable 30
!V5000 2 40 "%date()" Set variable 40 to today's date, present time
!V5000 3 41 "%date.add(%40V,%30V,2)" Add two days to variable 40, store the result in variable
41

User guides
Date update and truncation
It is possible to use the same date even if the actual date changes and only update it on a monthly basis.
This is accomplished by the use of %date.updateday(...), which specifies what day in the month to
update the date. See the following example where %date.updateday(...) is set to '15':
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.updateday(%10V,15)" The expiration date shall be updated the 15th, every
month
!V5000 3 12 "%date.add(%11V,'day',10)" Set a ten days expiration date, store the result in variable
12
!V5000 4 13 "%date.year(%12V,4)/%date.month(%12V)/%date.monthday(%12V)" Store the
calculated expiration date as YYYY/MM/DD in variable 13
When today's date reaches the 15th of October the output would be 2005/10/25, until 15th of November
where it would be 2005/11/25 and so on.
Another feature that can be automated is month truncation. If the calculated date exceeds a certain day
in the calculated month, the resulting date will be rounded to the first of next month. The truncation day
is specified by %date.truncateday(...). See the following example where %date.truncateday(...) is set to
'20':
Example:
!V5000 1 10 "%date()" Set variable 10 to today's date, present time
!V5000 2 11 "%date.add(%10V,'month',1)" Set a one month expiration date, store the result in
variable 11

Document generated by Confluence on 2007-02-27 14:02

Page 11

!V5000 3 12 "%date.truncateday(%11V,20)" The resulting expiration date shall be rounded to the


first of next month when it reaches the 20th
!V5000 4 13 "%date.year(%12V,4)/%date.month(%12V)/%date.monthday(%12V)" Store the
calculated expiration date as YYYY/MM/DD in variable 13
When today's date reaches the 20th of September the output would be 2005/11/01, until 20th of October
where it would be 2005/12/01 and so on.
It is also possible to use both the dateupdateday- and the truncateday-function on a date expression. It
is important that the functions are implemented in a correct sequence of actions in order to receive the
expected result:
!V5000 1 10 "%date()" 1. Store present date in a variable.
!V5000 2 11 "%date.updateday(%10V,15)" 2. Set the date update day of the month.
!V5000 3 12 "%date.add(%11V,'month',2)" 3. Add the expiration date offset.
!V5000 4 13 "%date.truncateday(%12V,15)" 4. Specify which day in the month that the result shall
be truncated to the first of the next month.
!V5000 5 14 "%date.year(%13V,4)/%date.month(%13V)/%date.monthday(%13V)" 5. Use
the calculated result in user defined date expression.

Open issues
See page Open Issues.

Document generated by Confluence on 2007-02-27 14:02

Page 12

Вам также может понравиться