Fieldpine Logo Documentation Home  

POS Commands are used by User Interfaces to control the pos operation. They can be executed from native UI files, or web pages. Information on these pages is designed for User Interface designers and is not introductory in nature.

Active Commands (Most Commonly Used)

Maint

General purpose commands

Sale

Perform an operation on a sale object, such as selling items or setting other characteristics that affect a single sale.

Saleline

The saleline command controls individual items on a sale.

Screen

Control screens, such as displaying new screens or closing screens.

Lookup

Display and control a user lookup screen to reference stored reference data.

Active Commands

Seritem

Control of individually serialised and tracked items such as value based discount vouchers

AddRule

Allow direct control at counters to underlying data. Used to add dynamic pricing

Settings

Affect stored settings used by the system to control operation. This command is not typically used for sale processing

Hardtotal

Access to sequential counters and non resetable totals

Input

Very simple single field prompting from operator. Designed to quickly capture single values

SaleState

Post financial completion sale state management. Typically used when a sale is used in an extended form, such as a food order.

Config

Commands to alter the underlying configuration or definition data the POS is operating against

Barcode

Actions relating to the processing management of barcodes

Storage

Provides a range of commands to interact with the underlying database.

System

Interaction with the operating system to start programs or alter the environment around the POS.

Eft

EFTPOS payment processing. Direct access to pinpads and integrated payments.

Message

Display a user message and optionally capture result

Help

Control context sensitive help that can appear alongside the operator while they perform tasks

Send

Send a single digit sequence to a control. Typically used to route single keystrokes to the element designated to process it.

SendStr

Send a string sequence to a control. Typically used to allow single keystrokes to cause sequences of commands to process.

Sale?

Create a new sale if none is currently present. Often used before sequences that affect sales

Saledone?

Check if the sale is completable, and if so, process the required steps to close the sale now.

Teller

Commands to affect current teller and control tellers in general

PastSales

Perform actions on sales that are completed, or no longer active.

Drawer

Commands affecting cash drawer operation, float and cash control

Discount

Select and control discounts for current sale

Debug

Invoke a range of specialised options for debug and support use. Not for general use.

Need

Specify a range of requirements that must be met before the remaining POSCommands on the line are processed.

Settle

Perform an end of period cash settlement process to balance cash takings to transactions.

Stack

Change the order of sales presented to user, when more than one sale is active

Call

Call a script in a file directly. Typically used on buttons to call scripts to process how the button press should be handled.

Password

Validate user security or password before executing remaining commands on this line

Generate

Process items such as mouse clicks and keystrokes as if the user themselves had entered them. Can also generate operations events

Pole

Control customer pole displays

Counter

User controlled counters for providing unique or repeatable sequences

Stocktake

Commands to control stocktake handling

Group

Send a command to a group of elements, typically buttons or control screens. Mainly used for product modifer selection

Worklist

Worklist management functions

UI

Send a command to alter the User Interface screen, or one of the items on it, such as buttons.

Undocumented Commands

The following commands are not yet documented. They are listed here for reference purposes. Some of these commands will be documented to full support status, others may be retired

subscription()
printer()
storeserver
document
posc
product
remote
infobase()
telephone()
teller2()
chat()
intfunc()
storagenetwork()
iroute()
context()
plugin()
shift()
health()
return()
motorcharge()
g2()
stock()
object()
if()
fuel()
postec
account()
navigate
xml()
vault()
purchase()
lock() and unlock()
Lock a user defined named resource. Used to control single stream devices in a multiuser environment.
maint_customer()
goodsin()
sendpage()
grid()
callerid()
productfinder()
Deprecated
customer()
Deprecated
productfindermatrix()

Retired and Deprecated Commands

The following commands have been deprecated or retired and are no longer documented. Many of these commands continue to work to ensure backward compatiability.

custom()
A selection of highly customised functions for specific customers. This command should not be used in new environments and is present for backwards compatibility only.
eftpos()
This command has been replaced by the eft() command. It continues to work, but changes should be migrated to the eft() command. There are direct equivalents so this is not a hard process, only a syntax change.
spawn()
The spawn() command was used to create external processes. It has been replaced by the more powerful system(shell,...) command

PosScript is a Point of Sale specific scripting language to allow simple business rules to be implemented in the system. It is broadly similar in concept to Javascript but is different. There are alternatives to PosScript however this is very quick and flexible for small, rapid deployment

Fieldpine POS-Script is the scripting language used by Fieldpine POS core engine to control and influence operation of the POS. POS-Script allows you to alter and flex the POS in a wide variety of ways allowing close integration with your current business procedures.

