BPS Script API  2.24.4
bps Namespace Reference

The bps extension is a namespace assembling general BPS properties and functions. More...

Namespaces

 gui
 The bps.gui extension is a namespace assembling GUI properties and functions.
 
 installer
 The bps.installer extension is a namespace holding classes for installation and update of the BPS database.
 
 validator
 The bps.validator extension is a namespace holding the base class for field validators.
 

Classes

class  AsyncIO
 The bps.AsyncIO class provides functionality for reading and writing asynchronous serial ports. More...
 
class  Brush
 A wrapper for QBrush. More...
 
class  CmdlineParser
 A parser for command line arguments. More...
 
class  Color
 A wrapper for QColor. More...
 
class  Datastore
 The datastore class is used to access the BPS databases. More...
 
class  Decimal
 A class for decimal arithmetics. More...
 
class  Dir
 The bps.Dir class provides access to directory structures and their contents in a platform-independent way. More...
 
class  FieldValidator
 This class implements the BPS table field validator. More...
 
class  File
 The bps.File class provides functionality for reading and writing binary and text files. More...
 
class  Font
 A wrapper for QFont. More...
 
class  Margins
 A wrapper for BpsMargins. More...
 
class  MaskProcessor
 This class implements the BPS mask validator for input text. More...
 
class  OrderUtils
 The OrderUtils class holds a number of utility methods for order processing. More...
 
class  Pen
 A wrapper for QPen. More...
 
class  Pixmap
 A wrapper for QPixmap. More...
 
class  Point
 A wrapper for QPointF. More...
 
class  Query
 The query class is used to process SQL queries. More...
 
class  Schedule
 This class implements the BPS schedule object. More...
 
class  Settings
 Create and query settings on the local maching and in the central datastore. More...
 
class  Size
 A wrapper for QSizeF. More...
 
class  SqlValues
 Convenience class to help composing select, insert and update statements. More...
 
class  Timer
 The Timer class provides repetitive and single-shot timers. More...
 
class  XmlReader
 A wrapper for QXmlStreamReader. More...
 
class  XmlWriter
 A wrapper for QXmlStreamWriter. More...
 

Enumerations

enum  Access { AccessNone = 0 , AccessReadOnly = 1 , AccessReadWrite = 2 }
 Simple access control. More...
 
enum  Alignment { AlignTopLeft = 0 , AlignTopCenter = 1 , AlignTopRight = 2 , AlignMiddleLeft = 3 , AlignMiddleCenter = 4 , AlignMiddleRight = 5 , AlignBottomLeft = 6 , AlignBottomCenter = 7 , AlignBottomRight = 8 }
 General alignment. More...
 
enum  Barcode {
  BarcodeEAN13 = 0 , BarcodeEAN8 = 1 , BarcodeUPCA = 2 , BarcodeUPCE0 = 3 , BarcodeUPCE1 = 4 , BarcodeSUPPL2 = 5 , BarcodeSUPPL5 = 6 , Barcode39 = 7 , Barcode39C = 8 , Barcode39E = 9 ,
  Barcode39EC = 10 , Barcode2of5 = 11 , Barcode2of5C = 12 , Barcode128 = 13 , Barcode128S = 14 , Barcode128R = 15 , BarcodeEAN128 = 16 , BarcodeEAN128S = 17 , BarcodeRSS14 = 18 , BarcodeRSS14S = 19 ,
  BarcodeRSS14SO = 20 , BarcodeRSSLIM = 21
}
 Type of the bar code. More...
 
enum  Direction { DirectionEast = 0 , DirectionSouth = 1 , DirectionWest = 2 , DirectionNorth = 3 }
 Basic Compass Directions. More...
 
enum  HorizontalAlignment { AlignLeft = 0 , AlignCenter = 1 , AlignRight = 2 }
 Horizontal alignment. More...
 
