HareScript core
Core functions in HareScript. Builtins are available without using any LOADLIBS
Builtin functions
- MACRO Abort(VARIANT errordata, STRING format)
Signal a fatal error
- VARIANT FUNCTION Abs(VARIANT value)
Returns the absolute value of a number
- VARIANT FUNCTION Any(VARIANT data)
Get 'a' value from a group
- STRING FUNCTION AnyToString(VARIANT data, STRING format)
Convert any type to a string for debugging
- VARIANT FUNCTION ArraySlice(VARIANT arr, INTEGER start, INTEGER64 numelements)
Returns part of a array.
- OBJECTTYPE AsyncControl
Object used to configure async function/generator options
- OBJECT FUNCTION AsyncReadFrom(INTEGER inputid, INTEGER maxnumbytes)
Asynchronously read a string from any input device
- OBJECT FUNCTION AsyncReadLineFrom(INTEGER inputid, INTEGER maxnumbytes, BOOLEAN striplf)
Asynchronously read a line from any input device
- ASYNC FUNCTION AsyncSendBlobTo(INTEGER outputid, BLOB data)
Write a blob to any output device
- VARIANT FUNCTION Avg(VARIANT data)
Aggregate function which returns the average of values
- TABLE FUNCTION BindSchemaToTable(SCHEMA bind_schema, STRING tablename)
Link a schema variable to an external table
- SCHEMA FUNCTION BindTransactionToSchema(INTEGER transaction, STRING schemaname)
Link a schema variable to a transaction
- TABLE FUNCTION BindTransactionToTable(INTEGER transaction, STRING tablename)
Link a table variable to an external table
- STRING FUNCTION ByteToString(INTEGER bytecode)
Convert a byte code to a string
- VARIANT FUNCTION CallAnyPtrVA(FUNCTION PTR v, VARIANT ARRAY args)
Calls any function pointer with an argument list, returning the return value. If a macro is invoked, returns TRUE
- VARIANT FUNCTION CallFunctionPtrVA(FUNCTION PTR fptr, VARIANT ARRAY arguments)
Calls a function pointer with an argument list, returning the return value. Aborts when the function pointer points to a macro.
- MACRO CallMacroPtrVA(FUNCTION PTR fptr, VARIANT ARRAY arguments)
Calls a function pointer with an argument list, without expecting a return value
- BOOLEAN FUNCTION CanCastTypeTo(INTEGER fromtype, INTEGER totype)
Returns whether a type is implicitly casted to another type if a value of that other type is required
- VARIANT FUNCTION CastTo(VARIANT invalue, INTEGER desttype)
Cast a value to a specific type
- RECORD FUNCTION CellDelete(RECORD rec, STRING cellname)
Remove a cell from a record
- BOOLEAN FUNCTION CellExists(RECORD rec, STRING cellname)
Check if a cell exists in a record
- RECORD FUNCTION CellInsert(RECORD rec, STRING cellname, VARIANT value)
Insert a cell in a record
- RECORD FUNCTION CellUpdate(RECORD rec, STRING cellname, VARIANT newvalue)
Update a cell in a record
- MACRO CollectGarbage()
Collects and removes all unreferenced objects
- INTEGER FUNCTION Count(VARIANT data)
Aggregate function which returns the number of records
- MACRO Debugger()
Pauses the debugger if attached, or can be used for rule-based connect
- MACRO DebuggerKeepalive(VARIANT ARRAY keepalives)
Function to ensure the parameters passed are kept alive until the call to this function to make sure the debugger can inspect them
- STRING FUNCTION DecodeBase16(STRING text)
Decodes a hexadecimal string.
- STRING FUNCTION DecodeBase32(STRING value)
Decodes an RFC 4648 base-32 encoded string.
- STRING FUNCTION DecodeBase32Hex(STRING value)
Decodes an RFC 4648 base-32 hex encoded string.
- STRING FUNCTION DecodeBase64(STRING text)
Decodes a base-64 encoded string.
- STRING FUNCTION DecodeCharSet(STRING text, STRING charset)
Convert a string from a specific character set to UNICODE(UTF-8)
- STRING FUNCTION DecodeHareScript(STRING text)
Converts special characters as used in HareScript.
- VARIANT FUNCTION DecodeHSON(STRING indata)
Decodes a HSON string
- VARIANT FUNCTION DecodeHSONBlob(BLOB indata)
Decodes a HSON blob
- STRING FUNCTION DecodeHTML(STRING text)
Converts HTML back to special characters.
- STRING FUNCTION DecodeJava(STRING text)
Converts special characters as used in javascripts.
- VARIANT FUNCTION DecodeJSON(STRING indata, RECORD translations, RECORD options)
Decodes a JSON string
- VARIANT FUNCTION DecodeJSONBlob(BLOB indata, RECORD translations, RECORD options)
Decodes a JSON blob
- RECORD FUNCTION DecodePacket(STRING format, STRING data)
Decode a binary packet
- STRING FUNCTION DecodeQP(STRING text)
Decodes a quoted-printable encoded string.
- STRING FUNCTION DecodeUFS(STRING text)
Decode a string encoding using url and filename safe base-64 encoding
- STRING FUNCTION DecodeURL(STRING text)
Converts hexadecimal encodings to special characters.
- STRING FUNCTION DecodeValue(STRING text)
Converts HTML entities back to their characters
- STRING FUNCTION Detokenize(STRING ARRAY elements, STRING separator)
Concatenates an array of strings, while adding a seperator between all pairs
- MACRO DumpValue(VARIANT data, VARIANT options)
Print any type to an output for debugging
- STRING FUNCTION EncodeAttributeValue(STRING text)
Encode an attributenode
- STRING FUNCTION EncodeBase16(STRING text)
Encodes a string into a hexadecimal string.
- STRING FUNCTION EncodeBase32(STRING value, BOOLEAN dontpad)
Encodes a string into an RFC 4648 base-32 encoded string
- STRING FUNCTION EncodeBase32Hex(STRING value, BOOLEAN dontpad)
Encodes a string into an RFC 4648 base-32 hex encoded string
- STRING FUNCTION EncodeBase64(STRING text)
Encodes a string into a base-64 encoded string
- STRING FUNCTION EncodeCharSet(STRING text, STRING charset)
Convert a string to a specific character set
- STRING FUNCTION EncodeHareScript(STRING text)
Escapes special characters for use in HareScript strings.
- STRING FUNCTION EncodeHSON(VARIANT arg)
Encode data as a HSON string
- BLOB FUNCTION EncodeHSONBlob(VARIANT arg)
Encode data as a HSON blob
- STRING FUNCTION EncodeHTML(STRING text)
Converts special characters to HTML entities.
- STRING FUNCTION EncodeJava(STRING text)
Escapes special characters for use in java strings.
- STRING FUNCTION EncodeJSON(VARIANT arg, RECORD translations, RECORD options)
Encode data as a JSON string
- BLOB FUNCTION EncodeJSONBlob(VARIANT arg, RECORD translations, RECORD options)
Encode data as a JSON blob
- STRING FUNCTION EncodePacket(STRING format, RECORD data)
Encode a binary packet
- STRING FUNCTION EncodeQP(STRING text)
Encodes a string into a quoted-printable encoded string
- STRING FUNCTION EncodeTextNode(STRING text)
Encode a textnode
- STRING FUNCTION EncodeUFS(STRING text)
Encodes a string into a url and filename safe base-64 encoding
- STRING FUNCTION EncodeURL(STRING text)
Converts special characters to hexadecimal encodings.
- STRING FUNCTION EncodeValue(STRING text)
Converts special characters to HTML entities.
- VARIANT FUNCTION EnforceStructure(VARIANT expected, VARIANT received, RECORD options)
Enforce a structure on a data
- OBJECTTYPE Exception
Base object type for exceptions. It is recommended this type is used to derive exceptions from; it provides handy stuff like an exception trace and error traces of uncaught exceptions.
- STRING FUNCTION ExplainFunctionPtrSignature(FUNCTION PTR funcptr)
Generate a string which describes the given function ptr
- STRING FUNCTION ExplainFunctionSignature(INTEGER returntypeid, INTEGER ARRAY parametertypeids, STRING name)
Generate a string which describes the given return and parameter types
- MACRO ExtendObject(OBJECT base, STRING objname, VARIANT ARRAY constructorarguments)
Extends an existing object with a dynamically specified object
- OBJECT FUNCTION GeneratorSpawn(OBJECT generator)
This function asynchronously drives a generator function that yields promises. It returns a promise for the final return value.
- VARIANT FUNCTION GeneratorSpawnTrySync(OBJECT generator)
This function asynchronously drives a generator function that yields promises. If the async generator doesn't yield or return a promise, the value is returned directly. Otherwise, a promise for the return value is returned.
- VARIANT FUNCTION GetArrayTypeDefaultElement(INTEGER type)
Returns the default value for elements of a array based on its type
- OBJECT FUNCTION GetAsyncControl()
Function to set async function/generator options. Use
AWAIT GetAsyncControl()
to get the object - RECORD ARRAY FUNCTION GetAsyncStackTrace()
Returns the call stack for asynchronous functions
- RECORD FUNCTION GetAuthenticationRecord()
Get the current value of the authentication record
- STRING FUNCTION GetBestCharacterSet(STRING text)
Get the smallest character set in which a string would fit
- RECORD FUNCTION GetBindingFromSchema(SCHEMA bound_schema)
Get the transaction id and table name that have been bound to a schema variable
- RECORD FUNCTION GetBindingFromTable(TABLE bound_table)
Get the transaction id and table name that have been bound to a table variable
- INTEGER FUNCTION GetByteValue(STRING str)
Get the byte value of a character
- VARIANT FUNCTION GetCell(RECORD rec, STRING cellname)
Retrieve a cell from a record by name
- STRING FUNCTION GetExternalSessionData()
Get the current external session data
- INTEGER FUNCTION GetHarescriptTypeIdByName(STRING name)
Returns the type number from a type name
- VARIANT FUNCTION GetMember(OBJECT obj, STRING membername)
Retrieve a member from an object by name
- STRING FUNCTION GetMemberType(OBJECT obj, STRING membername)
Returns the type of a member of an object
- FUNCTION PTR FUNCTION GetObjectMethodPtr(OBJECT obj, STRING membername)
Creates a function pointer to an object method
- INTEGER FUNCTION GetSpotHitCount()
Return the number of times this functions was called from, from the caller's location
- RECORD ARRAY FUNCTION GetStackTrace()
Get the current stack trace
- VARIANT FUNCTION GetStoredScriptProperty(STRING propertyname)
Returns the value of a stored script property for the top-level script
- VARIANT FUNCTION GetTypeDefaultArray(INTEGER type)
Returns an empty array of a specific type of elements
- VARIANT FUNCTION GetTypeDefaultValue(INTEGER type)
Returns the default value for a type
- STRING FUNCTION GetTypeName(INTEGER type)
Returns the name of a type
- INTEGER FUNCTION GetUCValue(STRING str)
Get the UNICODE character value of a character
- VARIANT FUNCTION GroupedValues(VARIANT data)
Return grouped values as an array
- OBJECTTYPE HarescriptErrorException
Base object type for harescript errors exceptions. This type is used to describe Harescript errors.
- OBJECTTYPE InvalidOptionException
This error is thrown when an invalid option is passed to ValidateOptions (webhare 4.20+)
- BOOLEAN FUNCTION IsAtEndOfStream(INTEGER filehandle)
Test if we are at the end of a stream (eg a file)
- BOOLEAN FUNCTION IsDebugTagEnabled(STRING tag)
Returns whether a tag is currently enabled in the current debugging configuration
- BOOLEAN FUNCTION IsDefaultValue(VARIANT input)
Checks if the given variable is equal to the default value of its type.
- BOOLEAN FUNCTION IsObjectReferencePublic(OBJECT obj)
Returns whether a object reference is public
- BOOLEAN FUNCTION IsPrintableASCII(STRING text)
Test whether a string consists of only printable ASCII text
- BOOLEAN FUNCTION IsProfilingEnabled()
Returns whether profiling is enabled. If so, jobs and processes need extra care so they can shutdown cleanly (eg using TerminateScript) so they can send they profiles before being closed
- BOOLEAN FUNCTION IsTypeidArray(INTEGER type)
Is the specified type id an array ?
- BOOLEAN FUNCTION IsTypeidComparable(INTEGER type)
Is the specified type id comparable ? (it can be used in inequality comparisons)
- BOOLEAN FUNCTION IsValidUTF8(STRING text, BOOLEAN xmlchar)
Test whether a string is a proper UTF8 string
- BOOLEAN FUNCTION IsValueSet(VARIANT input)
Checks if the given variable is not equal to the default value of its type. Opposite of IsDefaultValue
- OBJECTTYPE JSONArray
JSON array wrapper, contains a list of values
- OBJECTTYPE JSONObject
JSON object wrapper, contains a (key, value) store with case-sensitive keys
- STRING FUNCTION Left(STRING text, INTEGER numbytes)
Returns the left part of a string.
- INTEGER FUNCTION Length(VARIANT obj)
Returns the length of an variable.
- INTEGER64 FUNCTION Length64(VARIANT obj)
Returns the length of an variable as an integer64.
- OBJECTTYPE LibraryVersionConflictException
This error is thrown when a new library is loaded, which depends on another library that was loaded, but has been changed since. Harescript cannot load two different compiled versions of the same library at the same time.
- STRING FUNCTION LimitUTF8Bytes(STRING text, INTEGER numbytes, STRING addiftruncated)
Limit a UTF-8 encoded string to a maximum byte length
- MACRO LogDebug(STRING logsource, VARIANT message, VARIANT ARRAY args)
Log debugging data
- INTEGER FUNCTION MakeAutoNumber(TABLE gettable, STRING columnname)
Get the next autonumber ID for a table
- INTEGER64 FUNCTION MakeAutoNumber64(TABLE gettable, STRING columnname)
Get the next autonumber ID for a table
- INTEGER ARRAY FUNCTION MakeAutoNumbers(TABLE gettable, STRING columnname, INTEGER amount)
Get a list of the next autonumber IDs for a table
- INTEGER64 ARRAY FUNCTION MakeAutoNumbers64(TABLE gettable, STRING columnname, INTEGER amount)
Get a list of the next 64-bit autonumber IDs for a table
- RECORD FUNCTION MakeEmptyRecord()
Create an empty, existing record
- FUNCTION PTR FUNCTION MakeFunctionPtr(STRING functionname)
Dynamically create a function/macro pointer
- RECORD FUNCTION MakeMergedRecord(RECORD rec1, RECORD rec2)
Combines the cells of two records into one record
- OBJECT FUNCTION MakeObject(STRING objname, VARIANT ARRAY constructorarguments)
Creates a new object using a dynamically specified object
- RECORD FUNCTION MakeOverwrittenRecord(RECORD original, RECORD updatedata)
Supplements or replaces the cells in a record
- OBJECT FUNCTION MakePublicObjectReference(OBJECT obj)
Makes a private object reference public again
- RECORD FUNCTION MakeReplacedRecord(RECORD original, RECORD updatedata)
Replaces the cells in a record
- RECORD FUNCTION MakeUpdatedRecord(RECORD original, RECORD updatedata)
Updates the cells in a record with an extra record
- VARIANT FUNCTION Max(VARIANT data)
Aggregate function which returns the highest value.
- OBJECT FUNCTION MemberDelete(OBJECT obj, STRING membername)
Delete a member from an object
- BOOLEAN FUNCTION MemberExists(OBJECT obj, STRING membername)
Check if a specific member exists in a object
- OBJECT FUNCTION MemberInsert(OBJECT obj, STRING membername, BOOLEAN make_private, VARIANT value)
Insert a member in an object
- MACRO MemberUpdate(OBJECT obj, STRING membername, VARIANT value)
Update a member in an object
- VARIANT FUNCTION Min(VARIANT data)
Aggregate function which returns the lowest value.
- STRING FUNCTION NormalizeWhitespace(STRING text)
Remove extra internal whitespace from a string
- BOOLEAN FUNCTION ObjectExists(OBJECT obj)
Checks if an object exists
- RECORD FUNCTION OmitCells(RECORD data, STRING ARRAY cells)
Eliminates a subset of cells of a record
- RECORD FUNCTION PickCells(RECORD data, STRING ARRAY cells)
Returns a subset of cells of a record
- VARIANT FUNCTION PickFirst(VARIANT arr)
Pick the first element of an array
- VARIANT FUNCTION PickLast(VARIANT arr)
Pick the last element of an array
- MACRO Print(STRING data)
Prints a string
- MACRO PrintRecordArrayTo(INTEGER outputdevice, RECORD ARRAY recarr, STRING format)
Show the records of a record array
- MACRO PrintRecordTo(INTEGER outputdevice, RECORD rec, STRING format)
Show the contents of a single record
- BOOLEAN FUNCTION PrintTo(INTEGER outputid, STRING data)
Write a string to any output device
- INTEGER FUNCTION Random(INTEGER min, INTEGER max)
Get a random number
- RECORD FUNCTION ReadDebugSetting(STRING varcontent)
- STRING FUNCTION ReadFrom(INTEGER inputid, INTEGER maxnumbytes)
Read a string from any input device
- STRING FUNCTION ReadLineFrom(INTEGER inputid, INTEGER maxnumbytes, BOOLEAN striplf)
Read a line from any input device
- BOOLEAN FUNCTION RecordExists(RECORD rec)
Checks if a record exists
- INTEGER FUNCTION RedirectOutputTo(INTEGER newoutputid)
Redirect output 0 to a different output
- VARIANT FUNCTION Reflect(VARIANT value, RECORD options)
Try to pause execution while reflecting on the contents of the value
- OBJECT FUNCTION RepackJSONObject(RECORD ARRAY cells)
Construct a JSONObject from a list of name/value pairs
- RECORD FUNCTION RepackRecord(RECORD ARRAY fields)
Repacks a record array into a record
- VARIANT FUNCTION RepeatElement(VARIANT element, INTEGER count)
Return an array with a specific number copies of a value.
- STRING FUNCTION RepeatText(STRING text, INTEGER count)
Repeat the specified text the specified number of times
- STRING FUNCTION Resolve(STRING inpath)
Resolve a path against the current library
- VARIANT FUNCTION ReverseArray(VARIANT input)
Reverse the order of an array
- STRING FUNCTION Right(STRING text, INTEGER numbytes)
Returns the right part of a string.
- VARIANT FUNCTION RoundToMultiple(VARIANT value, VARIANT roundunit, STRING mode)
Round a value to a multiple of a unit value
- VARIANT FUNCTION RunGeneratorUntilReturn(OBJECT generator)
Drives a (non-async) generator until it is exhausted, returns the final returned value
- INTEGER FUNCTION SearchElement(VARIANT list, VARIANT element, INTEGER start)
Returns the index of an element in an ARRAY
- INTEGER FUNCTION SearchLastElement(VARIANT list, VARIANT element, INTEGER start)
Returns the index of an element in an ARRAY, searching from the back
- INTEGER FUNCTION SearchLastSubstring(STRING text, STRING search, INTEGER start)
Find the last occurrence of a substring
- INTEGER FUNCTION SearchSubstring(STRING text, STRING search, INTEGER start)
Find the first occurrence of a substring
- INTEGER FUNCTION SeedRandomizer(INTEGER newseed)
Seed the randomizer
- BOOLEAN FUNCTION SendBlobTo(INTEGER outputid, BLOB data)
Write a blob to any output device
- MACRO SetAuthenticationRecord(RECORD rec)
Set the value of the authentication record
- MACRO SetErrorContextInfo(RECORD contextinfo)
Sets error context info (for the notice log)
- MACRO SetExternalSessionData(STRING newid)
Replaces the current external session data for this VM group (shared with weblets, inherited by jobs)
- VARIANT FUNCTION ShuffleArray(VARIANT indata)
Shuffle the elements in the array into a random order
- MACRO Sleep(INTEGER msecs)
Sleep (do nothing) for a given number of milliseconds
- VARIANT FUNCTION SortArray(VARIANT input)
Sorts an array of comparable values
- STRING FUNCTION Substitute(STRING text, STRING search, STRING replace)
Search and replace parts of a string
- STRING FUNCTION Substring(STRING text, INTEGER start, INTEGER numbytes)
Returns part of a string.
- VARIANT FUNCTION Sum(VARIANT data)
Aggregate function which returns the sum of values
- MACRO TerminateScript()
Terminate immediately without error message
- INTEGER FUNCTION ToInteger(STRING str, INTEGER defaultvalue, INTEGER radix)
Returns an integer representation of a string
- INTEGER64 FUNCTION ToInteger64(STRING str, INTEGER64 defaultvalue, INTEGER radix)
Returns an integer64 representation of a string
- STRING ARRAY FUNCTION Tokenize(STRING text, STRING separator)
Returns an array of strings by splitting a string into sub strings.
- STRING FUNCTION ToLowercase(STRING src)
Converts a string to lowercase.
- RECORD ARRAY FUNCTION ToRecordArray(VARIANT elements, STRING cellname)
Converts a list of values to a record array with in every record a cell with one of the values.
- STRING FUNCTION ToString(INTEGER64 val, INTEGER radix)
Returns a string representation of an integer
- STRING FUNCTION ToUppercase(STRING src)
Converts a string to uppercase.
- STRING FUNCTION TrimWhitespace(STRING src)
Remove whitespace from both ends of a string
- STRING FUNCTION UCLeft(STRING text, INTEGER numchars)
Returns the left part of a UTF-8 string.
- INTEGER FUNCTION UCLength(STRING text)
Returns number of characters in a UNICODE(UTF-8) string
- STRING FUNCTION UCRight(STRING text, INTEGER numchars)
Returns the right part of a UTF-8 string.
- INTEGER FUNCTION UCSearchLastSubstring(STRING text, STRING search, INTEGER start)
Find the last occurrence of a UTF-8 substring
- INTEGER FUNCTION UCSearchSubstring(STRING text, STRING search, INTEGER start)
Find the first occurrence of a UTF-8 substring
- STRING FUNCTION UCSubstring(STRING text, INTEGER start, INTEGER numchars)
Returns part of a UTF-8 string.
- STRING FUNCTION UCToString(INTEGER charactercode)
Convert a character code to a UNICODE(UTF-8) sequence
- STRING FUNCTION UCTruncate(STRING text, INTEGER maxlen)
Truncate a text if it's too long, adding an ellipsis ('…') if truncated. Whitespace between the text and ellipsis will be removed.
- RECORD ARRAY FUNCTION UnpackRecord(RECORD rec)
Unpacks a record into a record array
- BOOLEAN FUNCTION ValidateFunctionPtr(MACRO PTR funcptr, INTEGER returntypeid, INTEGER ARRAY parametertypeids)
Validates a macro/function pointer
- RECORD FUNCTION ValidateOptions(RECORD defaultoptions, RECORD options, RECORD metaoptions)
Validate the options passed to a function
- INTEGER FUNCTION WaitForMultiple(INTEGER ARRAY reads, INTEGER ARRAY writes, INTEGER maxwait)
Waits for reads and/or writes, for a maximum of one hour.
- INTEGER FUNCTION WaitForMultipleUntil(INTEGER ARRAY reads, INTEGER ARRAY writes, DATETIME until)
Waits for reads and/or writes until a specified time
- VARIANT FUNCTION WaitForPromise(OBJECT promise, RECORD options)
Synchronously waits for a promise to resolve
- RECORD ARRAY FUNCTION WaitUntil(RECORD waitfor, DATETIME until)
Wait until a handle is signalled, a promise is fulfilled or a timeout is reached
- RECORD ARRAY FUNCTION WaitUntilMultiple(RECORD waitfor, DATETIME until)
Wait until a handle is signalled, a promise is fulfilled or a timeout is reached. Deprecated, use WaitUntil with multiple := TRUE
- BOOLEAN FUNCTION WeakObjectExists(WEAKOBJECT obj)
Checks if a weak object reference exists
- VARIANT FUNCTION WrapJSONObjects(VARIANT value, RECORD options)
Converts all records and arrays in a value to JSONObject and JSONArray, respectively.
- INTEGER FUNCTION WriteTo(INTEGER outputid, STRING data)
Write (part of) a string to any output device, non-blocking.
Date and time manipulation
- DATETIME FUNCTION AddDaysToDate(INTEGER add_days, DATETIME date)
Adds a number of days to a date, and returns the new timestamp
- DATETIME FUNCTION AddMonthsToDate(INTEGER months, DATETIME date, RECORD options)
Adds a number of months to a date
- DATETIME FUNCTION AddTimeToDate(INTEGER64 add_msecs, DATETIME date)
Adds a time to a date, and returns the new timestamp
- DATETIME FUNCTION AddYearsToDate(INTEGER add_years, DATETIME date, RECORD options)
Adds a number of years to a date, and returns the new timestamp
- STRING FUNCTION FormatDateTime(STRING formatstring, DATETIME date, STRING datetexts)
Returns a string containing a formatted date and time.
- STRING FUNCTION FormatISO8601DateTime(DATETIME whattime, RECORD options)
Formats a datetime in the ISO 8601 format
- STRING FUNCTION FormatTimeStamp(STRING formatstring, INTEGER64 timestamp, STRING datetexts)
Returns a string containing a formatted time.
- DATETIME FUNCTION GetCurrentDateTime()
Returns the timestamp of the current date and time on the server
- RECORD FUNCTION GetDatetimeDifference(DATETIME fromdate, DATETIME todate)
Get difference between two datetimes
- INTEGER FUNCTION GetDayCount(DATETIME date)
Returns the number of days since 01-01-0001.
- STRING FUNCTION GetLanguageDatetimeStrings(STRING langcode)
Get language-specific datetime strings
- INTEGER FUNCTION GetMonthLength(INTEGER month, INTEGER year)
Returns the number of days in a specific month in a specific year
- INTEGER FUNCTION GetMsecondCount(DATETIME endtime)
Returns the number of mseconds passed since the beginning of the day
- INTEGER FUNCTION GetMsecsDifference(DATETIME fromdate, DATETIME todate)
Get difference between two timestamps in milliseconds
- DATETIME FUNCTION GetNextAnniversary(DATETIME creation_date, DATETIME date)
Calculate the date of the next anniversary of something
- DATETIME FUNCTION GetNextCronTime(DATETIME now, STRING cronmask)
Calculate the next timestamp based on a cron-style mask
- DATETIME FUNCTION GetRoundedDatetime(DATETIME dt, INTEGER precision)
Round down a datetime
- INTEGER FUNCTION GetUnixTimestamp(DATETIME whattime)
Get the UNIX timestamp
- INTEGER64 FUNCTION GetUnixTimestampMsecs(DATETIME whattime)
Get the UNIX timestamp in msecs
- RECORD FUNCTION GetYearInfo(INTEGER year)
Return info about a year
- INTEGER FUNCTION GetYearLength(INTEGER year)
Returns the number of days in a specific year
- DATETIME FUNCTION GetYearlyHoliday(INTEGER year, STRING holiday)
Calculate on which day a specific yearly holiday will fall
- BOOLEAN FUNCTION IsAnniversaryAt(DATETIME creation_date, DATETIME date)
Return whether today is the anniversary of something
- DATETIME FUNCTION MakeDate(INTEGER year, INTEGER month, INTEGER day)
Returns a DateTime value from year, month and day values with time 00:00:00
- DATETIME FUNCTION MakeDateFromDayCount(INTEGER daycount)
Creates a DateTime value from a total number of days
- DATETIME FUNCTION MakeDateFromParts(INTEGER daycount, INTEGER msecs)
Creates a DateTime value from a total number of days and msecs
- DATETIME FUNCTION MakeDateFromText(STRING datestring)
Create a datetime from a date string
- DATETIME FUNCTION MakeDateTime(INTEGER year, INTEGER month, INTEGER day, INTEGER hour, INTEGER minute, INTEGER second, INTEGER mseconds)
Returns a DateTime value from year, month, day, hour, minute and second values
- DATETIME FUNCTION MakeDatetimeFromNTTime(INTEGER64 nttime)
Convert a Windows NT timestamp to a datetime
- DATETIME FUNCTION MakeDatetimeFromUnixTimestamp(MONEY dt)
Convert a UNIX timestamp to a datetime
- DATETIME FUNCTION MakeDateTimeFromWeek(INTEGER year, INTEGER week, INTEGER weekday, INTEGER hour, INTEGER minute, INTEGER second, INTEGER mseconds)
Returns a DateTime value for a specified week
- INTEGER FUNCTION MakeDayCount(INTEGER year, INTEGER month, INTEGER day)
Returns the number of days since 01-01-0001.
- INTEGER FUNCTION MakeTime(INTEGER hour, INTEGER minute, INTEGER second, INTEGER mseconds)
Calculate the number of milliseconds from an hour, minute and second value
- CONSTANT DATETIME MAX_DATETIME
The maximum possible DATETIME value. There is no DATETIME value bigger than this value.
- RECORD FUNCTION UnpackDateTime(DATETIME date)
Returns a record from an unpacked timestamp
Mathematic and floating point utility functions
- FLOAT FUNCTION ACos(FLOAT value)
Returns the arccosine of a value.
- FLOAT FUNCTION ASin(FLOAT value)
Returns the arcsine of a value.
- FLOAT FUNCTION ATan(FLOAT value)
Returns the arctangent of a value.
- FLOAT FUNCTION ATan2(FLOAT value1, FLOAT value2)
Returns the arctangent of a value divided by another value.
- FLOAT FUNCTION Ceil(FLOAT value)
Returns the smallest integer FLOAT value larger than a value.
- FLOAT FUNCTION Cos(FLOAT value)
Returns the cosine of a value.
- FLOAT FUNCTION CosH(FLOAT value)
Returns the hyperbolic cosine of a value.
- FLOAT FUNCTION DegreesToRadians(FLOAT degrees)
Converts degrees to radians.
- FLOAT FUNCTION Exp(FLOAT value)
Returns @italic e raised to the power of a value.
- INTEGER FUNCTION FloatToInteger(FLOAT value)
Converts a FLOAT value to an INTEGER value.
- FLOAT FUNCTION Floor(FLOAT value)
Returns the largest integer FLOAT value smaller than a value.
- FLOAT FUNCTION FMod(FLOAT value1, FLOAT value2)
Returns the floating-point remainder of a value divided by another value.
- STRING FUNCTION FormatFloat(FLOAT value, INTEGER decimals)
Formats a FLOAT value and returns the resulting STRING.
- RECORD FUNCTION FrExp(FLOAT value)
Splits a value into a mantissa and an exponent
- FLOAT FUNCTION LdExp(FLOAT mantissa, INTEGER exponent)
Calculates mantissa * pow(2, exponent).
- FLOAT FUNCTION Log(FLOAT value)
Returns the natural logarithm of a value.
- FLOAT FUNCTION Log10(FLOAT value)
Returns the logarithm of a value, using base 10.
- RECORD FUNCTION ModF(FLOAT value)
Splits a value into an integral and a fractional part.
- CONSTANT FLOAT PI
The value of Pi (3.141592653589793238)
- FLOAT FUNCTION Pow(FLOAT value, FLOAT exp)
Calculates a value of a power equation.
- FLOAT FUNCTION RadiansToDegrees(FLOAT radians)
Converts radians to degrees.
- FLOAT FUNCTION Sin(FLOAT value)
Returns the sine of a value.
- FLOAT FUNCTION SinH(FLOAT value)
Returns the hyperbolic sine of a value.
- FLOAT FUNCTION Sqrt(FLOAT value)
Returns the square root of a value.
- FLOAT FUNCTION Tan(FLOAT value)
Returns the tangent of a value.
- FLOAT FUNCTION TanH(FLOAT value)
Returns the hyperbolic tangent of a value.
- FLOAT FUNCTION ToFloat(STRING value, FLOAT defval)
Creates a FLOAT value from a string.
Money type utility functions
- MONEY FUNCTION FloatToMoney(FLOAT value)
Casts a FLOAT value to a MONEY value.
- STRING FUNCTION FormatJSFinmathMoney(MONEY indata)
Format money amounts as our JS finmath library expects it (simply n[.nnnnn] eg 4.25 or 8.5)
- STRING FUNCTION FormatMoney(MONEY value, INTEGER decimals, STRING decimalsep, STRING thousandsep, BOOLEAN round)
Formats a MONEY value and returns the resulting STRING.
- INTEGER FUNCTION MoneyToInteger(MONEY value)
Converts a MONEY value to an INTEGER value.
- MONEY FUNCTION ToMoney(STRING value, MONEY defval)
Creates a MONEY value from a STRING.
Promises and cancellation
- OBJECTTYPE CancellationToken
A cancellation token provides the notification that an operation is cancelled
It is modelled with .NET CancellationTokens as an example.
- OBJECTTYPE CancellationTokenSource
A CancellationTokenSource generates a CancellationToken. Cancellation of that token is done on this class.
- OBJECT FUNCTION CreateDeadlinePromise(DATETIME deadline)
Asynchronous sleep until an absolute time (allows microtasks to run ie to allow promises to resolve)
- RECORD FUNCTION CreateDeferredPromise()
Creates a promise together with functions to manually resolve or reject it
- OBJECT FUNCTION CreatePromise(FUNCTION PTR executor)
Creates a Promise.
- OBJECT FUNCTION CreatePromiseAll(OBJECT ARRAY promises)
The CreatePromiseAll function returns a new promise which is fulfilled with an array of fulfillment values for the passed promises, or rejects with the reason of the first passed promise that rejects.
- OBJECT FUNCTION CreatePromiseAllSettled(OBJECT ARRAY promises)
The CreatePromiseAllSettled returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected.
- OBJECT FUNCTION CreatePromiseRace(OBJECT ARRAY promises, RECORD options)
The race function returns a new promise which is settled in the same way as the first passed promise to settle.
- OBJECT FUNCTION CreateRejectedPromise(VARIANT e)
The CreateRejectedPromise function returns a new promise rejected with the passed argument.
- OBJECT FUNCTION CreateResolvedPromise(VARIANT value)
The CreateResolvedPromise function returns either a new promise resolved with the passed argument, or the argument itself if the argument is a promise produced by this constructor.
- OBJECT FUNCTION CreateSleepPromise(INTEGER time)
Asynchronous sleep (allows microtasks to run ie to allow promises to resolve)
- OBJECTTYPE OperationCancelledException
Exception thrown to indicate that an operation has been cancelled
- OBJECTTYPE PromiseBase
The Promise object is as a placeholder for the value of a currently executing operation. It can be resolved with a value, or rejected with an exception. Only the first resolvement or rejection will be used, once resolved the promise keeps that value.
Within asynchronous functions, you can wait for the promise to be resolved with
AWAIT promise
, with returns the value the promise was resolved with, or throws the exception the promise was rejected with.
Asynchronous programming
- OBJECTTYPE CallSerializer
Helper class that serializes call to functions (optionally coalescing them)
- OBJECT FUNCTION MakeCallSerializer(RECORD options)
Returns a class that helps with serializing functions
- OBJECTTYPE WaitableConditionBase
Base class for waitable condition
Regular expressions
- STRING FUNCTION CreateLikeRegexPattern(STRING likemask)
Create a regular expression pattern to match a LIKE mask
- OBJECTTYPE JSRegEx
JavaScript-like regular expression
- OBJECTTYPE RegEx
Perl-compatible regular expression
Filesystem and process management
- MACRO AddInterruptCallback(MACRO PTR callback)
Add an interrupt (SIGINT,SIGTERM,SIGHUP) callback
- STRING FUNCTION AnsiCmd(STRING types)
Generate ANSI-escape codes.
- STRING FUNCTION BlobToString(BLOB data, INTEGER maxlen)
Convert a blob to a string
- BOOLEAN FUNCTION CloseBlobFile(INTEGER filehandle)
Close a blob file
- BOOLEAN FUNCTION CloseDiskFile(INTEGER filehandle)
Close a file on disk
- MACRO CloseProcess(INTEGER processid)
Wait for an OS subprocess to finish and clean itself up
- MACRO CloseProcessInput(INTEGER processid)
Close the input stream
- STRING FUNCTION CollapsePath(STRING path)
Collapse a path containing duplicate slashes, '.' and '..' entries
- BOOLEAN FUNCTION CreateDiskDirectory(STRING directory, BOOLEAN visible)
Create a directory
- BOOLEAN FUNCTION CreateDiskDirectoryRecursive(STRING directory, BOOLEAN visible)
Create a directory and its parents
- INTEGER FUNCTION CreateDiskFile(STRING path, BOOLEAN failifexists, BOOLEAN publicfile)
Create a file on disk
- BOOLEAN FUNCTION CreateDiskFileFromBlob(STRING path, BOOLEAN failifexists, BOOLEAN publicfile, BLOB sourcedata)
Write a blob to disk
- BOOLEAN FUNCTION CreateHardLink(STRING path, STRING linkto)
Create a hard link
- OBJECT FUNCTION CreateProcess(STRING processexecutable, STRING ARRAY arguments, RECORD options)
Create a new process
- BOOLEAN FUNCTION CreateSoftLink(STRING path, STRING linkto)
Create a soft link
- INTEGER FUNCTION CreateStream()
Create a stream
- BOOLEAN FUNCTION DeleteDiskDirectory(STRING path)
Delete a directory from disk
- BOOLEAN FUNCTION DeleteDiskDirectoryRecursive(STRING path)
Delete a directory and any of its contents from disk, recursively
- BOOLEAN FUNCTION DeleteDiskFile(STRING path)
Delete a file from disk
- BOOLEAN FUNCTION DeleteDiskWildcardsRecursive(STRING path)
Delete files or directories recursively using wildcards
- MACRO FlushOutputBuffer()
Flush the standard output buffer
- STRING FUNCTION GenerateTemporaryPathname()
Generate a temporary filepath
- STRING FUNCTION GenerateTemporaryPathnameFromBasepath(STRING basepath)
Generate a temporary filepath, with a specific base path as prefix
- STRING FUNCTION GetBasenameFromPath(STRING path)
Obtain the basename part from a path
- STRING ARRAY FUNCTION GetConsoleArguments()
Get the arguments passed to a script
- BOOLEAN FUNCTION GetConsoleEcho()
Gets the echo mode of the console
- RECORD FUNCTION GetConsoleSize()
Returns the console size
- STRING FUNCTION GetCurrentPath()
Get the path to the current directory
- STRING FUNCTION GetDirectoryFromPath(STRING path)
Obtain the directory part from a path
- RECORD FUNCTION GetDiskFileProperties(STRING filename)
Read the properties of a file on disk
- BLOB FUNCTION GetDiskResource(STRING path, RECORD options)
Get an existing file from disk as a blob
- RECORD ARRAY FUNCTION GetEnvironment()
Returns the current environment
- STRING FUNCTION GetEnvironmentVariable(STRING varname)
Returns the content of an environment variable
- STRING FUNCTION GetExtensionForMimeType(STRING mimetype)
Get the proper or usual extension for the file's mimetype
- STRING FUNCTION GetExtensionFromPath(STRING path)
Obtain the extension part from a path
- INTEGER64 FUNCTION GetFilelength(INTEGER filehandle)
Get the size of a file (a file on disk or a blob)
- INTEGER64 FUNCTION GetFilePointer(INTEGER filehandle)
Get the current file pointer
- BLOB FUNCTION GetHarescriptResource(STRING path)
Open a HareScript resource file as a blob
- DATETIME FUNCTION GetHostingProcessStartTime()
Get the start time of the current process (runscript, webserver, etc) startup time
- STRING FUNCTION GetLastOSError()
Returns the last OS error
- STRING FUNCTION GetNameFromPath(STRING path)
Obtain the filename part from a path
- BLOB FUNCTION GetPrintedAsBlob(MACRO PTR toinvoke)
Get the output of a function call as a blob
- INTEGER FUNCTION GetProcessExitCode(INTEGER processid)
Get the process exit code, if it stopped
- STRING FUNCTION GetRealPath(STRING path)
Returns an absolute pathname that resolves to the same directory entry as path, without using '.', '..', or symbolic links.
- STRING FUNCTION GetSafeFileName(STRING value)
Generate a filename from a string
- BLOB FUNCTION GetSTDINAsBlob()
Read all of STDIN and return as a blob
- INTEGER64 FUNCTION GetStreamLength(INTEGER streamid)
Get the length of the stream so far
- INTEGER64 FUNCTION GetStreamPointer(INTEGER streamid)
Get the offset of the stream so far
- INTEGER FUNCTION GetSystemNumProcessors()
Get the number of processors installed on this machine
- INTEGER FUNCTION GetSystemNumVirtualProcessors()
Get the number of virtual processors installed on this machine
- STRING FUNCTION GetSystemOsName()
Get a description of the underlying OS
- STRING FUNCTION GetTempDir()
Get the path to temporary working space
- MACRO InterruptProcess(INTEGER processid)
Sends an interrupt signal to a process
- BOOLEAN FUNCTION IsAnsiCmdEnabled()
Returns whether ANSI escape sequences will be generated. Defaults to whether the console is a terminal.
- BOOLEAN FUNCTION IsConsoleATerminal()
Determines if the console is a terminal.
- BOOLEAN FUNCTION IsConsoleClosed()
Returns whether if the process input stream has been closed
- BOOLEAN FUNCTION IsConsoleSupportAvailable()
Returns TRUE if console support is available (only using
wh run
) - BOOLEAN FUNCTION IsPathAbsolute(STRING path)
Test if a path is absolute
- BOOLEAN FUNCTION IsProcessRunning(INTEGER processid)
Check if a process is still running
- BOOLEAN FUNCTION IsRunningInEditor()
Returns TRUE if the current process is running in an editor/debugger
- BLOB FUNCTION MakeBlobFromDiskFile(STRING path)
Open an existing file on disk as a blob
- BLOB FUNCTION MakeBlobFromStream(INTEGER streamid)
Finish writing to a stream and return a blob
- BLOB FUNCTION MakeComposedBlob(RECORD ARRAY parts)
Compose a blob from other blobs
- ASYNC FUNCTION * MakeProcessAsyncIterator(OBJECT process, RECORD options)
Returns a async iterator which yields lines of output from a process
- BLOB FUNCTION MakeSlicedBlob(BLOB parentblob, INTEGER64 startoffset, INTEGER64 length)
Slice a blob
- STRING FUNCTION MergePath(STRING first, STRING second)
Merges to paths together, inserting a slash at the merge point if necessary. The returned string is then collapsed.
- BOOLEAN FUNCTION MoveDiskPath(STRING from_path, STRING to_path)
Rename or move a path on disk
- INTEGER FUNCTION OpenBlobAsFile(BLOB blobfile)
Open a blob as file
- INTEGER FUNCTION OpenDiskFile(STRING path, BOOLEAN writeaccess)
Open an existing file on disk
- RECORD FUNCTION ParseArguments(STRING ARRAY arguments, RECORD ARRAY vars)
Parse the arguments passed to a script
- OBJECTTYPE Process
Process objecttype
- STRING FUNCTION ReadConsoleInput()
Get a single line of text from the console
- RECORD ARRAY FUNCTION ReadDiskDirectory(STRING directory, STRING mask)
Read the contents of a directory on disk
- STRING FUNCTION ReadFromFile(INTEGER filehandle, INTEGER64 numbytes)
Read from a file on disk, moving the file pointer while reading
- STRING FUNCTION ReadProcessErrors(INTEGER processid)
Read any available data from the error stream
- STRING FUNCTION ReadProcessOutput(INTEGER processid)
Read any available data from the output stream
- STRING FUNCTION ReadSoftLink(STRING path)
Read the target of a soft link
- STRING FUNCTION ResolveToAbsolutePath(STRING path)
Resolve a possible relative path to an absolute path
- STRING FUNCTION ResolveToRelativePath(STRING basepath, STRING targetpath)
Resolve an absolute path to a relative path (with respect to a basepath)
- RECORD FUNCTION ScanBlob(BLOB toscan, STRING filename, RECORD options)
Scan a blob and explain its contents.
- MACRO SetAnsiCmdMode(STRING mode)
Override whether ANSI escape sequences will be generated
- MACRO SetConsoleEcho(BOOLEAN setecho)
Sets the echo mode of the console
- MACRO SetConsoleExitCode(INTEGER errorcode)
Set an errorcode to return from console scripts
- MACRO SetConsoleLineBuffered(BOOLEAN setbuffering)
Sets the buffering mode of the console
- MACRO SetDiskFilelength(INTEGER filehandle, INTEGER64 filesize)
Set the size of a file on disk
- BOOLEAN FUNCTION SetFileModificationDate(STRING path, DATETIME newmodtime)
Update the modification date for a file
- MACRO SetFilePointer(INTEGER filehandle, INTEGER64 newpos)
Set the current file pointer
- MACRO SetOutputBuffering(BOOLEAN write_to_buffer)
Enable or disable standard output buffering
- MACRO SetStreamPointer(INTEGER streamid, INTEGER64 newoffset)
Get the length of the stream so far
- BOOLEAN FUNCTION SetUNIXPermissions(STRING path, INTEGER permissions)
Set unix permissions for a file.
- INTEGER FUNCTION StartProcess(STRING processexecutable, STRING ARRAY arguments, RECORD options)
Start an OS subprocess
- MACRO StoreDiskFile(STRING path, BLOB data, RECORD options)
Store a blob to disk
- BLOB FUNCTION StringToBlob(STRING data)
Convert a string to a blob
- MACRO TerminateProcess(INTEGER processid)
Terminate an OS subprocess
- MACRO TerminateScriptWithError(STRING error, RECORD options)
Terminate the current script
- INTEGER FUNCTION WaitForProcessOutput(INTEGER processid, INTEGER maxwait)
Wait for a process to send output
- RECORD FUNCTION WrapBlob(BLOB toscan, STRING filename, RECORD options)
Create a record wrapping the blob and its contents
Inter-process communication and jobs
- ASYNC FUNCTION AsyncCallFunctionFromJob(STRING func, VARIANT ARRAY args)
Asynchronously calls a function from within a new job
- VARIANT FUNCTION AsyncWaitHandleReadSignalled(INTEGER handle, DATETIME waituntil)
Returns whether a handle is read signalled in within a specific period. If immediately signalled, returns TRUE, else a promise. That promise that resolves to TRUE when the handle becomes signalled before waituntil, and to FALSE on timeout
- VARIANT FUNCTION AsyncWaitHandleWriteSignalled(INTEGER handle, DATETIME waituntil)
Returns whether a handle is read signalled in within a specific period. If immediately signalled, returns TRUE, else a promise. That promise that resolves to TRUE when the handle becomes signalled before waituntil, and to FALSE on timeout
- MACRO BroadcastEvent(STRING event, RECORD msg)
Broadcasts an event
- MACRO BroadcastLocalEvent(STRING event, RECORD msg)
Broadcasts an event only in this process (not in other processes)
- VARIANT FUNCTION CallFunctionFromJob(STRING func, VARIANT ARRAY args)
Calls a function from within a new job
- MACRO CancelEventLoop()
Cancel any running event loop, even future ones
- MACRO CloseJobPipe(INTEGER handle)
Closes an input/output pipe of a job
- OBJECT FUNCTION ConnectToGlobalIPCPort(STRING name)
Connects to a global IPC port. If the port exists, a link is established immediately.
- OBJECT FUNCTION ConnectToIPCPort(STRING name)
Connects to an IPC port. If the port exists, a link is established immediately.
- OBJECT FUNCTION CreateGlobalIPCPort(STRING name)
Creates a new named global IPC port, that is reachable from other processes to (using ConnectToGlobalIPCPort). A local port with the same name is also created. No errors are reporting when the registration as global port fails. Also, callback events need to be processed.
- OBJECT FUNCTION CreateIPCPort(STRING name)
Creates a new named IPC port
- RECORD FUNCTION CreateJob(STRING script)
Creates a new job. SUPER rights are required.
- OBJECTTYPE EventManager
Eventmanager object. Used to receive events and broadcast them.
- STRING FUNCTION FormatIPCMessageId(INTEGER64 messageid)
Formats a message id
- STRING FUNCTION GenerateTemporaryIPCPortName()
create a random, free port name, that will not be affected by future namespaces
- STRING FUNCTION GetCurrentGroupId()
Returns Harescript group ID of current script
- OBJECT FUNCTION GetIPCLinkToParent()
Returns the endpoint of the link to the parent
- OBJECTTYPE IPCLinkEndpoint
This objecttypes contains the endpoint of an IPC link. You can send messages to the other endpoint of the link, and receive messages from the other endpoint.
If you need to wait on a message, you can use the @a handle property as a parameter to WaitForMultiple. The handle is signalled when a message is in queue, or when the other endpoint is closed.
- OBJECTTYPE IPCPort
An IPC port is used as an address to create IPC links to. Only one port with a given name may exist in a system.
If you need to wait on a incoming link request, you can use the @a handle property as a parameter to WaitForMultiple. The handle is signalled when a link request is in queue.
- OBJECTTYPE IPCPortHandlerBase
This objecttype is meant as a base for a message-handling script, and tries to abstract away the waiting on, receiving of and sending of messages as much as possible.
How to use it:
Open a listening port (eg using CreateIPCPort). Create an object based on the porthandlerbase, and give the port as argument. Call the Run member.
Messages will be dispatched to the OnMessage member. When processing just one message at a time, the reply can be sent by just returning the appropriate return value.
If you waiting loop needs to wait on other handles, or you need timeouts, you can override some other functions, to implement those.
In flat_responses mode, exceptions are given back as cell __exception Cells: what (string), trace (record array)
- BOOLEAN FUNCTION IsWithinFunctionRunningJob()
Returns whether we're in a job used by (Async)CallFunctionFromJob
- INTEGER FUNCTION RegisterEventCallback(STRING event, FUNCTION PTR callback)
Registers an callback function capable of handling a single event to be called when a certain event is dispatched. Only supported in the following contexts: tollium, appserver and porthandler.
- INTEGER FUNCTION RegisterHandleReadCallback(INTEGER handle, FUNCTION PTR callback)
Registers an callback function that will be called when a handle is read signalled. Only supported in the following contexts: tollium, appserver and porthandler.
- INTEGER FUNCTION RegisterHandleWriteCallback(INTEGER handle, FUNCTION PTR callback)
Registers an callback function that will be called when a handle is write signalled. Only supported in the following contexts: tollium, appserver and porthandler.
- INTEGER FUNCTION RegisterMultiEventCallback(STRING event, FUNCTION PTR callback, RECORD options)
Registers an callback function capable of handling multiple events to be called when a certain event is dispatched. Only supported in the following contexts: tollium, appserver and porthandler.
- MACRO RegisterReceivedExceptionType(STRING type, FUNCTION PTR createfunc)
Register an exception type that can be received from IPC links for automatic throwing by receivemessage
- INTEGER FUNCTION RegisterTimedCallback(DATETIME when, FUNCTION PTR callback)
Register a callback that will be called at the first wait point after a specified time. Only supported in the following contexts: tollium, appserver and porthandler.
- MACRO RunEventLoop()
Loop on all messages until CancelEventLoop is invoked
- MACRO ScheduleMicroTask(MACRO PTR task)
Schedule a micro task
- MACRO UnregisterCallback(INTEGER id)
Unregisters a previously registered callback (handle, event or timed)
Cryptographic operations
- INTEGER FUNCTION CreateStreamingHasher(STRING algorithm, STRING key_salt)
Create a streaming hasher
- STRING FUNCTION CreateWebHarePasswordHash(STRING pwd)
Hash a password
- RECORD FUNCTION DecodeECSignature(STRING signature)
Decode a BER-encoded EC signature into its
r
ands
components - STRING FUNCTION Decrypt(STRING algorithm, STRING keydata, STRING data, RECORD options)
- STRING FUNCTION DecryptSignedData(STRING data, STRING algorithm, STRING encryptkey)
Decrypt a string encrypted by EncryptAndSignData
- STRING FUNCTION EncodeECSignature(RECORD signature)
Encode an EC signature with
r
ands
components into a verifiable BER-encoded signature - STRING FUNCTION Encrypt(STRING algorithm, STRING keydata, STRING data, RECORD options)
- STRING FUNCTION EncryptAndSignData(STRING data, STRING algorithm, STRING encryptkey)
Salt, eencrypt and sign a string
- OBJECTTYPE EVPKey
EVP key (high-level cryptograpic key)
- OBJECT FUNCTION GenerateCryptoKey(STRING type, VARIANT options)
Create a cryptograpic key
- STRING FUNCTION GeneratePassword(STRING base, INTEGER len, BOOLEAN mixed_case)
Generate a password
- STRING FUNCTION GenerateRandomBinaryValue(INTEGER len)
Returns a random binary string
- STRING FUNCTION GenerateRandomText(INTEGER len, STRING allowed_chars)
Generate a random text
- STRING FUNCTION GenerateUFS128BitId()
Generate a random 128bit UFS-encoded ID
- STRING FUNCTION GenerateUUID()
Generate a V4 UUID (or GUID in Microsoft-speak)
- RECORD FUNCTION GetCertificateData(STRING certificate)
Returns components of a certificate
- STRING FUNCTION GetHashForBlob(BLOB data, STRING algorithm, STRING key_salt)
Return the hash for a blob
- STRING FUNCTION GetHashForString(STRING text, STRING algorithm, STRING key_salt)
Return the hash for a string
- STRING FUNCTION GetMD5Hash(STRING text)
Return the MD5 hash for a text
- STRING FUNCTION GetSHA1Hash(STRING text)
Return the SHA1 hash for a text
- STRING FUNCTION GetVariableHash(VARIANT variable)
- BOOLEAN FUNCTION IsWebHarePasswordHashStillSecure(STRING hash)
Is the specified password hash still secure?
- OBJECT FUNCTION MakeCryptoKey(STRING keydata)
Read a cryptograpic key from private or public key data
- STRING FUNCTION MakeHashFromStreamer(INTEGER streamerid)
Close a streaming hasher
- BOOLEAN FUNCTION VerifyWebHarePasswordHash(STRING pwd, STRING hash)
Verify a password against a stored hash