PosScript is quickest to learn by examples. As it uses polymorphic operations, describing how it works can be hard to comphrend, where documented examples are reasonably obvious in intent

If you are already familar with one of the following languages, the following quick comparison may assist your understanding of script positioning.

C/C++ programmers
Lines do not terminate with a semi-colon. When a case tag is encountered in a switch statement, the default action of POS-Script is to abort, without requiring a break statement. If you do not want to abort, and wisht the script to continue through, issue the nobreak statement inside each case block.
VB Programmers
All script variables are internally variant datatypes. In reality they are more than simply a variant datatype, but a number variable is internally held in a variant type structure.
Assembler Programmers
Events are like interrupts or traps in nature.
VMS DCL Programmers
Variable _output is analagous to SYS$OUTPUT
Unix Scripts
Variable _output is analagous to stdout

Fundamentals

Script is a line processed script language. The POS dynamically interprets script at execution time by converting to an internal Just In Time compiled format. This compiled format is typically cached for repeat execution performance. If you are editing a script, the POS may not reload it automatically due to this caching, unless designer mode is selected or debug settings are selected to disable caching. To disable caching of script files, tick "Programming mode" on the configure page (or setting UIProgramMode=1 ).

The command parser is sensitive to whitespace, and if lines are not parsing as expected, it is wise to try separating each element with at least one space.

The POS also includes a runtime script debugger that allows you to set breakpoints and single step. You can enable the debugger by selecting "designer mode" on the debug screen.

Variables and Datatypes

Variable names must start with a letter.can only include letters and numbers.are not case sensitive and script writers are encouraged to only use lower case names.starting with underscore are reserved for internal use and special purposes.with dots, are used to refer to the Data Space.

Variables and DataTypes
Data Variable Type
Base data types are:
 number
 float
 string
 boolean
 money
 raw
 date
 time
 timespan
 special (described later)

The special purposes variable names are:
 _output   the current selected output device  

Formatting

When variables are output they can be formatted in different ways depending on their type.

Money

%a Abbreviated weekday name
%A Full weekday name
%b Abbreviated month name
%B Full month name
%c Date and time representation appropriate for locale
%d Day of month as decimal number (01 - 31)
%H Hour in 24-hour format (00 - 23)
%I Hour in 12-hour format (01 - 12)
%j Day of year as decimal number (001 - 366)
%m Month as decimal number (01 - 12)
%M Minute as decimal number (00 - 59)
%p Current locale's A.M./P.M. indicator for 12-hour clock
%S Second as decimal number (00 - 59)
%U Week of year as decimal number, with Sunday as first day of week (00 - 51)
%w Weekday as decimal number (0 - 6; Sunday is 0)
%W Week of year as decimal number, with Monday as first day of week (00 - 51)
%x Date representation for current locale
%X Time representation for current locale
%y Year without century, as decimal number (00 - 99)
%Y Year with century, as decimal number
%z, %Z Time-zone name or abbreviation; no characters if time zone is unknown

float

#	Insert a variable number of digits
0	Insert a single digit
other	Insert the character other.

boolean

Always formats as "1" for TRUE, and "0" for false.

Arithmetic

Operators
  +  addition
  -   subtraction
  *   multiplication
  /   division
  ^ and "xor"  exclusive or  (number variables only)
  | and  "or" inclusive or	(number variables only)
  & and "and" boolean and (number variables only)
  % and "remainder" remainder (number variables only)

Logical Expressions

 = or eq
<> or != or ne
< or lt
> or gt
<= or le
>= or ge
in

Commands

PosScript has a small set of commands primarily around flow control and variable loading. In additional there are a number of functions which are documented under Variables

PosScript can also directly embed PosCommands, meaning the PosScript can access all PosCommands and some additional flow control and variable operations that PosCommands do not have

++ or --
Postfix operator. Increases or decreases a variable by one.
Example:
	myVar++
	LoopCounter--
IF expression THEN statement
The if statement has two forms
    if expression then statement

    if expression
    then
	   statements
    else
	  statements
    endif 
	

In the first form, the expression is evaluated and if the result is true, the statement is executed. Only a single statement can be executed.

The second form is similar in that the expression is evaluated, and if the result is true, the statements in the then section are executed, if the result is false, the statements in the else section are executed. Multiple statements are permitted in each section. It is acceptable to omit the else section. The ENDIF directive is required.

SET variable = value
level(command) syntax(set) script Assign values to variables. The variable name on the left will receive the value from the right. The right hand side is evaluated before assigment.

Syntax

set output = input

The keyword set is optional.

Variable names should start with a letter, and only consist of letters and numbers. Array structures can be created by using [] syntax to address elements within an array.

Examples

set j = 5