enum  PaperOrientation { Portrait = 0 , Landscape = 1 }
 Paper orientation. More...
 
enum  PixmapSizing { SizeFixed , SizeFit , SizeFill }
 Pixmap sizing mode. More...
 
enum  Rotation { Rotation0 = 0 , Rotation90 = 1 , Rotation180 = 2 , Rotation270 = 3 }
 Rotation in 90 degree steps. More...
 
enum  Status { OK = 0 , Error = 1 , Timeout = 2 , Locked = 3 , Notlocked = 4 , Notfound = 5 }
 General purpose return status. More...
 
enum  VerticalAlignment { AlignTop = 0 , AlignMiddle = 1 , AlignBottom = 2 }
 Vertical alignment. More...
 

Functions

Boolean canEditInstallSettings ()
 Check if the the local installation settings are editable. More...
 
String dateToTimestampString (Date aDate)
 Format date object to a timestamp string. More...
 
Number decryptPin (Number aUserid, Number aPin)
 Decrypt a user PIN. More...
 
String directory (String aName="")
 Get a BPS application directory. More...
 
String dump (Mixed aValue, Number aMaxDepth=100)
 Format any variable (except functions) for debug output. More...
 
Number encryptPin (Number aUserid, Number aPin)
 Encrypt a user PIN. More...
 
String formatError (Error aError)
 Format an Error for display. More...
 
String formatNiceNumber (Number aValue)
 Format a large integer number for better human readability, for example 1234567 becomes 1'234'567. More...
 
Boolean isElevated ()
 Check if the current process is running with elevated or limited privilege. More...
 
void lerror (...)
 Print to log error output. More...
 
void lfile (...)
 Print lo log file only. More...
 
void log (...)
 Print to log output. More...
 
void logClose ()
 Close the log file. More...
 
void logOpen ()
 Opens the log file and writes the script name and starting date/time into it. More...
 
void msleep (Number aMilliseconds)
 Sleep for the time specified in milliseconds. More...
 
void mwait (Number aMilliseconds)
 Wait for a number of milliseconds. More...
 
String personalFolder ()
 Get the personal data folder. More...
 
Boolean printData (String aPrinterName, String aDocName, String aData, String aCodec="")
 Send data to a printer. More...
 
Boolean printFile (String aPrinterName, String aDocName, String aFileName)
 Send a file to a printer. More...
 
Number round (Number aValue, Number aDigits=3)
 Round off as per standard commercial practice. More...
 
void sleep (Number aSeconds)
 Sleep for the time specified in seconds. More...
 
String sprintf (String aFormat, Mixed aArgs)
 A string formatting function. More...
 
Date timestampStringToDate (String aTimestampString)
 Parses a date/time encoded in text with format YYYYMMDDHHMMSS. More...
 
void usleep (Number aMicroseconds)
 Sleep for the time specified in microseconds. More...
 
void wait (Number aSeconds)
 Wait for a number of seconds. More...
 

Variables

String logFile
 The log file name used by bps.log(), bps.lerror() and bps.lfile(). More...
 
Number logLevel
 The level to indent the log outputs by. More...
 
String Version
 Software version as text.
 
Number VersionFix
 Software fix version number.
 
Number VersionMajor
 Software major version number.
 
Number VersionMicro
 Software micro version number.
 
Number VersionMinor
 Software minor version number.
 

Detailed Description

The bps extension is a namespace assembling general BPS properties and functions.

There is only one static bps object, you can not create new objects of this type.

The extension needs to be loaded before it can be used:

