8.1. Mathematical
Function |
Description |
function Sqr(const X: Double): Double |
Square |
function Max(const A, B: Double): Double |
Greater of two number |
function Min(const A, B: Double): Double |
Lesser of two numbers |
function Round(e: Extended): Integer |
Round to nearest integer |
function Trunc(e: Extended): Integer |
Truncate fractional portion |
function Int(e: Extended): Integer |
Return integer part of the number |
function Frac(X: Extended): Extended |
Return fractional portion |
function Sqrt(e: Extended): Extended |
Square root |
function Abs(e: Extended): Extended |
absolute value / modulus |
function Sin(e: Extended): Extended |
Sine |
function Cos(e: Extended): Extended |
Cosine |
function ArcTan(X: Extended): Extended |
Arctangent |
function Tan(X: Extended): Extended |
Tangent |
function Exp(X: Extended): Extended |
Exponential |
function Ln(X: Extended): Extended |
logarithm |
function Pi: Extended |
π |
8.2. Date/Time
function EncodeDate(Year, Month, Day: Word): TDateTime |
Conversion of the year, month and day to the date format |
procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word) |
Conversion of date to the year, month and day |
function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime |
Conversion of hours, minutes, and seconds to the time format |
procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word) |
Conversion of time to hours, minutes, and seconds |
function Date: TDateTime |
Current date |
function Time: TDateTime |
Current time |
function Now: TDateTime |
Current date and time |
function DayOfWeek(aDate: DateTime): Integer |
Day of the week |
function IsLeapYear(Year: Word): Boolean |
Check if leap year |
function DaysInMonth(nYear, nMonth: Integer): Integer |
Check for number of days in a month |
8.3. String functions
function Length(s: String): Integer |
Length of a string |
function Copy(s: String; from, count: Integer): String |
Returns substring of a given length starting from the specified position |
function Pos(substr, s: String): Integer |
Returns position of substring within given string |
procedure Delete(var s: String; from, count: Integer) |
Removes substring of a given length starting from the specified position |
procedure Insert(s: String; var s2: String; pos: Integer) |
Append second string to the first |
function Uppercase(s: String): String |
Convert string into uppercase |
function Lowercase(s: String): String |
Convert string into lowercase |
function Trim(s: String): String |
Remove blank spaces from a string |
function NameCase(s: String): String |
Convert the first letter into uppercase |
function CompareText(s, s1: String): Integer |
Compares two strings |
function Chr(i: Integer): Char |
Return character with specified position |
function Ord(ch: Char): Integer |
Returns position of specified character |
procedure SetLength(var S: String; L: Integer) |
Sets length of a string |
8.4. Others
procedure Inc(var i: Integer; incr: Integer = 1) |
Increment |
procedure Dec(var i: Integer; decr: Integer = 1) |
Decrement |
procedure RaiseException(Param: String) |
Generate error message |
procedure Randomize |
Generate random number |
function Random: Extended |
Generate Pseudo-random number |
function ValidInt(cInt: String): Boolean |
Validate Integer |
function ValidFloat(cFlt: String): Boolean |
Validate Floating |
function ValidDate(cDate: String): Boolean |
Validate Date |
8.5. TStringList class objects
TStringList class objects are used to export data to a string file, and load it from a string file.
In order to create such an object, use the function TStringList.Create.
Example:
var Settings: TStringList;
------------------------------- procedure Init; begin Settings := TStringList.Create; end; |
This object has 5 properties:
a) Count: Integer – the number of strings in the list
b) Names[ ]: String – the name at a given index in the list
c) Values[ ]: String – the value for a given name when using name/value pair strings
d) Strings[ ]: String - the string at a given index in the list
e) Text: String – the whole list
You can use the following functions and procedures when working with this object:
function TStringList.Add(const S: string): Integer |
Adds a string to the list |
procedure TStringList.Clear |
Clears the list |
procedure TStringList.Delete(Index: Integer) |
Deletes the string with the given index from the list |
function TStringList.IndexOf(const S: string): Integer |
Returns the index of the given string. |
function TStringList.IndexOfName(const Name: string): Integer |
Returns the index of the string with a given name. |
procedure TStringList.Insert(Index: Integer; const S: string) |
Inserts the given string into the given position. |
procedure TStringList.LoadFromFile(const FileName: string) |
Loads the values from a file into the String list. |
procedure TStringList.SaveToFile(const FileName: string) |
Saves the String list into the file. |
In order to delete such an object, use the function Free.
Example:
Settings.Free; |
8.6. Scale marking setting
When using the function SetYScale, the vertical markings type can be altered depending on the type of your indicator. The Function SetYValuesFormat (const Format: String) can be used for this purpose.
The Format string can include the following symbols:
Symbol |
Influence |
# |
This symbol stands for a digit placeholder. The digit from the position where ‘#’ appears in the format string should be output in the corresponding position in the vertical markings. If there is no digit in that position, nothing is output in that position in the vertical markings. |
0 |
This symbol stands for a digit placeholder. The digit from the position where ‘0’ appears in the format string should be output in the corresponding position in the vertical markings. If there is no digit in that position, then ‘0’ will be output in that position in the vertical markings. The vertical markings will be rounded according to the number of ‘0’ and/or ‘#’ symbols after the decimal point in the format string. |
. |
This symbol stands for the decimal point. If there are more than one ‘.’ symbols, all of them except for the first one are ignored. This symbol specifies where the decimal separator should appear in the vertical markings. |
, |
This symbol stands for the thousand separator. If there is at least one ‘,’ symbol in the format string, the thousand separators will appear in the vertical markings between every three digits on the left side of the decimal point (the number of ‘,’ symbols and there positioning is ignored). |
E+, E-, e+, e- |
This symbol stands for the scientific notation. If there is any of the symbols ‘E+’, ‘E-’, ‘e+’, or ‘e-’ in the format string, the format of vertical markings will be set according to the scientific notation. The minimum number of digits in the exponent is determined depending on the number of ‘0’ symbols (up to four) which follow the scientific notation symbol. If the ‘E-’ or the ‘e-’ symbol is used in the format string, the sign symbol will be displayed only for the negative exponents. If the ‘E+’ or the ‘e+’ symbol is used, the sign symbol will be displayed for both positive and negative exponents. |
; |
This symbol is the separator. It allows to specify different formats for the positive, negative and zero values. If there is no such separator, the format string is applied to all of the values. If there is one separator in the format string, the first part corresponds to the positive and zero values, and the second part corresponds to the negative values. If there are two separators, then the first part is applied to the positive values, the second part corresponds to the negative values, and the third part corresponds to the zero values. |
‘xx' or "xx" |
The symbols in the quotes will be displayed in the vertical markings, as indicated in the format string. These symbols do not have influence on the format. |