1. General information


1.1. Purposes

1.1.1. To make user functions that are not preset.

1.1.2. To achieve specific automatic system behaviour.

1.1.3. This manual based on ftp://ftp.ucs.ru/rk7/ForDealers/docs_english/RK7Scripts.doc


2. How to make use in RK7


2.1. Manager station points

2.1.1. Scripts reference

2.1.1.1. Open "Service" -> "Scripts".

 2.1.1.2. Create new script in "Operations" (if you want to use it as operation) or other group and open editor by pressing "other" section "SomeScript" property.

2.1.2. Operations reference

 2.1.2.1. Open "Service" -> "Operations". Choose one of editable user operations (rename it for convenience).

2.1.2.2. Assign your script to "Scripting" section "Script" parameter.

2.1.3. Forms reference

2.1.3.1. To use Scripts as form modifiers you are to do the following.
2.1.3.2. Open Form in builtin editor (copy preset one if you used to use that).


2.1.3.3. Select necessary selector panel and open "Events" tab [Other] section any ("OnCompare", for example) property.

2.1.3.4. And put in your script to editor and press "OK" to save.

2.1.4. Function keys

2.1.4.1. Go to "Options" -> "User interface" -> "Function keys".

2.1.4.2. Create new one and give the name. Assign operation to "Basic" section "Operation" and "Operation for empty" parameters.

2.1.5. Selectors

2.1.5.1. Go to "Options" -> "User interface" -> "Selectors". Copy preset selector if you used to use that.

2.1.5.2. Add necessary function keys to any chosen selector page.

2.1.5.3. Do not forget setting proper usage.

2.1.6. Layouts

2.1.6.1. Open Layout editor and content editor inside it. There are script facilities both for bands and memos. Script area is a lower one.

2.1.6.2. This editor is not the same as in "scripts": you don't need to write a code outside "begin-end". There is even the special GUI for variables definitions.

2.1.6.3. Find additional information on layouts in .


3. Standard functions


3.1. Working with numbers


function Abs(e : Extended) : Extended;
Returns absolute meaning of argument e (e by modulus).

3.2. Working with strings


function StrGet(var S : String; I : Integer) : Char;
Returns element of string S with index I.
 
procedure StrSet(c : Char; I : Integer; var s : String);
Sets element of string S with indexI in meaning c.

function Uppercase(s : string) : string;
Returnsstring s in upper case.

function Lowercase(s : string) : string;
Returns string s inlowercase.

function Trim(s : string) : string;
Returns changed string sall beginning and ending “spaces” and control symbols are deleted.

function Length(s : String) : Longint;
Returns length of string s.

procedure SetLength(var S: String; L: Longint);
Sets length of string S in L.

function inttostr(i: Longint): string;
Returns stringthat contains transformed integer value i.

function strtoint(s: string): Longint;
Returns integer value, taken from string s.

function strtointdef(s: string; def: Longint): Longint;
Returns string s, transformed to integer value. If this string is not allowed integer, then value by default def is returned.

function copy(s: string; ifrom, icount: Longint): string;
Returns string that is sub-string of string S, starting from S[ifrom] and containing icount number of symbols.

function pos(substr, s: string): Longint;
Returns position (index) of first meeting subsrtinS. If S doesn’t contain Substr, 0 is returned.

procedure delete(var s: string; ifrom, icount: Longint);
Deletes from string S icount number of symbols from position ifrom.

procedure insert(s: string; var s2: string; ipos: Longint);
Inserts string s into s2from position ipos.

function StrToFloat(s: string): Extended;
Function returns real number (with floating point), transformed from s.

function FloatToStr(e : Extended) : String;
Returns string, this string is transformed value of e.

function Padl(s : string; I : longInt) : string;
Returns stringsadded with “spaces to the length of I on the left part.

function Padr(s : string; I : longInt) : string;
Returns stringsadded with “spaces to the length of I on the right part.

function Padz(s : string; I : longInt) : string;
Returns stringsaddedwithsymbols ‘0’ to the length of I on the left part.

function StringOfChar(c : char; I : longInt) : string;
Returns string, that consists of I symbols ‘C’.

 function FormatFloat(const Mask: string; d : Extended) : String;
Returns string, that consists of value d transformed with the help of mask Mask.

3.3. Working with arrays

function getarraylength(var v: array): Integer;
Returns length of array v.

procedure setarraylength(var v: array; i: Integer);
Sets length of array v into i.

