LUA object: utility

The object contains all the system utilities.

AvailabilityGlobal object, available in all scripts
Pre-initialized inAll scripts

convap

DescriptionDoubles the single quotes in the string, so that it can be used within an SQL statement
Value Typestring
Formatstring = utility.convap(value)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
valuestringThe value to be checked
Examples
datatable = database.getsql("SELECT * FROM customers where name='" .. utility.convap("D'Amico") .. "'")

createdate

DescriptionCreates a date in timestamp format
Value Typedouble
Formatdouble = utility.createdate(year, month, day, hour, minute, second)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
yearintegerThe year of the date to convert
monthintegerThe month of the date to convert
dayintegerThe day of the date to convert
hourintegerThe hour of the date to convert
minuteintegerThe minutes of the date to convert
secondintegerThe seconds of the date to convert
Examples
date = utility.createdate(2024,03,16,2,30,0)

crlf

DescriptionReturns the carriage return character
Value Typestring
Formatstring = utility.crlf()
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
Examples
carrier = utility.crlf()

dateadddays

DescriptionIncreases the days of a date
Value Typedouble
Formatdouble = utility.dateadddays(timestamp, number)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date to be modified in timestamp format
numberdoubleThe number of days to add or subtract
Examples
newdate = utility.dateadddays(date,1)

dateaddhours

DescriptionIncreases the hours of a given date
Value Typedouble
Formatdouble = utility.dateaddhours(timestamp, number)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date to be modified in timestamp format
numberdoubleThe number of hours to add or subtract
Examples
newdate = utility.dateaddhours(date,1)

dateaddminutes

DescriptionIncreases the minutes of a given date
Value Typedouble
Formatdouble = utility.dateaddminutes(timestamp, number)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date to be modified in timestamp format
numberdoubleThe number of minutes to add or subtract
Examples
newdate = utility.dateaddminutes(date,1)

dateaddmonths

DescriptionIncreases the months of a date
Value Typedouble
Formatdouble = utility.dateaddmonths(timestamp, number)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date to be modified in timestamp format
numberdoubleThe number of months to add or subtract
Examples
newdate = utility.dateaddmonths(date,1)

dateaddseconds

DescriptionIncreases the seconds of a date
Value Typedouble
Formatdouble = utility.dateaddseconds(timestamp, number)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date to be modified in timestamp format
numberdoubleThe number of seconds to add or subtract
Examples
newdate = utility.dateaddseconds(date,1)

dateaddyears

DescriptionIncreases the years of a date
Value Typedouble
Formatdouble = utility.dateaddyears(timestamp, number)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date to be modified in timestamp format
numberdoubleThe number of years to add or subtract
Examples
newdate = utility.dateaddyears(date,1)

dateday

DescriptionExtracts the numerical value of the day from a date
Value Typeinteger
Formatinteger = utility.dateday(timestamp)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe timestamp date from where to extract the value

datedayofweek

DescriptionReturns a number representing the day of the week
Value Typeinteger
Formatinteger = utility.datedayofweek(timestamp)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date in timestamp format

datediffminutes

DescriptionThe function calculates the difference in minutes between two timestamp dates
Value Typesingle
Formatsingle = utility.datediffminutes(startdate, enddate)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
startdatedoubleThe start timestamp date
enddatedoubleThe end timestamp date

datehour

DescriptionExtracts the numerical value of the hour from a date
Value Typeinteger
Formatinteger = utility.datehour(timestamp)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe timestamp date from where to extract the value

dateminute

DescriptionExtracts the numerical value of the minutes from a date
Value Typeinteger
Formatinteger = utility.dateminute(timestamp)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe timestamp date from where to extract the value

datemonth

DescriptionExtracts the numeric value of the month from a date
Value Typeinteger
Formatinteger = utility.datemonth(timestamp)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe timestamp date from where to extract the value

datesecond

DescriptionExtracts the numerical value of seconds from a date
Value Typeinteger
Formatinteger = utility.datesecond(timestamp)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe timestamp date from where to extract the value

datetostring

DescriptionConverts a timestamp date into a string
Value Typestring
Formatstring = utility.datetostring(timestamp)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date in timestamp format to be converted into a string

dateyear

DescriptionExtracts the numeric value of the year from a date
Value Typeinteger
Formatinteger = utility.dateyear(timestamp)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe timestamp date from where to extract the value

escapehtml

DescriptionPerforms an HTML escape on a string
Value Typestring
Formatstring = utility.escapehtml(value)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
valuestringThe value to be converted

formatdate

DescriptionConverts a timestamp date into a defined string format
Value Typestring
Formatstring = utility.formatdate(timestamp, format)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
timestampdoubleThe date in timestamp format to be converted
formatstringThe mask of the format to be applied to the string

formatnum

DescriptionConverts a numerical value into a string by rounding it to a specific number of decimals
Value Typestring
Formatstring = utility.formatnum(number, numberdecimal)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
numberdoubleThe number to be converted
numberdecimalintegerThe number of decimals to keep

getnow

DescriptionRetrieves the current date
Value Typedouble
Formatdouble = utility.getnow()
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS

gguid

DescriptionReturns a new unique identifier
Value Typestring
Formatstring = utility.gguid()
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS

isnum

DescriptionChecks whether a value is a number
Value Typeboolean
Formatboolean = utility.isnum(value)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
valueobjectThe value to be checked

stringreplace

DescriptionReplaces a part of a string with another value
Value Typestring
Formatstring = utility.stringreplace(expression, find, replacement)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
expressionstringThe string to be evaluated
findstringThe string to search for
replacementstringThe string that will replace the value found within the expression

stringtrim

DescriptionThe function removes spaces on the right and left of a string
Value Typestring
Formatstring = utility.stringtrim(expressions)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
expressionsstringThe string to be checked

tid

DescriptionReturns the current date in numeric format, to be used as a time marker on records
Value Typedouble
Formatdouble = utility.tid()
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
NotesThe date format used is “YYYYMMDDhhmmss”

urlencode

DescriptionPerforms an escape on a URL link
Value Typestring
Formatstring = utility.urlencode(value)
TypeMethod
SystemsWindows, Web, Android, IOS, Mac OS
ParameterValue TypeDescription
valuestringThe URL link to be converted