with (bps) {
log('Script started');
...
void importExtension(String aExtensionName)
Imports the named extension into the script engine.
The bps extension is a namespace assembling general BPS properties and functions.
Definition: bps.AsyncIO.js:1
void log(...)
Print to log output.
void logOpen()
Opens the log file and writes the script name and starting date/time into it.

Embedded scripts (getting called by BPS C++ code) such as report scripts for example have the bps extension allready loaded by default.

Enumeration Type Documentation

◆ Access

Simple access control.

Enumerator
AccessNone 

No access permission.

AccessReadOnly 

Read only access.

AccessReadWrite 

Read/write access.

◆ Alignment

General alignment.

Enumerator
AlignTopLeft 

Align to the top left.

AlignTopCenter 

Align to the top center.

AlignTopRight 

Align to the top right.

AlignMiddleLeft 

Align to the middle left.

AlignMiddleCenter 

Align to the middle center.

AlignMiddleRight 

Align to the middle right.

AlignBottomLeft 

Align to the bottom left.

AlignBottomCenter 

Align to the bottom center.

AlignBottomRight 

Align to the bottom right.

◆ Barcode

Type of the bar code.

Note
(1) with check char (last char of text)
(2) text is 8 chars: '0' + 6 data digits + check char
(3) with check char (not part of text)
(4) 43 chars: 0...9 A...Z - . SPACE $ / + %
(5) 128 chars: ASCII 0...127
Enumerator
BarcodeEAN13 

EAN, 13 digits (1)

BarcodeEAN8 

EAN, 8 digits (1)

BarcodeUPCA 

UPC-A, 12 digits (1)

BarcodeUPCE0 

UPC-E Code 0, 6 digits (2)

BarcodeUPCE1 

UPC-E Code 1, 6 digits (2)

BarcodeSUPPL2 

EAN/UPC 2-digit supplement.

BarcodeSUPPL5 

EAN/UPC 5-digit supplement.

Barcode39 

Code 39 no check char (4)

Barcode39C 

Code 39 with check char (3,4)

Barcode39E 

Extended Code 39 no check char (5)

Barcode39EC 

Extended Code 39 with check char (3,5)

Barcode2of5 

Interleaved 2 of 5.

Barcode2of5C 

Interleaved 2 of 5 with check char (1)

Barcode128 

Code 128 (5)

Barcode128S 

Code 128 store and concat with next (5)

Barcode128R 

Code 128 reader function control (5)

BarcodeEAN128 

EAN 128 (5)

BarcodeEAN128S 

EAN 128 store and concat with next (5)

BarcodeRSS14 

RSS-14, RSS-14 truncated.

BarcodeRSS14S 

RSS-14 stacked.

BarcodeRSS14SO 

RSS-14 stacked omnidirectional.

BarcodeRSSLIM 

GS1 DataBar limited.

◆ Direction

Basic Compass Directions.

Enumerator
DirectionEast 

To east (default)

DirectionSouth 

To south.

DirectionWest 

To west.

DirectionNorth 

To north.

◆ HorizontalAlignment

Horizontal alignment.

Enumerator
AlignLeft 

Align to the left.

AlignCenter 

Align to the center.

AlignRight 

Align to the top right.

◆ PaperOrientation

Paper orientation.

Enumerator
Portrait 

The page's height is greater than its width.

Landscape 

The page's width is greater than its height.

◆ PixmapSizing

Pixmap sizing mode.

Enumerator
SizeFixed 

Size to fixed pixel per inch (ppi), clipping overflow.

SizeFit 

Scale to fit into rectangle keeping aspect, no larger than original size (default).

SizeFill 

Scale pixmap to completely fill the rectangle.

◆ Rotation

Rotation in 90 degree steps.

Enumerator
Rotation0 

No rotation (default)

Rotation90 

90 degrees

Rotation180 

180 degrees

Rotation270 

270 degrees

◆ Status

General purpose return status.

Enumerator
OK 

All worked out.

Error 

Some unspecified error happened.

Timeout 

The operation timed out.

Locked 

The object is already locked.

Notlocked 

The object was not locked for the current actor.

Notfound 

The object was not found.

◆ VerticalAlignment

Vertical alignment.

Enumerator
AlignTop 

Align to the top.

AlignMiddle 

Align to the middle.

AlignBottom 

Align to the bottom.

Function Documentation

◆ canEditInstallSettings()

Boolean bps::canEditInstallSettings ( )

Check if the the local installation settings are editable.

The settings are stored in the file settings.ini in the application data folder selected while installing BPS.

Returns
true = editable, false = not editable.

◆ dateToTimestampString()

String bps::dateToTimestampString ( Date  aDate)

Format date object to a timestamp string.

Parameters
aDateThe date/time value.
Returns
The date/time as string YYYYMMDDHHMMSS

◆ decryptPin()

Number bps::decryptPin ( Number  aUserid,
Number  aPin 
)

Decrypt a user PIN.

PIN's are stored in an encrypted manner within the t_users table.

Parameters
aUseridThe user id.
aPinThe encrypted PIN.
Returns
The decrypted PIN.

◆ directory()

String bps::directory ( String  aName = "")

Get a BPS application directory.

The path is first searched in the environment where aName is prefixed with "BPS_".

When the path was not found in the environment variables, it is searched in the file bps.conf which is in the directory where the executable was started from. The key aName is expected in section [Paths].

If the found path is relative (not starting with a drive or slash/backslash), it is assumed to be relative to the BPS installation directory (one above the exe's). The returned path is made absolute under this premise.

Example 1: Relative path in environment variable

aNameLogs
Environment variable BPS_LOGS=mylogs
BPS installation directoryC:\Program Files\IBK BPS 2.0.0
Returned pathC:/Program Files/IBK BPS 2.0.0/mylogs

Example 2: Relative path in bps.conf

aNameLogs
Environment variable BPS_LOGS=(not found)
bps.conf: [Paths] ... Logs=logs
BPS installation directoryC:\Program Files\IBK BPS 2.0.0
Returned pathC:/Program Files/IBK BPS 2.0.0/logs
Parameters
[in]aNameLogical path name, for example: Logs, Plugins or Scripts. Get the BPS installation directory if aName is empty.
Returns
The absolute path with forward slashes, or empty string if path unknown.

◆ dump()

String bps::dump ( Mixed  aValue,
Number  aMaxDepth = 100 
)

Format any variable (except functions) for debug output.

The formatted text is in ECMAscrip syntax, so basically it could be used as script source.

Parameters
[in]aValueAny object, array or scalar variable to dump.
[in]aMaxDepthMaximum recursion depth. Use 1 to list top level scalars of a object or array only.
Returns
The formatted text.

◆ encryptPin()

Number bps::encryptPin ( Number  aUserid,
Number  aPin 
)

Encrypt a user PIN.

PIN's are stored in an encrypted manner within the t_users table.

Parameters
aUseridThe user id.
aPinThe unencrypted PIN.
Returns
The encrypted PIN.

◆ formatError()

String bps::formatError ( Error  aError)

Format an Error for display.

In case aError is an instance of Error, the message text is returned with the stack traceback information appended in human readable format. If aError if not instance or Error, its string representation is returned.

Parameters
[in]aErrorAn object, possibly an instance of Error.
Returns
The formatted error message.
try {
throw new Error('this failed');
}
catch (err) {
perror( bps.formatError(err) );
}
void perror(...)
Print the expressions (applying toString() if necessary) to the console error output (stderr),...
@ Error
Some unspecified error happened.
Definition: bps.js:26

◆ formatNiceNumber()

String bps::formatNiceNumber ( Number  aValue)

Format a large integer number for better human readability, for example 1234567 becomes 1'234'567.

Parameters
aValueThe value to process
Returns
The formatted text.

◆ isElevated()

Boolean bps::isElevated ( )

Check if the current process is running with elevated or limited privilege.

Elevated: Either UAC is enabled and the process was elevated by the administrator, or UAC is disabled and the process was started by a user who is a member of the Administrators group.

Not elevated (limited): Either UAC is enabled and the process was started normally without the elevation, or UAC is disabled and the process was started by a standard user.

Returns
true = elevated, false = limited.

◆ lerror()

void bps::lerror (   ...)

Print to log error output.

Print the expressions (applying toString() if necessary) to the console error output (stderr), followed by a newline. Lines will be indented by logLevel * 2 spaces. In case a logFile was opened, the output is also appended to the logFile.

Multiple expressions will be separated by a blank.

◆ lfile()

void bps::lfile (   ...)

Print lo log file only.

Append the expressions (applying toString() if necessary) to the logFile, followed by a newline. Lines will be indented by logLevel * 2 spaces.

Multiple expressions will be separated by a blank.

◆ log()

void bps::log (   ...)

Print to log output.

Print the argument expressions (applying toString() if necessary) to the console standard output (stdout), followed by a newline. Lines will be indented by logLevel * 2 spaces. In case a logFile was opened, the output is also appended to the logFile.

Multiple expressions will be separated by a blank.

◆ logClose()

void bps::logClose ( )

Close the log file.

Writes the ending date/time and the elapsed time into the log file in case one is opened.

◆ logOpen()

void bps::logOpen ( )

Opens the log file and writes the script name and starting date/time into it.

The log directory is determined as:

  • If a bps.conf file is present in the applicationDirPath, the variables Prefix and Logs in the Paths section of the the file are recognized. The Prefix is only used if Logs is not an absolute path.

    In this example the log files will be stored in D:/Projekte/BPS2/logs:
    [Paths]
    Prefix = D:/Projekte/BPS2
    Logs = logs

    In this example the log files will be stored in E:/bps/logfiles, the Prefix is ignored because Logs is an absolute path:
    [Paths]
    Prefix = D:/Projekte/BPS2
    Logs = E:/bps/logfiles
  • In case no bps.conf file is present, or the Prefix or Logs settings are not found in the Paths section, Prefix will default to applicationDirPath and Logs will default to "logs".
Note
The log directory must allready exist before calling logOpen, otherwise no log file will be opened.

The filename of the log will be the same as the script name, but with the extension .log instead of .js

◆ msleep()

void bps::msleep ( Number  aMilliseconds)

Sleep for the time specified in milliseconds.

No event processing will be done so the application will be unresponsive. Use mwait() in case to for non-blocking sleeping.

Parameters
aMillisecondsNumber of milliseconds to sleep.

◆ mwait()

void bps::mwait ( Number  aMilliseconds)

Wait for a number of milliseconds.

While waiting, events will be processed and the application will stay responsive to user interface events and network communication. If aMilliseconds is <= 0, the function returns immediately after processing any pending events.

Parameters
aMillisecondsThe time to wait.

◆ personalFolder()

String bps::personalFolder ( )

Get the personal data folder.

Under windows this is the path of "My documents" or "Eigene Dateien". Under other operating systems this function is equivalent to QDir::homePath().

Returns
The personal data folder.

◆ printData()

Boolean bps::printData ( String  aPrinterName,
String  aDocName,
String  aData,
String  aCodec = "" 
)

Send data to a printer.

Parameters
aPrinterNameThe name of the printer. May also be a network printer name such as "\\\\server\\printer".
aDocNameThe document name as shown in the spooler. The document name will be prefixed with the node name, for example when the document name is "My Report", the spooler might show "SPEEDY.Console.kochp: My Report".
aDataThe data to send.
aCodecThe codec used for text encoding. Default = Latin1. See https://doc.qt.io/qt-5/qtextcodec.html for examle "IBM 850".
Returns
True if successfully sent

◆ printFile()

Boolean bps::printFile ( String  aPrinterName,
String  aDocName,
String  aFileName 
)

Send a file to a printer.

The printer may be any local or network printer known to the workstation.

Parameters
aPrinterNameThe name of the printer. May also be a network printer name such as "\\\\server\\printer".
aDocNameThe document name as shown in the spooler. The document name will be prefixed with the node name, for example when the document name is "My Report", the spooler might show "SPEEDY.Console.kochp: My Report".
aFileNameThe name of the file to send.
Returns
True if successfully sent

◆ round()

Number bps::round ( Number  aValue,
Number  aDigits = 3 
)

Round off as per standard commercial practice.

Parameters
[in]aValueThe value to round off.
[in]aDigitsNumber of digits behind the decimal point.
Returns
The rounded off value.

◆ sleep()

void bps::sleep ( Number  aSeconds)

Sleep for the time specified in seconds.

No event processing will be done so the application will be unresponsive. Use wait() in case to for non-blocking sleeping.

Parameters
aSecondsNumber of seconds to sleep.

◆ sprintf()

String bps::sprintf ( String  aFormat,
Mixed  aArgs 
)

A string formatting function.

The placeholders in the format string are marked by "%" and are followed by one or more of these elements, in this order:

  1. An optional "+" sign that forces to preceed the result with a plus or minus sign on numeric values. By default, only the "-" sign is used on negative numbers.

  2. An optional padding specifier that says what character to use for padding (if specified). Possible values are 0 or any other character precedeed by a single quote '. The default is to pad with spaces.

  3. An optional "-" sign, that causes sprintf to left-align the result of this placeholder. The default is to right-align the result.

  4. An optional number, that says how many characters the result should have. If the value to be returned is shorter than this number, the result will be padded.

  5. An optional precision modifier, consisting of a "." (dot) followed by a number, that says how many digits should be displayed for floating point numbers. When used on a string, it causes the result to be truncated.

  6. A type specifier that can be any of:

    % - print a literal "%" character
    b - print an integer as a binary number
    c - print an integer as the character with that ASCII value
    d - print an integer as a signed decimal number
    e - print a float as scientific notation
    u - print an integer as an unsigned decimal number
    f - print a float as is
    o - print an integer as an octal number
    s - print a string as is
    x - print an integer as a hexadecimal number (lower-case)
    X - print an integer as a hexadecimal number (upper-case)

You can also swap the arguments. That is, the order of the placeholders doesn't have to match the order of the arguments. You can do that by simply indicating in the format string which arguments the placeholders refer to:

sprintf("The quick %4$s %3$s jumps over the lazy %1$s %2$s",
'Tail', 'Dogs', 'Fox', 'brown');
String sprintf(String aFormat, Mixed aArgs)
A string formatting function.

You can repeat the placeholders without having to increase the number of arguments.

Parameters
aFormatThe string that must be left padded.
aArgsAn arbitrary number of arguments.The
Returns
The formatted string.

◆ timestampStringToDate()

Date bps::timestampStringToDate ( String  aTimestampString)

Parses a date/time encoded in text with format YYYYMMDDHHMMSS.

Parameters
aTimestampStringThe timestamp string to process.
Returns
The parsed Date object, or null in case the text is invalid.

◆ usleep()

void bps::usleep ( Number  aMicroseconds)

Sleep for the time specified in microseconds.

Parameters
aMicrosecondsNumber of microseconds to sleep.

◆ wait()

void bps::wait ( Number  aSeconds)

Wait for a number of seconds.

While waiting, events will be processed and the application will stay responsive to user interface events and network communication. If aSeconds is <= 0, the function returns immediately after processing any pending events.

Parameters
aSecondsThe time to wait.

Variable Documentation

◆ logFile

String bps::logFile

The log file name used by bps.log(), bps.lerror() and bps.lfile().

When empty (default), bps.log() and bps.lerror() will only create console ouput, while bps.lfile() will throw an bps.Error.

◆ logLevel

Number bps::logLevel

The level to indent the log outputs by.

Log outputs created by bps.log(), bps.lerror() and bps.lfile() will be indented by bps.logLevel * 2 spaces.