set a = j

set b[2] = 5

j = string(5)

goto label
The goto statement may be used to transfer control to a label. The label must be within the current script block. A goto may jump in any direction, forward or backwards. You should not jump into or out of enclosing while/for/switch statements, but you may safely jump within if/then/else statements.

Syntax:
goto label

Labels are defined in a script by a single series of alphanumeric characters, terminated by a colon (:). The first character in a label must be a letter. Labels should be less than 30 characters, excluding the colon, in length.

Examples:
mylabel:
g56:

call
level(command) syntax(call) script Syntax call name

Transfer control to the routine name and when an exit statement is encountered continue on the next line in this script.

declare name
Specify the scope of variables named. Not commonly used
abort value
Abort script at this point, and return control to the smallest enclosing handler. Not commonly used
exit [status]

Finish the script at this time. An optional status can be returned. When script is being used in event handlers, the exit status is often used to indicate accept/decline type functionality. In other places, such as HTML server side scripting, the exit status of the script is not used.

dump
Reserved for debugging
menu
Deprecated. Add options to dynamic menus. This command allows a script used in a screen creation process to add menu options to the screen when it is created.
while
level(command) syntax(while) script Implements a while endwhile loop based on conditional logic. This permits a structured logic approach, rather than using GOTO loops alone.

Syntax

while condition
...commands
end while

The condition test should be a logic test alone, and not cause additional command execution. Using commands in the test logic is undefined in operation.

Examples

while 1 = f % 2
   f--
end while

f = 3
while f gt 0
   f--
endwhile

f = 2
message(99,1,f entry  F is %f%)
while f > 0
   message(99,1,%f%)
   set g = 2
   while (f > 0) & (g < 4)
	  message(99,1,Inner f=%f%  g = %g%)
	  g++
   end while
   f--
end while
message(99,1,f exit)
for
attempt
output
level(command) syntax(output [modifier] literal-text) script title(output) The output command is used to place literal text or variables directly into the output stream. This is typically used when the script is executing within the context of a web page, and the script wishes to alter the HTML stream. // output literal text //output var variable-name [formatting string]

The first form, is used to output exact text or HTML tags. The second form is used to output a script variable. When outputing script variables, these can be formatted using a format string, so that they are presented in a certain format.

Literal text is output exactly as shown. If you place the text in quotation marks, these quotation marks will be written to the output stream.

Examples:
set x = date(yesterday)
output Yesterday was the
output var x ~j
output th day of the year.

This script results in
Yesterday was the 138th day of the year.

define
Deprecated
convert
format
Syntax format type variable-list

Converts the list of variables given into the format given by type. This is typically used to prepare output for specific purposes such as Web page creation.

destroy

Delete the variable(s) named. Variables are normally internally destroyed, but in some cases where the variable is a special datatype, such as an open file, the variable needs to be destroyed at controlled points to achieve other actions. Destroying a variable that holds a file handle, results in the file being closed at this point.

switch
The switch statement is used to evaluate a range of result expressions, given a single selection expression. The syntax is

switch expression (selector)
case expression (target result 1)
script commands
case expression (target result 2)
script commands
default (catchall result)
endswitch

When processing a switch statement, script evaluates the selector expression, which results in a single value. This value is compared against each of the case expressions, and when an equality match is found, the following script commands are executed. All the commands after the matching case statement are evaluated, until the next case statement is encountered.

Within a case block execution will stop when the next case label is reached. The keyword nobreak may be used, which when encountered causes control not to break on the next case expression(s), but instead to follow through to the next set of script commands. This method of operation is different from what C and Javascript programmers might be familiar with.

The default case label should be the last label, as any case statements after the default label will not be processed.

Example:

switch f 
case	1
	message(99,1, f is 1)
case	2
	message(99,1, f is 2)
case	3
	message(99,1, f is 3)
	nobreak
case	4
case	5
	message(99,1, f is 4 or 5 or flow through from 3)
default
	message(99,1,In default)
	f = 3
endswitch

When processing case labels, the script processor evaluates each case expression in turn, and executes the first match. Once a match has been met, control transfers to the endswitch statement. Technically, this allows case statements to be expression themselves, such as case myvariable.

debug
level(command) syntax(debug) script Syntax debug

This command available only in POSDesigner.

When this statement is executed, the POS pauses script execution and displays the script debugger.

:label
Defines a label that can be used as a target for goto

Events in the POS are internal actions and conditions that occur when certain actions are processed. For example, creating a new sale causes a new-sale event to be fired. You can write event handlers in POS-Script to handle and control how events are processed. This scripted ability gives you absolute control over the complete sale handling in your POS

