Edit

Function and Handler Summary

The following is a brief summary of the available functions and handlers. The functions (which are grouped into broad types) can be used in MoneyWorks expressions in data entry, reports and forms (unless otherwise stated). Some functions (such as GetFieldValue() or GoToNextField()) and all handlers are specific to MWScript (see Scripting Functions). A brief outline of scripts is given at scripts.

Numerics

Abs: Absolute value of a number

Average: Average of numbers (for ExpandList, mainly)

Int: Discard fractional part of a number (truncate)

Log10: Base 10 logarithm of a number

Log2: Base 2 logarithm of a number

LogN: Base e logarithm of a number

Max: Select the largest of the given numbers

Min: Select the lowest of the given numbers

Mod: Remainder after division

Pow: Exponentiation

Random: Get a random number

Round: Round a number to given decimal places

Sign: Get the sign of a number

Sqrt: Square root of a number

Sum: Add the given numbers (for ExpandList, mainly)

Text and strings

ByteLength: Get the byte length of the utf-8 representation of a string

CSV: format the values as CSV

Concat: Concatenate several strings

ConcatAllWith: Concatenate several strings with a delimiter string

ConcatWith: Concatenate several strings with a delimiter string, omitting blank input

Dice: Get a subcomponent of a delimited tabular string

Head: Get some elements from the start of a delimited string

InsertVars: Insert values of variables or expressions in a string

Left: Get characters from the start of a string

Length: Length in characters of a string

Lower: Lowercase a string

Mid: Get characters from the middle of a string

Pad: Pad a string to a desired length

ParseCSV: Convert a line of CSV (Comma-Separated-Value) text to tab-delimited

PositionInText: Find the character offset of a substring within a string

Proper: Uppercase initial letters of words in a string

Regex_GetMatches: Find tokens using a regular expression

Regex_Match: Test whether a string matches a regular expression

Regex_Replace: Replace text in a string using a regular expression

Regex_Search: Find the first match of a regular expression in a string

Regex_SearchStr: Find the first match of a regular expression in a string and return the matching string

RemoveLeading: Remove characters from the start of a string

RemoveTrailing: Remove characters from the end of a string

Replace: Replace matching text in a string with new text

Right: Get characters from the end of a string

Slice: Get a component of a delimited string

Sort: Sort a delimited tabular string

Tail: Get some elements from the end of a delimited string

Transpose: Transpose a tabular delimited string

Trim: Remove whitespace from beginning and end of a string

URLEncode: Convert url unsafe characters in a string to "%xx”

Upper: Uppercase a string

Data Conversion

Base64Decode: String from a base64 encoding

Base64Encode: Base64 of a string

CalcDueDate: Calculate a due date for given terms

Char: A one character string from a unicode code point

Checksum: Cryptographic checksum of a string

Choose: Choose between several values based on an index

ClearFlag: Bitwise bit clear

Code128: Code128 barcode byte representation of a string

Count: Count parameters (mainly for ExpandList)

CountElements: Get the size of an associative array

CountLines: Count delimited lines/elements in a string

CreateArray: Create an empty associative array

CurrencyFormat: Format a number as a currency value with ISO code

Date: Convert d,m,y to a date

DateToPeriod: Convert a date to a period

DateToText: Format a date as a string

Day: Get the Day of month of a date

DayOfWeek: Get The weekday of a date

DeleteElement: Remove a key from an associative array

DollarsToEnglish: Convert a currency amount to English or French

ElementExists: Check if a key exists in an associative array

HMAC: Create a keyed-hash message authentication code

HexDecode: String from hex representation of the utf-8 encoding

HexEncode: Hex representation of the utf-8 encoding of a string

If: Choose between two values based on a Boolean

Match: Find a value's parameter number in a parameter list

Month: Get the month of a date

NumToEnglish: Convert a number to English or French words

NumToPeriod: Convert a linear period offset to a period

NumToText: Format a number as a string

ParamsFromArray: Expand array values to a variable parameter list

PeriodOffset: Difference between two periods

