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.
Post financial completion sale state management. Typically used when a sale is used in an extended form, such as a food order.
Commands to alter the underlying configuration or definition data the POS is operating against
Send a single digit sequence to a control. Typically used to route single keystrokes to the element designated to process it.
Send a string sequence to a control. Typically used to allow single keystrokes to cause sequences of commands to process.
Create a new sale if none is currently present. Often used before sequences that affect sales
Check if the sale is completable, and if so, process the required steps to close the sale now.
Commands to affect current teller and control tellers in general
Commands affecting cash drawer operation, float and cash control
Invoke a range of specialised options for debug and support use. Not for general use.
Perform an end of period cash settlement process to balance cash takings to transactions.
Change the order of sales presented to user, when more than one sale is active
Call a script in a file directly. Typically used on buttons to call scripts to process how the button press should be handled.
Validate user security or password before executing remaining commands on this line
Control customer pole displays
User controlled counters for providing unique or repeatable sequences
Commands to control stocktake handling
Send a command to a group of elements, typically buttons or control screens. Mainly used for product modifer selection
Worklist management functions
Send a command to alter the User Interface screen, or one of the items on it, such as buttons.
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
The following commands have been deprecated or retired and are no longer documented. Many of these commands continue to work to ensure backward compatiability.
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.
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.
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 DataTypesBase 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
When variables are output they can be formatted in different ways depending on their type.
%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
# Insert a variable number of digits 0 Insert a single digit other Insert the character other.
Always formats as "1" for TRUE, and "0" for false.
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
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
Example: myVar++ LoopCounter--
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.
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)
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:
Transfer control to the routine name and when an exit statement is encountered continue on the next line in this script.
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.
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)
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.
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.
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 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.
This command available only in POSDesigner.
When this statement is executed, the POS pauses script execution and displays the script debugger.
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
Event | PosScript | "C" | TTF | Type | Description |
16100 | N/A | P1918 | Passive | Called when a server system is about to store a sale from a trading lane | |
16300 HttpSocketAccept | N/A | P1918 | Active | Called after a TCP connection has been accepted. You can abort the connection. | |
This is a sample only, see full version |
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 Sales History Request A request to display the customer purchase history
Account Detail Request Full Account Details have been requested
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, 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 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 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
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 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
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