3.4. Working with “variant” type

function VarGetType(x: Variant): TVarType;
Returns code of data type, that are stored in variable x.

function Null: Variant;
Returns value NULL.


4. RK7 data types


4.1. Simple data types


Simple data typesthat are used in functions and classes of RK7, are described below:

Type name

Corresponding type

Description

TQuantity

Int64

Usedforquantity

TMoney

Int64

Usedforsum

TWeight

Int64

Usedforweight

TSmallWeight

Longint


TimeMacro

TDateTime


Int2

Smallint


Int4

Longint


Int8

Int64


TEditType

(etInsert, etRemove, etChange)

Usedforcallingfunctionoforderediting – defineseditingtypepastingdeletionorchangingofanelement

 TDrawItemState 

(disNone, disOpened, disLocked, disFixed, disPrinted, disPartClosed, disClosed, disDeleted)

Elementcondition:
Opened, Blocked.

4.2. RK7 classes

4.2.1. Syntax description


All classes, that can be used in RK7 scripts, are described below. Syntax:
ClassName (ParentClassName)
      Methods
            // methods description (may not be present)
      Properties
            // class properties description (may not be present). Syntax:
            // AccessType PropertyType PropertyName
            // AccessType:    ROReadOnlyWOWriteOnlyRWReadWrite
            // PropertyType: type of the property, for example, int64, string
            // PropertyName: name for referring to property.

4.2.2. Classes


TIdentItem (TPersistent)
TIntegerId (TIdentItem)
TDrawItem (TIntegerId)
properties
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State

TDrawItemList (TIdentItem)

properties
 RO TDrawItem ITEMS[i]
 RO integer ITEMCOUNT
TCheckItemList (TDrawItemList)


TCheckItem (TDrawItem)
properties
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State


tPrintCheckItem (TCheckItem)
properties
 RO Boolean WasAllChangeToTip
 RO TRate BasicRate
 RO Integer iVoid
 RO Boolean IsBill
 RO Integer PrintTry
 RO Integer iDeleteManager
 RO TDateTime DeleteDateTime
 RO Boolean Deleted
 RO tCheckSubItemList CurrLines
 RO Boolean BillError
 RO Boolean PrintError
 RO String DeleteManager
 RO String Void
 RO String Drawer
 RO String CloseStation
 RO String PrintStation
 RO String Printer
 RO String SeatName
 RO TMoney TaxSumAdded
 RO TMoney TaxSum
 RO TMoney DistrMarkupSum
 RO TMoney DiscountSum
 RO TMoney ChargePriceListSum
 RO TMoney DishPriceListSum
 RO TMoney PRListSum
 RO TMoney BindedSum
 RO TMoney ToPaySum
 RO TMoney FiscalSum
 RO TMoney NationalSum
 RO TMoney BasicSum
 RO Byte Seat
 RO Integer ParentCheckNum
 RO Integer CheckNum
 RO Integer PrintNumber
 RO Integer iDrawer
 RO Integer iFiscShift
 RO Integer iShift
 RO Integer iCloseStation
 RO String35 ExtFiscID
 RO Integer iPrinter
 RO Integer iPrintStation
 RO TDateTime CloseDateTime
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State


TDish (TCheckItem)
properties
 RO Boolean Selected
 RO String SeatName
 RO TMoney ClosedPaySum
 RO TMoney ClearSum
 RO TMoney PaySum
 RO TMoney SumWithDiscounts
 RO tPayBindings PayBindings
 RO TMoney PriceSumBinded
 RO Boolean IsPortion
 RO Integer iTaxDishType
 RO TVoids Voids
 RO TConsumators Consumators
 RO TDiscounts Discounts
 RO TModifiers Modifiers
 RO Byte Seat
 RO Byte QntFormat
 RO Smallint CookMins
 RO TMoney BonusBaseSum
 RO TMoney CalcConsumSum
 RO TMoney ConsumSum
 RO TMoney PRListSum
 RO TMoney Price
 RO Boolean IsUserPrice
 RO TQuantity SrcQuantity
 RO TQuantity Pieces
 RO TQuantity Quantity
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State


tCommonPayLine (TCheckItem)
properties
 RO Integer iHighLevelType
 RO String PrintOwnerInfo
 RO String OwnerInfo
 RO String ISO
 RO String CurrencyName
 RO String TaxPayTypeName
 RO Integer TaxPayTypeSifr
 RO Integer PrintCheckUNI
 RO TRate DBKurs
 RO TMoney NationalSum
 RO TMoney BasicSum
 RO TMoney OriginalSum
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State