PeriodToDate: Get the end date of a period

PeriodToNum: Convert a period to a linear offset

Quarter: Create a lexical label for breaking down data (e.g. "Q1"..."Q4")

SetFlag: Binary OR

TestFlags: Binary AND

TextToDate: Parse a string to a date

TextToNum: Parse a string to a number

TypeOf: Get the type enumeration of a value or variable

Unicode: Get the unicode codepoint for a character

Val: Evaluate a string as an expression

WeekOfYear: Convert a date to a week number

Year: Year of a date

Special Form Designer Functions

ExpandDetail: Expand form search result values to a parameter list

ExpandList: Expand form list values to a parameter list

SubTotal: Subtotal a form list column

Environmental

AddStatementTransaction: Add a transaction to the bank statement import

AgeByPeriod: Calculate invoice ageing

Allowed: Test a named privilege for the current user

Analyse: Run an Analysis of transaction details or job sheets

Authenticate: Test a supplied username + password

AvailableStockForBatch: Get effective SOH for a batch

CancelTransaction: Cancel a transaction

ChangePrimaryKeyCode: Change a code programmatically

CloseDocument: Close the document or connection

CloseWindow: Close a window

CopyUserSettings: Copy settings from one user to another

CurrencyConvert: Convert amount between currencies

CurrentPeriod: Get the current period number

DoForm: Output a custom form to PDF

DoReport: Output a report to text, html, or PDF

Export: Export records as text/xml

ExportImage: Export an image

External: Execute an installed external function

FieldLabel: Get the name of a custom field

Find: Get formatted record data matching a search as a string

FindRecordsInListWindow: Perform a search in a list window

FirstUnlockedPeriod: Get the oldest period that is not locked

GetAllContactEmailsForRole: Get a list of email addresses for a Name

GetAppPreference: Get a named preference value

GetBalance: Get a balance from an account

GetDatabaseFieldSize: Get table field sizes from the database schema

GetDatabaseFields: Get table field names from the database schema as a delimited string

GetDatabaseFiles: Get the MoneyWorks database table names

GetLastErrorMessage: Get the last import error message string

GetMovement: Get the movement for an account

GetMutex: Try to obtain a named mutex

GetNextReference: Allocate a reference number for a transaction type (or job code).

GetOffBalance: Get the balance form an off ledger

GetPersistent: Load a record as an associative array from one of the user tables

GetPlugins: Get a list of reports

GetScriptText: Get the text of a script

GetTaggedValue: Extract a value from a tagged value field

GetTaxRate: Get a tax rate

HavePicture: Test for existence of an image file related to a record

Import: Import data from an xml string

ImportImage: Import an image from a file

Lookup: Lookup a field value for a primary key

Mail: Send an email with an attachment

MakeGUID: Make a globally unique identifier string

OpenDocument: Open a document or connection (use from external script)

PeriodName: Get the Name of a period

PostTransactions: Post a selection of transactions

ProductSOHForLocation: Gets the SOH for a product held at a specified location

ReleaseMutex: Release a mutex

ReplaceField: Replace a field in records matching a search

SetBudget: Set a budget value

SetExchangeRate: Create and post an exchange rate journal

SetPersistent: Create or update a user table record using data in an associative array

SetProgressMessage: Suggest a progress message

SetStocktakeForLocation: Update the stocktake count for a product]

SetTaggedValue: Encode data for a TaggedText field (for custom data storage)

SuggestNameCode: Suggest a Name Code given a company name

SumDetail: Add up a field for details matching a search

SumSelection: Add up a field for records matching a search

SyncTransactionImage: Set the image flag for a transaction

Time: The current Datetime

TimeAdd: Add seconds to a DateTime

TimeDiff: The difference, in seconds, between two DateTimes

Timestamp: A timestamp string

Today: Today's date

TransferFunds: Create a funds transfer payment between two bank accounts

TryPutBackReference: Try to return an unused reference number (allocated by GetNextReference) to the reference number allocator.

UpdateOrderLines: Change ship quantities in an existing order

WaitMilliseconds: pause script execution

