function Abs(e: Extended): Extended returns the positive value of the argument function ArcTan(X: Extended): Extended Calculates the arctangent of a given number. function Cos(e: Extended): Extended Calculates the cosine of an angle. function Exp(X: Extended): Extended Returns the exponential of X. function Frac(X: Extended): Extended Returns the fractional part of a real number. function Int(e: Extended): Integer Returns the integer part of a real number. function Ln(X: Extended): Extended Returns the natural log of a real expression. function Pi: Extended Returns 3.1415926535897932385. function Round(e: Extended): Integer Round returns a value that is the value of X rounded to the nearest whole number. If X is exactly halfway between two whole numbers, the result is always the even number. function Sin(e: Extended): Extended Returns the sine of the angle in radians. function Sqrt(e: Extended): Extended Returns the square root of X. function Tan(X: Extended): Extended Returns the tangent of X. function Trunc(e: Extended): Integer Truncates a real number to an integer. |
function Chr(i: Integer): Char Returns the character for a specified ASCII value. function CompareText(s, s1: String): Integer Compares two strings by ordinal value without case sensitivity. Thus for example, CompareText will indicate that the string ABC is less than aaa because A is less than a in ascii order. function Copy(s: String; from, count: Integer): String Returns a substring of a string, starting at FROM for COUNT characters function Length(s: String): Integer Returns the number of characters in a string or elements in an array. function Lowercase(s: String): String Converts an ASCII string to lowercase. function NameCase(s: String): String Converts the first character of words to uppercase function Ord(ch: Char): Integer Returns the ordinal value of an ordinal-type expression. E.g Ord('A') would return 65 function Pos(substr, s: String): Integer Returns the index value of the first character in a specified substring that occurs in a given string. If Substr is not found, Pos returns zero. function Trim(s: String): String Trims leading and trailing spaces and control characters from a string. function Uppercase(s: String): String Converts an ASCII string to uppercase. procedure Delete(var s: String; from, count: Integer): String Removes a substring from a s string. Delete removes a substring of Count characters from string S starting with S[Index]. S is a string-type variable. Index and Count are integer-type expressions. procedure Insert(s: String; var s2: String; pos: Integer): String Inserts a substring into a string beginning at a specified point. procedure SetLength(var S: String; L: Integer) Sets the length of a string or dynamic-array variable.
|
function CreateOleObject(ClassName: String): Variant Instantiates a single instance of an Automation object. ClassName specifies the string representation of the Class ID (CLSID). function Random: Extended Random returns a random number within the range 0 <= X < Range. If Range is not specified, the result is a real-type random number within the range 0 <= X < 1.
NB: To initialize the random number generator, add a single call Randomize before making any calls to Random. function ValidDate(cDate: String): Boolean Returns True if the string argument has a valid date(time) format function ValidFloat(cFlt: String): Boolean Returns True if the string argument has a valid real format function ValidInt(cInt: String): Boolean Returns True if the string argument has a valid integer format function VarArrayCreate(Bounds: Array; Typ: Integer): Variant All kind of arrays are supported: static (one- and multi-dimesional), dynamic, variant arrays. However, since the scripting control uses variant types 'behind the scene' there is a specific syntax for creating arrays that requires a call to the VarArrayCreate function. Here is an example of script that uses all array types:
var ar1: array[0..2] of Integer; ar2: array of Integer; ar3: Variant;
SetLength(ar2, 3); ar3 := VarArrayCreate([0, 2], varInteger); ar1[0] := 1; ar2[0] := 1; ar3[0] := 1; procedure Dec(var i: Integer; decr: Integer = 1) Decrements a variable by 1 or decr. procedure Inc(var i: Integer; incr: Integer = 1) Increments a variable by 1 or decr. procedure RaiseException(Param: String) Will generate an error message stop the continuation of the code flow procedure Randomize Initializes the random number generator with a random value. Typically, Randomize is called only once, before all calls to Random. procedure ShowMessage(Msg: Variant) Call ShowMessage to display a simple message box with an OK button. |
function Date: TdateTime Returns the current date function DateOf(const AValue: TDateTime): TDateTime Returns the date part of a datetime function DayOf(const AValue: TDateTime): Word Returns the day in the month of the date argument function DayOfTheMonth(const AValue: TDateTime): Word Returns the day in the month of the date argument function DayOfTheWeek(const AValue: TDateTime): Word Returns the day in the week of the date argument. Monday is Day1 function DayOfTheYear(const AValue: TDateTime): Word Returns the day in the year of the date argument function DaysInAMonth(const AYear, AMonth: Word): Word Returns the number of days in the month of a supplied year function DaysInAYear(const AYear: Word): Word Returns the number of days in a supplied year function DaysInMonth(const AValue: TDateTime): Word Returns the number of days in the month of a supplied date function DaysInYear(const AValue: TDateTime): Word Returns the number of days in the year of a supplied date function EncodeDate(Year, Month, Day: Word): TdateTime Converts arguments into a Date value function EncodeTime(Hour, Min, Sec, MSec: Word): TdateTime Converts arguments into a Time value function EndOfAMonth(const AYear, AMonth: Word): TDateTime Returns the end of month date for year and month arguments function EndOfAWeek(const AYear, AWeekOfYear: Word; const ADayOfWeek: Word = 7): TDateTime Returns the end of week date for year and week arguments function EndOfAYear(const AYear: Word): TDateTime Returns the end of year date for year argument function EndOfTheDay(const AValue: TDateTime): TDateTime Returns datetime at the end of the day of the date argument e.g. 01/01/2005 15:36 becomes 01/01/2005 23:59 function EndOfTheMonth(const AValue: TDateTime): TDateTime Returns the end of the month date for the month in the date argument function EndOfTheWeek(const AValue: TDateTime): TDateTime Returns the end of the week date for the week in the date argument function EndOfTheYear(const AValue: TDateTime): TDateTime Returns the end of the year date for the month in the date argument function HourOf(const AValue: TDateTime): Word Returns the hour value for the datetime argument function HourOfTheDay(const AValue: TDateTime): Word Returns the hour in the day for the datetime argument function HourOfTheMonth(const AValue: TDateTime): Word Returns the hour in the month for the datetime argument function HourOfTheWeek(const AValue: TDateTime): Word Returns the hour in the week for the datetime argument function HourSpan(const ANow, AThen: TDateTime): Double Returns the number of hours between two dates function IsInLeapYear(const AValue: TDateTime): Boolean Returns True if argument is in a leap year function IsLeapYear(Year: Word): Boolean Returns True if argument is a leap year function IsPM(const AValue: TDateTime): Boolean Returns True if argument is in the afternoon function IsSameDay(const AValue, ABasis: TDateTime): Boolean Returns True if two dates are on the same day function IsToday(const AValue: TDateTime): Boolean Returns True if argument is today function IsValidDate(const AYear, AMonth, ADay: Word): Boolean Returns True if arguments make up a valid date function IsValidDateDay(const AYear, ADayOfYear: Word): Boolean Returns True if ADayOfYear of Ayear falls on a valid date function IsValidDateMonthWeek(const AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word): Boolean Returns True if AWeekOfMonth and ADayOfWeek falls on a valid date for the aYear and aMonth arguments. function IsValidDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word): Boolean Returns True if arguments make up a valid datetime function IsValidDateWeek(const AYear, AWeekOfYear, ADayOfWeek: Word): Boolean Returns True if arguments make up a valid date function IsValidTime(const AHour, AMinute, ASecond, AMilliSecond: Word): Boolean Returns True if arguments make up a valid date function MinuteOf(const AValue: TDateTime): Word Returns the minute only of a datetime argument function MinuteOfTheDay(const AValue: TDateTime): Word Returns the minute part of a datetime argument function MinuteOfTheHour(const AValue: TDateTime): Word Returns the number of minutes into a the day of the dateime argument function MonthOf(const AValue: TDateTime): Word Returns the month part of a datetime argument function MonthOfTheYear(const AValue: TDateTime): Word Returns the number of months into the year of the datetime argument function Now: TdateTime Returns the current date time function StartOfAMonth(const AYear, AMonth: Word): TdateTime Returns the date for the first day in the month for the aMonth and aYear arguments function StartOfAWeek(const AYear, AWeekOfYear: Word; const ADayOfWeek: Word = 1): TdateTime Returns the date of the start of the week in the supplied year and week arguments. function StartOfAYear(const AYear: Word): TdateTime Returns January 1st for the year in the Date Time argument function StartOfTheDay(const AValue: TDateTime): TdateTime Returns the date part only of the argument, thus giving the start of the day function StartOfTheMonth(const AValue: TDateTime): TdateTime Returns the date of the first day of the month in the Date Time argument function StartOfTheWeek(const AValue: TDateTime): TdateTime Returns the date of the Monday of the week in the Date Time argument function StartOfTheYear(const AValue: TDateTime): TdateTime Returns January 1st for the year in the Date Time argument function Time: TdateTime Returns the current time function TimeOf(const AValue: TDateTime): TdateTime Retuns the time fraction of datetime argument, N.B. 0.5 = 12:00hr function Today: TdateTime Returns Today's date function Tomorrow: TdateTime Returns Tomorrow's date function WeekOf(const AValue: TDateTime): Word Returns the number of weeks into a the year of the date time argument function WeekOfTheMonth(const AValue: TDateTime): Word Returns the number of weeks into the month of the date time argument function WeekOfTheYear(const AValue: TDateTime): Word Returns the number of weeks into the year of the date time argument function WeeksInAYear(const AYear: Word): Word Returns the number of weeks in the year of the year argument function WeeksInYear(const AValue: TDateTime): Word Returns the number of weeks in the year of the date argument function YearOf(const AValue: TDateTime): Word Returns the year part of the date argument function Yesterday: TdateTime Returns yesterday's date procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word) decomposes a date into constituent Year, Month, Day values; procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word) decomposes a date into constituent Hour, Min, Sec, MSec values; |
Most of the functions available perform standard tasks that many programmers would expect a programming environment to offer; however, the Navigator node contains a number of specialised functions that have been crafted to assist with the sort of calculations that you might need when working out crew costs. You will see some of them used in the code samples supplied, but a brief explanation of them follows below:
GetSubRangeHours(mainRangeStart, mainRangeFinish, subRangeStart, subRangeFinish: real; DoublePeriod: boolean = False): real This is the real engine of time of day hourly pricing. It returns the overlap in hours of two time ranges, regardless of midnight spans and other complexities. The optional DoublePeriod parameter tells the function to get the second overlap if there is one as well, e.g. overtime rate is from 21:00 - 07:00 and someone works from 06:00 until 22:00. If DoublePeriod = false then overlap for overtime is 1 hour, if true its 2 hours. DateTimeInHoursRange(aDateTime, RangeStartTime, RangeEndTime: real; IncludeStart, IncludeEnd: boolean): boolean Tests if a time falls in a time range. IncludeStart, IncludeEnd specify whether you consider the time in the range if it equals the extreme of the range. For example, if you are interested in if the START of someone's shift falls in the range you might want to set IncludeStart = True, IncludeEnd = false. GetHolidaysFromRange(Start, Finish: TdateTime; HolidayArray: variant; IngoreWeekend: boolean = false): integer This allows you to get the number of user-defined holiday days from a period. The list of holidays is passed in the HolidayArray parameter and this must be constructed in a special way. See the sample "Daily - inc. holidays" script for an example of its implementation. The IgnoreWeekend parameter stops the total returned adding Saturdays and Sundays if the holidays fall on any of these days. GetHolidaysFromRangeEx(Start, Finish: TdateTime; HolidayArray: variant; IngoreDays: variant): integer This works just like GetHolidaysFromRange() except that you can pass a variant array of integers in your IngoreDays parameter where Monday = 1, Sunday = 7. GetDayCountFromRange(Start, Finish: TdateTime;Day:integer): integer This retrieves the number of Monday, Tuesdays, etc from a date range, where Monday = 1, Sunday = 7 GetDaysCountFromRange(Start, Finish: TdateTime;Days:variant): integer This works just like GetDayCountFromRange() except that you can pass a variant array of integers in your Days parameter where Monday = 1, Sunday = 7, thus enabling you to get then total number of, say, Fridays and Saturdays in a period. GetEasterDate(year, method: word):TDateTime This retrieves Easter Sunday date from a year (e.g. 2005). The method parameter can be either 1,2,or 3 where · 1 uses the Julian calendar · 2 uses the Gregorian calendar (orthodox method) · 3 users the Gregorian calendar (western method) The third method would normally be passed. DateToHolidaysString(aDate:TDateTime):string This function will return a string from a date that is formatted correctly to be added to a HolidayArray. See the sample "Daily - inc. holidays" script for an example of its implementation. GetWeekendDaysFromRange(Start, Finish: TdateTime): integer Returns the number of Weekend days in a time period IsAHoliday(aDate:TDateTime;HolidayArray:variant):boolean Returns true if a passed date is in a user defined HolidayArray (see above). |
function DateTimeToStr(e: Extended): String Converts a DateTime value to a string. function DateToStr(e: Extended): String Converts a Date value to a string. function FloatToStr(e: Extended): String Converts a real number to a string. function IntToStr(i: Integer): String Converts an integer to a string. function StrToDate(s: String): Extended Converts a string to a DateTime value. function StrToDateTime(s: String): Extended Converts a string to a DateTime value. function StrToFloat(s: String): Extended Converts a string to a real number. function StrToInt(s: String): Integer Converts a string to an integer value. function StrToTime(s: String): Extended Converts a string to a DateTime value. function TimeToStr(e: Extended): String Converts a Time to a String value. function VarToStr(v: Variant): String Converts a Variant to a string. |
function Format(Fmt: String; Args: array): String Returns a formatted string assembled from a format string and an array of arguments. e.g. Format('There are now %d records in the table', [DataSet.RecordCount]); The following table summarizes the possible values for the array of arguments:
d Decimal. The argument must be an integer value. The value is converted to a string of decimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has less digits, the resulting string is left-padded with zeros. u Unsigned decimal. Similar to 'd' but no sign is output. e Scientific. The argument must be a floating-point value. The value is converted to a string of the form "-d.ddd...E+ddd". The resulting string starts with a minus sign if the number is negative. One digit always precedes the decimal point.The total number of digits in the resulting string (including the one before the decimal point) is given by the precision specifier in the format string—a default precision of 15 is assumed if no precision specifier is present. The "E" exponent character in the resulting string is always followed by a plus or minus sign and at least three digits. f Fixed. The argument must be a floating-point value. The value is converted to a string of the form "-ddd.ddd...". The resulting string starts with a minus sign if the number is negative.The number of digits after the decimal point is given by the precision specifier in the format string—a default of 2 decimal digits is assumed if no precision specifier is present. g General. The argument must be a floating-point value. The value is converted to the shortest possible decimal string using fixed or scientific format. The number of significant digits in the resulting string is given by the precision specifier in the format string—a default precision of 15 is assumed if no precision specifier is present.Trailing zeros are removed from the resulting string, and a decimal point appears only if necessary. The resulting string uses fixed point format if the number of digits to the left of the decimal point in the value is less than or equal to the specified precision, and if the value is greater than or equal to 0.00001. Otherwise the resulting string uses scientific format. n Number. The argument must be a floating-point value. The value is converted to a string of the form "-d,ddd,ddd.ddd...". The "n" format corresponds to the "f" format, except that the resulting string contains thousand separators. m Money. The argument must be a floating-point value. The value is converted to a string that represents a currency amount. The conversion is controlled by the CurrencyString, CurrencyFormat, NegCurrFormat, ThousandSeparator, DecimalSeparator, and CurrencyDecimals global variables, all of which are initialized from the Currency Format in the International section of the Windows Control Panel. If the format string contains a precision specifier, it overrides the value given by the CurrencyDecimals global variable. p Pointer. The argument must be a pointer value. The value is converted to an 8 character string that represents the pointers value in hexadecimal. s String. The argument must be a character, a string, or a PChar value. The string or character is inserted in place of the format specifier. The precision specifier, if present in the format string, specifies the maximum length of the resulting string. If the argument is a string that is longer than this maximum, the string is truncated. x Hexadecimal. The argument must be an integer value. The value is converted to a string of hexadecimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has fewer digits, the resulting string is left-padded with zeros. function FormatFloat(Fmt: String; Value: Extended): String Formats a floating point value. The following format specifiers are supported in the format string: 0 Digit place holder. If the value being formatted has a digit in the position where the '0' appears in the format string, then that digit is copied to the output string. Otherwise, a '0' is stored in that position in the output string. # Digit placeholder. If the value being formatted has a digit in the position where the '#' appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.
. Decimal point. The first '.' character in the format string determines the location of the decimal separator in the formatted value; any additional '.' characters are ignored. The actual character used as a the decimal separator in the output string is determined by the DecimalSeparator global variable. The default value of DecimalSeparator is specified in the Number Format of the International section in the Windows Control Panel. , Thousand separator. If the format string contains one or more ',' characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of ',' characters in the format string does not affect the output, except to indicate that thousand separators are wanted. The actual character used as a the thousand separator in the output is determined by the ThousandSeparator global variable. The default value of ThousandSeparator is specified in the Number Format of the International section in the Windows Control Panel.
function FormatDateTime(Fmt: String; DateTime: TDateTime): String The following example assigns 'The meeting is on Wednesday, February 15, 1995 at 10:30 AM' to the string variable S.
S := FormatDateTime('"The meeting is on " dddd, mmmm d, yyyy, " at " hh:mm AM/PM', StrToDateTime('2/15/95 10:30am')); |
All kind of arrays are supported: static (one- and multi-dimesional), dynamic, variant arrays. However, since the scripting control uses variant types 'behind the scene' there is a specific syntax for creating arrays that requires a call to the VarArrayCreate function. Here is an example of script that uses all array types:
var ar1: array[0..2] of Integer; ar2: array of Integer; ar3: Variant;
SetLength(ar2, 3); ar3 := VarArrayCreate([0, 2], varInteger); ar1[0] := 1; ar2[0] := 1; ar3[0] := 1; |