TDishSubItem (TCheckItem)
properties
 RO Integer DishUNI
 RO Integer OwnerUNI
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State
 
TDiscountItem (TDishSubItem)
properties
 RO Boolean PDSTransaction
 RO String SrcValue
 RO String SeatName
 RO String DishName
 RO Boolean IsMarkup
 RO Boolean IsDiscount
 RO Integer SessionUNI
 RO Byte Seat
 RO Boolean ValueChanged
 RO TMoney MaxAmount
 RO Boolean IsCharge
 RO TMoney BonusAmount
 RO TMoney CalcAmount
 RO TMoney DiscountBase
 RO TPercent CalcPercent
 RO TMoney SrcAmount
 RO TCountType CountType
 RO Integer MInterface
 RO Integer BonusType
 RO Int64 AccountIdent
 RO String CardCode
 RO TChargeSource ChargeSource
 RO TChargeLocalization Localization
 RO Integer DishUNI
 RO Integer OwnerUNI
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State


TSessionLines (TCheckItemList)


TOrderSession (TCheckItem)
properties
 RO Integer iRemindServiceScheme
 RO Integer iPrintServiceScheme
 RO TSessionFlags SessionFlags
 RO TDateTime ReadyAt
 RO TPrintFlag ReadyFlag
 RO TDateTime RemindAt
 RO TPrintFlag RemindFlag
 RO TDateTime PrintAt
 RO TPrintFlag PrintFlag
 RO Integer iKurs
 RO tSessionLines Lines
 RO Integer ExtraUNI
 RO Integer ExtraVisit
 RO String Kurs
 RO String TransferInfo
 RO String Station
 RO String TradeGroup
 RO String Period
 RO String PriceScale
 RO Integer CreatorCode
 RO String Creator
 RO String Author
 RO Integer AuthorCode
 RO String SessionType
 RO Integer iStation
 RO Integer iTradeGroup
 RO Integer iPeriod
 RO Integer iPriceScale
 RO TDateTime EndService
 RO TDateTime StartService
 RO TSessionType iSessionType
 RO Integer IdInVisit
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State

tOrder (TCheckItem)
properties
 RO Integer iLastUser
 RO Integer LockedByStation
 RO String OtherWaitersString
 RO Integer iCommonShift
 RO TMoney DiscountSum
 RO TMoney UnClosedPrepaySum
 RO TMoney UnClosedPriceSum
 RO TMoney UnpaidSum
 RO TMoney PaidSum
 RO TMoney ToPaySum
 RO TMoney PriceListSum
 RO Int64 Duration
 RO Boolean FinishedService
 RO TDateTime EndService
 RO TDateTime StartService
 RO Integer iNationalCurrency
 RO Integer iBasicCurrency
 RO Integer Brigade
 RO Integer MainWaiter
 RO Integer UOT
 RO Integer COT
 RO Integer TableID
 RO TDateTime OpenTime
 RO Byte NumOnTable
 RO Integer UVN
 RO TDateTime LastService
 RO TOrderFlags Flags
 RO tLongSet256 SeatsFixed
 RO tLongSet256 OrderGuests
 RO Integer GuestsCount
 RO String VisitOtherInfo
 RO String VisitExtraInfo
 RO Boolean UnPaid
 RO String LastUser
 RO String GuestType
 RO Integer MainWaiterCode
 RO Integer CreatorCode
 RO String CreatorName
 RO Integer OrderCategoryCode
 RO String OrderCategory
 RO Integer OrderTypeCode
 RO String OrderType
 RO Integer TableCode
 RO String MainWaiterName
 RO String OrderName
 RO String TableName
 RO String TableNum
 RO Boolean CalcBySeats
 RO Boolean CanClose
 RO Boolean UnclosedReceipts
 RO Boolean UnsavedExists
 RO Boolean BillExists                             - checks if bill was printed (RKCheck.CurrentOrder.BillExists);
 RO Boolean IsCalcVisit
 RO Boolean UnclosedPrepays
 RO Boolean Paid
 RO Boolean Tarif
 RO Boolean Unprinted
 RO Boolean Locked
 RO Boolean IsEmpty
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemState State
 RO TOrderSession Sessions[i]