Record Selection

CreateSelection: Create a selection of records

IntersectSelection: Intersect a selection with the result of another search

RecordsSelected: Count records in a selection or resulting from a (meta) search

UnionSelection: Add the result of another search to a selection

Table Handling

CreateTable: Create an empty accumulator table

TableAccumulate: Accumulate numeric column data for a key

TableAccumulateColumn: Accumulate data in one column for a key

TableFind: Look up a key in the table

TableGet: Extract data for a key or index found with TableFind

User interface

AddListLine: Add a row to an editable list

AddSafePath: UI to add a safe path to the preferences

Alert: Display an alert with up to 3 buttons

AppendColumnToStdEditList: Customise a standard edit list

AppendPopupItems: Build a popup menu

Ask: Very simple dialog box with controls

AutoFillAcctDeptField: Apply auto-complete to a departmental account code edit field

AutoFillField: Apply auto-complete to a code edit field

CheckCodeField: Validate a code edit field

ChooseFromList: Very simple list dialog box

Clicks: Get the current click count

CreateListWindow: Instantiate a modeless custom database table list window

CreateWindow: Instantiate a modeless custom window

DeleteListLine: Delete a row from an editable list

DeletePopupItems: Remove items from a popup menu

DisplaySelection: Display standard list window for a given selection of records

DisplayStickyNote: Open sticky notes for a record

ExchangeListRows: Swap rows in an editable list

GetActiveListColumn: Get the column number of an edit list that has keyboard focus

GetActiveListRow: Get the row number of an edit list that has keyboard focus

GetClipboardText: Get the text on the clipboard

GetDialogHandle: Get a window reference from a list reference

GetFieldCount: Get the number of controls in a window (standard or custom)

GetFieldName: Get the symbolic identifier string for a standard or custom field or control

GetFieldNumber: Get an index from a symbolic field/control name

GetFieldValue: Get the value/contents of a field or control

GetListContents: Get a tab-delimited string with the contents of a simple list

GetListField: Get the text of an editable list field

GetListHandle: Get list handle from window handle and list ident

GetListLineCount: Get number of rows in a list

GetListName: Selected tab name for Transaction entry details list

GetRecordForListRow: Get list row record as array

GetUIField: Get value from a standard UI field

GetWindowByID: Gets a handle to the first window instance that has the given identifer

GetWindowID: Get the ident of a window from a window handle

GetWindowName: Get the title of a window

GetWindowProperty: Retrieve data previously stored for a windowHandle

GotoField: Set keyboard focus on a field

GotoNextField: Advance keyboard focus

InsertEditListObject: Initialise editable list object in a window

InsertListObject: Initialise selectable list object in a window

InstallMenuCommand: Install a command at the bottom of the Command menu

InstallToolbarIcon: Install a toolbar icon

LoadHTMLInWebView: Load HTML into a custom web view control

LoadPicture: Load a picture into a picture object in a custom window

LoadURLInWebView: Load a URL into a custom web view control

MergeOrderLines: Merge order lines (opposite of SplitOrderLines)

ModalJobsheetEntryWindow: Run a modal Jobsheet entry modify/create window

ModalListWindow: Instantiate a modal custom database table list window

ModalTransactionWindow: Run a modal transaction modify/create window

ModalWindow: Instantiate a modal custom window

Navigator: Execute a navigator click and/or post a coach tip window

NotifyChanged: Update any list windows containing records from the named database tables

PutClipboardText: Copy text to the clipboard

PutRecordForListRow: Put mutable fields from array to list row record

ReadCurrentRecordForWindow: Load a record in custom UI, or tagged fields in standard UI

SavePicture: Create an image file with the contents of a picture control

Say: Speak some text

SelectWindow: Bring a window to the front

SetFieldEnabling: Enable or disable a custom control

SetFieldValue: Set the value of a field, checkbox, popup, etc

SetFieldVisibility: Show or hide a custom control

SetListContents: Populate a simple list with data from tab-delimited text

SetListField: Set the text of an editable list field