Events are desigend solely to handle small tasks and return control to the main POS logic. You should not attempt large scale changes to the system, such as altering unrelated sales. It is also not permitted to cause recursion, such that an event handler causes itself to be fired again while still active. eg A "set customer" event cannot use POS Commands that would cause the current customer to change again while the first is still being processed.

POS Sale
V ^
Event Fires Returns to original sale
V ^
Calls User Handler » Performs checks/changes » Exits

The illustration highlights how events are called as part of the internal processing and return to the same context when they started

Events are most useful for ensuring business rules are being enforced. Adding a saleline might use an event to ensure all relevant information is captured for the saleline

Events are not reprocessed after restart. If the system is shutdown for any reason while an event handler is processing, there is no guarantee it will be reactivated when the POS starts again.

Event handlers can be written using PosScript, C programming language, or using the TalkToFieldpine interface

The following table shows when events were enabled for different interfaces. N/A means an event is deliberately not available for an interface. A space means not yet implemented or available for customer use.

A Passive event is where the system advises you something, but you have no ability to alter or control this event. An active event allows you to control operation

EventPosScript"C"TTFTypeDescription
16100N/AP1918PassiveCalled when a server system is about to store a sale from a trading lane
16300 HttpSocketAcceptN/AP1918ActiveCalled after a TCP connection has been accepted. You can abort the connection.
This is a sample only, see full version

Barcode Events

Unknown Barcode for defintion An unknown barcode has been scanned, and the user is about to be prompted

Unknown Barcode, Definition disabled An unknown barcode has been scanned and definition is disabled

Unknown Customer Barcode An unknown customer barcode has been scanned

Customer and Account Events

Customer Sales History Request A request to display the customer purchase history

Account Detail Request Full Account Details have been requested

Hardware Events

These events require additional components and are only present for some types of Hardware

Printer Offline A printer has moved to an offline state

Cash Drawer Change A cash drawer has been opened or closed

Sale Events

Sale, New Creation A new sale has just been created

Sale, Request to Park A request to park a sale has been made

Sale Writeoff Request A request to writeoff a sale has been made

Sale Quit Request The user has requested to abort the sale

Sale Trash Request A request to trash or void the current sale is being made

Sale About to Complete The Sale is about to complete normally

Sale Return Request The user requests that the current sale is processed as a return

Sale Set Customer A customer is being set to a sale

Sale Set Customer Request A customer is about to be set to a sale. Check permitted

Sale Purge Request A request is being processed to purge a sale from the database

Sale Purge Complete A sale has just been purged from the database.

Sale Fully Complete The sale has just been completed and removed from the POS processing stack

Saleline Events

Saleline Adding Product A product has just been added to the sale.

Saleline Return Adjustment Called when an item is being returned on a sale.

Saleline Adding Cash Item A Cash or Manual item is being added to the sale

Saleline Adding a discount A Discount is being applied to a saleline

Saleline Removing a discount A Discount is being deleted from a saleline

Saleline Price Changing The price being charged on an item is changing

Saleline Quantity Changing The quantity on a saleline is changing

Saleline Change A non-specific change has occurred to a saleline

Saleline Remove Item from Sale A saleline is about to be deleted from a sale

Saleline Pre Add of Item A product is about to be added to a sale, last chance for a script to block this action

Saleline Total Price Changing The total price on a saleline is changing

Saleline Price Prompting Required The user is about to be prompted for the price of an item

Saleline Return Request A return is requested

Saleline Delete Discount Request A request has been made to delete a discount from a saleline

Settlement Events

Settlement Closing The settlement process is closing

Settlement Close Parked Sales Special handling of parked sales during a settlement closing

Settlement Printing The settlement slip is printing and extra information can be added

Settlement Closing Blind Phase The settlement process is closing after the blind step

System Events

Location Change The system has just changed to a different store location

Web Server Request A new request for the Web Server has been received

Teller Management Events

Teller Change The active teller has just changed for a context

Teller Password Failure A teller login has failed

Teller Change Request A new teller login has been requested

Teller Maximum Failure The teller has just failed the maximum number of times and the login has been disabled

User Interface Events

Screen Request A new screen is about to be displayed

Debug Screen Request The Debug screen is about to be displayed

Config Screen Request The configuration screen is about to be displayed

User Input Request The user is about to be queried for information.

Adding Images and Text to receipts

This example shows how random images and text can be placed on customer receipts using PosCommands.

Printing on external pre-printed stationery

Shows how POS can print on external pre printed forms. Used for filling in details on forms, such as regulatory documents or event tickets.

Displaying user messages in a web page

Describes how simple user prompting messages can invoke a web page, allowing you to customise the display and operation of a message being displayed