TOrderSessions (TCheckItemList)
properties
 RO Integer Version
 RO Integer iLastUser
 RO TOrderFlags OrderFlags
 RO Boolean BySeats
 RO Integer COT
 RO Integer UniCount
 RO Boolean OneOrder
 RO tLongSet256 SeatsClosed
 RO TOrderSession Items[i]
 RO TCheckItem Lines[i]
 RO integer LinesCount


TPayLine (tCommonPayLine)
properties
 RO Integer AddByInterface
 RO Integer MInterface
 RO tTransactionStatus TransactionStatus
 RO TAuType AuthType
 RO Integer TransactionID
 RO String Owner
 RO Int64 AccountIdent
 RO String Track2
 RO String AuthCode
 RO TDateTime ExpDate
 RO String CardNum
 RO Integer CurrLineUNI
 RO String PayPrefix
 RO String AuthTypeName
 RO String SeatName
 RO Integer SessionUNI
 RO Byte Seat
 RO Integer SourcePayUNI
 RO Boolean IsPrepay
 RO TPayLineType PayLineType
 RO TInputType InputType
 RO TMoney CurrLineSum
 RO String ChangeForOwnerInfo
 RO String ChangeCurrency
 RO Integer ChangeForCurr
 RO Integer iHighLevelType
 RO String PrintOwnerInfo
 RO String OwnerInfo
 RO String ISO
 RO String CurrencyName
 RO String TaxPayTypeName
 RO Integer TaxPayTypeSifr
 RO Integer PrintCheckUNI
 RO TRate DBKurs
 RO TMoney NationalSum
 RO TMoney BasicSum
 RO TMoney OriginalSum
 RO Integer Tag
 RO Boolean Modified
 RO Integer iAuthor
 RO Integer iCreator
 RO String Name
 RO Integer Code
 RO Integer UNI
 RO Integer Sifr
 RO Integer Number
 RO Boolean PartClosed
 RO TDrawItemStateState

4.3.3. Other


4.3.3.1. RKCheck.CurrentOrder.Visit.GuestCnt

4.4. RK7 functions

4.4.1. Interaction with system parameters

Parameter search is made (using field ‘Parameter’ – value in this field is often in English.)

 function StrParam(ParamName: string): string;
Returns string value of parameterParamName.        

function IntParam(ParamName: string): integer;

Returns integer value of parameterParamName.        

function BoolParam(ParamName: string): boolean;

Returns boolean value of parameterParamName.

4.4.2. Interaction with interface


procedure InterfaceHandlerProcessCard(InterfaceCode: integer; CardID: string);

Procedure calls interface processing with code InterfaceCode of information from the card - CardID. After processing data is put into structure CARDINFO (information about this structure is provided by request).

procedure InterfaceHandlerGetCardAddInfo(InterfaceCode: integer; CardID: string; InfoType: integer; var AddInfo: string);
Receives additional information from the card with data CardID, using interface with code InterfaceCodeAddInfo – is information, received as a result of making request. More detailed information is provided by request.

4.4.3. Form events handlers


You can define your own event handlers for all components on the form. Element types and eventsfor that handlers can be definedare described below.

TCheckView
Events that occur in process of CheckView editingOnBeforeCheckViewEdit – before editing,OnAfterCheckViewEdit – after editing.

procedure OnBeforeCheckViewEdit(
Sender: TObject;        // object CheckView itself
AEditTypeTEditType;  // type of editing
AObjectBef,             // object before changing
AObjectAftTObject;    // object after editing
varAAllowboolean;    // allow changing
varAMessagestring); // error message, if changing is forbidden

procedure OnAfterCheckViewEdit(
Sender: TObject;        // object CheckView itself
AEditTypeTEditType;  // type of editing
AObjectBef,             // object before changing
AObjectAftTObject);   // object after changing

Both objects (AObjectBefAObjectAft) are elements of TCheckItem type. You can define type, using function ObjectInheritsFromIf editing type is etInsert (insertion), then AObjectBef = nil. If editing type is etRemove (deletion), then AObjectAft = nil.

4.4.4. Other functions

function ObjectInheritsFrom(PersistentObject: TObject; PersistentClassName: string): boolean;
Defines, if object PersistentObject is inheritor of the class PersistentClassName.
 
function MenuItemBarcode(BarCode: string): boolean;
DefinesifparameterBarCodeis a bar code of any particular dish.
 