SetListSelect: Highlight a row in a list

SetOptionsForEditList: Set options for the list

SetReportColumnWidth: Tweak a report column

SetSidebarColour: Set a custom sidebar colour for a window

SetWindowProperty: Store data related to a window

SortListByColumn: Sort an editable list by a column

SplitOrderLine: Duplicate a line item on an order, splitting the order qty (for serial entry)

ValidateFieldWithValidationString: Programmatically apply a custom validation expression to a field

WebViewControl: Set option(s) on a web view control (links load externally or not)

WriteCurrentRecordForWindow: Save a record in custom UI, or save tagged fields in standard UI

File Handling

CreateFolder: Create a new folder

File_Close: File functions for creating/reading/writing text files

File_GetLength: File length in bytes

File_GetMark: Get current read/write position

File_Move: Rename/move a file

File_Open: Open a file

File_Path: Get the full path of an open file

File_Read: Read text from current position

File_ReadLine: Read to end of line from current position

File_SetMark: Set Current read/write position

File_Write: Write text at current position

WriteToTempFile: Create a temp file containing the string

Debugging and performance

GetProfile: Get the execution timing profile for the current script

SysLog: Write message to MoneyWorks_Gold.log

_NTDump: Get a textual dump of identifiers and values from the MoneyWorks nametable

JSON parsing

JSON_AsXML: Convert JSON to XML

JSON_Free: Free a parsed JSON structure

JSON_Get: Extract object from parsed JSON

JSON_Parse: Parse JSON text

XML parsing

AddXMLElement: Write an element to an XML document handle

BeginXMLElement: Write an opening tag to an XML document handle

CreateXMLDoc: Create an XML document handle

EndXMLElement: Write a closing tag to an XML document

FinaliseXMLDoc: Get the finished XML as a string

XMLFree: Free an XML document

XMLParseFile: Parse an XML file to an XML document

XMLParseString: Parse an XML string to an XML document

XML_Free: Release an Expat parser

XML_Parse: Parse an XML string using an Expat parser

XML_ParserCreate: Create an Expat parser for parsing XML

XML_SetCharacterDataHandler: Set a character data Handler (callback) for an Expat parser

XML_SetElementHandler: Set an element Handler (callback) for an Expat parser

XPathEval: Extract a node or value from an XML document using XPath notation.

Networking

Curl_Close: Finish with a CURL session

Curl_Exec: Execute a CURL session

Curl_GetInfo: Get information about a CURL transfer

Curl_Init: Start a CURL session

Curl_SetOpt: Add options to a CURL session

Curl_StrError: Get an error message from a CURL object

Script Handlers

After: The window is closing or the record is advancing and the window content has changed

AllowDeleteRecords: Control whether a user can delete a selection

AllowPostTransactions: Control whether a user can post a selection

Before: The window has just opened or the record has just advanced or the view in a list has just changed

Cancel: The window is being cancelled

Close: The window is closing (with either OK or Cancel)

Dawdle: Do idle processing in a custom window

EnterCell: A cell in an editable list has just gained focus

EnterField: A field has just gained focus

ExitedCell: A cell in an editable list has just lost focus

ExitedField: A field has just lost focus

ItemHit: A field has had a keydown or a control value has changed

Load: Script just loaded

PostedTransactions: Post-process transactions that were just posted

SetupReport: Use to tweak a report layout.

TweakColumnList: Use to add custom columns to a standard editable list.

Unload: Script is about to unload

UserLoggedIn: User just connected

UserLoggingOut: User is about to disconnect

Validate: Control whether the window can be OK'd

ValidateCell: Control whether the content of a cell is acceptable and the cell can be exited

ValidateField: Control whether the content of a field is acceptable and the field can be exited

Name record methods

GetContactForRole: Get contacts from a Name record

Product record methods

SOHForLocation: Get Stock on Hand for a product at a location

StocktakeNewQtyForLocation: Get the current stocktake quantity for a product for a given location

StocktakeStartQtyForLocation: Get the stocktake starting snapshot quantity for a product for a given location