function EmployeeCardCode(CardCode: string): boolean;
DefinesifparameterCardCodeis a card code of any particular worker.
 
function Translate( S: String ): String;
Function makes translation of string S to current language, using translation file. It returns translated string (or current string, if translation was not found).

procedureWaiterMessage(MsgWaiterintegerMsgTextstringValidUntilTDateTime);
Send message with text MsgText to worker with code MsgWaiterValidUntilis time, during that message is actual, for example:
WaiterMessage(10, ‘Sample Message’, NOW + DAYS(5));
It means to send messageSample Message’ to worker with code 10, actual time is 5 days from current moment.

4.5. Interaction with object RK7Interface

4.5.1. Interaction with system parameters   


function GetIntSysParameter(
ParamName: string;      // parameter name
varValIntInteger     // numeric value of parameter
): Boolean;             // result – if execution was successful

functionGetStrSysParameter(
ParamNamestring;      // parameter name
varValStrstring     // string value of parameter
): Boolean;             // result – if execution was successful

4.5.2. Interaction with own parameters


                function GetIntOwnParameter(
ParamNum: integer;      // parameter number
varValIntInteger     // numeric value of parameter
): Boolean;             // result – if execution was successful

functionGetStrOwnParameter(
ParamNuminteger;      // parameter number
varValStrstring     // string value of parameter
): Boolean;             // result – if execution was successful

4.5.4. Interaction with objects’ properties


function GetOrdObjectProperty(
Obj: TObject;           // object
PropName: string;       // property name
varValIntInteger     // numeric value of this property
): boolean;             // result – if execution was successful

functionGetInt64ObjectProperty(
Obj: TObject;           // object
PropName: string;       // property name
varValInt64: int64     // numeric value of this property
): boolean;             // result – if execution was successful

functionGetStrObjectProperty(
Obj: TObject;           // object
PropName: string;       // property name
varValStrstring      // string value of this property
): boolean;             // result – if execution was successful

4.5.5. Interaction with references


              // Number of elements in manual
functionRefItemCount(
ObjTypeinteger // object type
): integer;       // result – number of elements

// Object from the manual by number
functionRefItemByNumber(
ObjTypeinteger; // object type
numinteger      // number of this element
): TObject;       // result – object TReferentItem or nil

//Find element in collection by id
functionFindRefItem(
ObjType,          // object type
ItemIDinteger   // object identifier
): TObject;       // result – object TReferentItem or nil

//Find elements by usage
function GetFilteredObject(
ft: TFilterType; // type of usage
ParentIdinteger // element
): integer;       // result – element identifier

4.5.6. Interaction with object CheckItem (element of a check)


                // get current sessions
functionCashSessions(
): TObject;       // result – object TOrderSessionsornil

// Number of elements in CheckItemList
function CheckItemCount(
List: TObject     // object TCheckItemList
): integer;       // result – number of elements

//Objectfrom CheckItemListby number
function CheckItemByNumber(
List: TObject;    // object TCheckItemList
num: integer      // element number
): TObject;       // result – objectCheckItemornil

// Find in OrderSessions
function FindCheckItem(
Sessions: TObject;// list of sessions (object TOrderSessions)
ObjUNI: integer   // identifier
): TObject;       // result – object CheckItem or nil

// Current visit
function CurrentVisit: TObject; // result – object TVisitor nil

// Current order
function CurrentOrder: TObject; // result – object TOrder or nil


5. RK7 operations processing


5.1. Common syntax

5.1.1. RK7 operations (represented on manager station in Service -> Operations) can be run from scripts. Common sytax is like this:

function PerformOperation(
Operation,         // operation
Parameter: integer // parameter
): integer;   // not 0, if it is processed

5.1.2. Some constants are created to provide easy using, they are seen in manual «Operations» as a property "Operation".

5.1.3. There are some operations, that change parameters value: functions SaveVarIntSaveVarStrSaveVarObj exist for such operations. So operation calling should be described like this:

var Data: integer;
     ...
Data := 5;
PerformOperation(rkoSomeOperation, SaveVarInt(Data));
ifData < 0 then
     ...

5.2. Brief list of main operations

Operation

Parameter

Action

rkoUserForm

Form number,
integer

Opens user form with defined number

rkoSetCurrentItem

Index

Sets position (in form of order editing) to defined element

rkoSetInputText

String,
SaveVarStr()

Defines text of entry field (order editing window)


6. Examples



6.1. See details in