Math Expressions
This section explains the syntax, and available functions and scopes for the math expressions. Math expressions are used in various places in the software:
- math parameters
- exports
- CID cell formatting
When writing a math expression there will be an auto complete functionality that can help to find parameter and function names.
Syntax
When writing a math expression, parameters from the current definition or other related definitions can be accessed and functions can be called to perform operations. Basic numerical, text and boolean operators are available.
Accessing a parameter
Parameters can be accessed by their names. Note that part item parameters are accessed using the name of the part parameter with PartItem
added to the end of the name.
Operators
The following numerical operators are available:
+
addition-
subtraction*
multiplication/
division
The following boolean operators are available:
<
less than<=
less than or equal<
greater than<=
greater than or equal&&
and||
or==
equal!=
not equal
The following operators are available for date time parameters:
+
addition. If the LHS is a date time and the RHS is a numerical parameter then the return value will be a new date time with the number of seconds from the RHS added to the LHS date time-
subtraction. If the LHS and RHS of the equation are both date time parameters then the return value will be a numerical value with the number of seconds difference between the two provided dates. If the LHS is a date time and the RHS is a numerical parameter then the return value will be a new date time with the number of seconds from the RHS subtracted from the LHS date time
String concatenation
If the return types of the LHS and RHS of the +
operator do not match then operator will return a string containing the concatenation of the two values. For example 1 + "test"
will return "1test"
.
Constant values
Constant values can be defined in an expression:
- numerical: type a number, e.g.
1.23
- string: type some text surrounded by double-quotes, e.g.
"test"
- boolean: type either
true
orfalse
Keywords
The following keywords are available
null
: mainly used in a boolean comparison to check if a parameter is set, e.g.FrontSpring != null
this
: represents the current scope
Scopes
The scope is an important concept to be aware of when writing a math expression. The scope defines what entity the math expression is referencing. If you are writing a math expression in a math parameter in a setup definition, then that setup definition is the current scope. You can access any parameters on that setup directly by typing the parameter name. To change scope and access a parameter from a different entity the dot-notation is used. Again using the setup as an example, to reference a parameter from the related event you would type Event.
and then a list of parameters defined in the event definition will be available in the auto update
You can join as many scope changes together, for example writing Event.Championship.Name
would let you access the championship name from a setup. The auto complete normally lets you find the correct scope for anything you need, but the data model documentation provides a full overview of the software.
Unit Management
Whenever a numerical parameter with a dimension and unit defined is accessed, a unit conversion can be performed to change the returned unit. This is done using square brackets, for example mCornerFL["kg"]
. A list of all available dimensions and units can be found in the units documentation.
Function Reference
This section lists all functions that are available to be used in math expressions.
Numerical Functions
Abs
Abs(double) | Returns the absolute value of the supplied number. |
Abs(double value)
Returns the absolute value of the supplied number.
Parameters
double
value A number that is greater than or equal to Decimal.MinValue, but less than or equal to Decimal.MaxValue.Returns
double
A decimal number, x, such that 0 ≤ x ≤ Decimal.MaxValue.Examples
Abs(-2.3) // Returns 2.3
ACos
ACos(double) | Returns the angle whose cosine is the specified number. |
ACos(double value)
Returns the angle whose cosine is the specified number.
Parameters
double
value A number representing a cosine, where value must be greater than or equal to -1, but less than or equal to 1.Returns
double
An angle, θ, measured in radians, such that 0 ≤ θ ≤ π.Examples
ACos(1) // Returns 0
ACos(0) // Returns Math.PI/2
ASin
ASin(double) | Returns the angle whose sine is the specified number. |
ASin(double value)
Returns the angle whose sine is the specified number.
Parameters
double
value A number representing a sine, where value must be greater than or equal to -1, but less than or equal to 1.Returns
double
An angle, θ, measured in radians, such that -π/2 ≤ θ ≤ π/2.Examples
ASin(0) // Returns 0
ASin(1) // Returns Math.PI/2
ATan
ATan(double) | Returns the angle whose tangent is the specified number. |
ATan(double value)
Returns the angle whose tangent is the specified number.
Parameters
double
value A number representing a tangent.Returns
double
An angle, θ, measured in radians, such that -π/2 ≤ θ ≤ π/2.Examples
ATan(0) // Returns 0
ATan(1) // Returns Math.PI/4
Average
Average(params double[]) | Produces the average value of the entered values. |
Average(params double[] values)
Produces the average value of the entered values.
Parameters
params double[]
values The list of values to average.Returns
double
The average value.Examples
Average(2) // Returns 2
Average(2,3,4,5,6,7,8) // Returns 5
BestX
BestX(List<FlatModel>, double, string, bool, bool) | Calculates the best X quantity of a specified parameter from a collection. |
BestX(List<FlatModel>, double, string, bool, bool, string) | Calculates the best X quantity of a specified parameter from a collection, with the ability to filter the items included in the calculation. |
BestX(List<FlatModel> items, double quantity, string propertyName, bool sortAscending, bool calculateAverage)
Calculates the best X quantity of a specified parameter from a collection.
Parameters
List<FlatModel>
items The items from which the average will be calculated.
double
quantity The quantity to use for the X.
string
propertyName The name of the property that contains the value to be averaged.
bool
sortAscending If true, then the values are sorted in ascending order before the best X quantity values are taken. If false, then the values are sorted in descending order.
bool
calculateAverage Defines whether the function will return the Xth best value from a collection or the average of the best x quantity of items.Returns
double
The best Xth value or the best X quantity average.Examples
BestX(SessionLaps, 0.2, "LapTime", true, true)
BestX(SessionLaps, 0.2, "vMax", false, true)
BestX(List<FlatModel> items, double quantity, string propertyName, bool sortAscending, bool calculateAverage, string conditionPropertyName)
Calculates the best X quantity of a specified parameter from a collection, with the ability to filter the items included in the calculation.
Parameters
List<FlatModel>
items The items from which the average will be calculated.
double
quantity The quantity to use for the X.
string
propertyName The name of the property that contains the value to be averaged.
bool
sortAscending If true, then the values are sorted in ascending order before the best X quantity values are taken. If false, then the values are sorted in descending order.
bool
calculateAverage Defines whether the function will return the Xth best value from a collection or the average of the best x quantity of items.
string
conditionPropertyName The name of the property that returns a boolean specifying if the item should be included in the calculation. If true, the value is included.Returns
double
The best Xth value or the best X quantity average.Examples
BestX(SessionLaps, 0.2, "LapTime", true, true "IncludeInCalculation")
BestXPercent
BestXPercent(List<FlatModel>, double, string, bool, bool) | Calculates the best X% of a specified parameter from a collection. |
BestXPercent(List<FlatModel>, double, string, bool, bool, string) | Calculates the best X% of a specified parameter from a collection, with the ability to filter the items included in the calculation. |
BestXPercent(List<FlatModel> items, double percent, string propertyName, bool sortAscending, bool calculateAverage)
Calculates the best X% of a specified parameter from a collection.
Parameters
List<FlatModel>
items The items from which the average will be calculated.
double
percent The percent to use for the X.
string
propertyName The name of the property that contains the value to be averaged.
bool
sortAscending If true, then the values are sorted in ascending order before the best X% values are taken. If false, then the values are sorted in descending order.
bool
calculateAverage Defines whether the function will return the X% best value from a collection or the average of the best x% quantity of items.Returns
double
The best X% value or the best X% average.Examples
BestXPercent(SessionLaps, 0.2, "LapTime", true, true
BestXPercent(SessionLaps, 0.2, "vMax", false, true
BestXPercent(List<FlatModel> items, double percent, string propertyName, bool sortAscending, bool calculateAverage, string conditionPropertyName)
Calculates the best X% of a specified parameter from a collection, with the ability to filter the items included in the calculation.
Parameters
List<FlatModel>
items The items from which the average will be calculated.
double
percent The percent to use for the X.
string
propertyName The name of the property that contains the value to be averaged.
bool
sortAscending If true, then the values are sorted in ascending order before the best X% values are taken. If false, then the values are sorted in descending order.
bool
calculateAverage Defines whether the function will return the X% best value from a collection or the average of the best x% quantity of items.
string
conditionPropertyName The name of the property that returns a boolean specifying if the item should be included in the calculation. If true, the value is included.Returns
double
The best X% value or the best X% average.Examples
BestXPercent(SessionLaps, 0.2, "LapTime", true, true, "IncludeInCalculation")
Cos
Cos(double) | Returns the cosine of the specified number. |
Cos(double value)
Returns the cosine of the specified number.
Parameters
double
value The number to take the cosine of.Returns
double
The cosine.Examples
Cos(0) // Returns 1
Cos(3.1415926535897931) // Returns -1
Count
Count(List<FlatModel> | List<double>) | Counts the items from a list of values. |
Count(List<FlatModel> | List<double> values)
Counts the items from a list of values.
Parameters
List<FlatModel> | List<double>
values The list to count.Returns
double
The number of items in the list.Examples
Count(SampleCollection1) // Returns the number of items in the collection.
Degrees
Degrees(double) | Converts a number in radians to degrees. |
Degrees(double value)
Converts a number in radians to degrees.
Parameters
double
value The value to convert.Returns
double
The value in degrees.Examples
Degrees(3.1415926535897931) // Returns 180
DoubleToString
DoubleToString(double) | Converts a double to a string. |
DoubleToString(double value)
Converts a double to a string.
Parameters
double
value The double to convert.Returns
string
The double as a string.Examples
DoubleToString(2) // Returns "2"
DoubleToString(2.4) // Returns "2.4"
FirstQuartil
FirstQuartil(List<FlatModel>, string) | Calculates the first quartil of a specified parameter from a collection. |
FirstQuartil(List<FlatModel>, string, string) | Calculates the first quartil of a specified parameter from a collection, with the ability to filter the items included in the calculation. |
FirstQuartil(List<FlatModel> items, string propertyName)
Calculates the first quartil of a specified parameter from a collection.
Parameters
List<FlatModel>
items The items from which the first quartil will be calculated.
string
propertyName The name of the property that contains the value to be calculated.Returns
double
The first quartil.
FirstQuartil(List<FlatModel> items, string propertyName, string conditionPropertyName)
Calculates the first quartil of a specified parameter from a collection, with the ability to filter the items included in the calculation.
Parameters
List<FlatModel>
items The items from which the first quartil will be calculated.
string
propertyName The name of the property that contains the value to be calculated.
string
conditionPropertyName The name of the property that returns a boolean specifying if the item should be included in the calculation. If true, the value is included.Returns
double
The first quartil
Interpolate
Interpolate(List<FlatModel>, string, string, double, bool) | Interpolates a collection of values with a 1D linear interpolation algorithm. |
Interpolate(List<FlatModel>, string, string, string, double, double, bool) | Interpolates a collection of values with a 2D linear interpolation algorithm. |
Interpolate(List<FlatModel> models, string xParameterName, string valueParameterName, double xValue, bool extrapolate)
Interpolates a collection of values with a 1D linear interpolation algorithm.
Parameters
List<FlatModel>
models A list of flat models to build the values to interpolate with.
string
xParameterName The name of the parameter on the flat model to use to build the x variables for interpolation.
string
valueParameterName The name of the parameter on the flat model to interpolate.
double
xValue The x value to interpolate for.
bool
extrapolate Whether to extrapolate or not (in which case it would take the min or max value of valueParameterName).Returns
double
The interpolated value.
Interpolate(List<FlatModel> models, string xParameterName, string yParameterName, string valueParameterName, double xValue, double yValue, bool extrapolate)
Interpolates a collection of values with a 2D linear interpolation algorithm.
Parameters
List<FlatModel>
models A list of flat models to build the values to interpolate with.
string
xParameterName The name of the parameter on the flat model to use to build the x variables for interpolation.
string
yParameterName The name of the parameter on the flat model to use to build the y variables for interpolation.
string
valueParameterName The name of the parameter on the flat model to interpolate.
double
xValue The x value to interpolate for.
double
yValue The y value to interpolate for.
bool
extrapolate Whether to extrapolate or not.Returns
double
The interpolated value.
Length
Length(string) | Returns the length of a supplied string. |
Length(string text)
Returns the length of a supplied string.
Parameters
string
text The string to compute the length of.Returns
double
A non-negative integer representing the length of the string.Examples
Length("test") // Returns 4
Length("test")*2 // Returns 8
LowerWhisker
LowerWhisker(List<FlatModel>, string) | Calculates the lower whisker of a specified parameter from a collection. |
LowerWhisker(List<FlatModel>, string, string) | Calculates the lower whisker of a specified parameter from a collection, with the ability to filter the items included in the calculation. |
LowerWhisker(List<FlatModel> items, string propertyName)
Calculates the lower whisker of a specified parameter from a collection.
Parameters
List<FlatModel>
items The items from which the lower whisker will be calculated.
string
propertyName The name of the property that contains the value to be calculated.Returns
double
The lower whisker.
LowerWhisker(List<FlatModel> items, string propertyName, string conditionPropertyName)
Calculates the lower whisker of a specified parameter from a collection, with the ability to filter the items included in the calculation.
Parameters
List<FlatModel>
items The items from which the lower whisker will be calculated.
string
propertyName The name of the property that contains the value to be calculated.
string
conditionPropertyName The name of the property that returns a boolean specifying if the item should be included in the calculation. If true, the value is included.Returns
double
The lower whisker.
Max
Max(params double[]) | Returns the largest of the specified numbers. |
Max(params double[] values)
Returns the largest of the specified numbers.
Parameters
params double[]
values The numbers to compare.Returns
double
The specified number with the largest value.Examples
Max(-3) // Returns -3
Max(2,3,4,2,-3,-12) // Returns 4
Median
Median(List<FlatModel>, string) | Calculates the median of a specified parameter from a collection. |
Median(List<FlatModel>, string, string) | Calculates the median of a specified parameter from a collection, with the ability to filter the items included in the calculation. |
Median(List<FlatModel> items, string propertyName)
Calculates the median of a specified parameter from a collection.
Parameters
List<FlatModel>
items The items from which the median will be calculated.
string
propertyName The name of the property that contains the value to be calculated.Returns
double
The median.
Median(List<FlatModel> items, string propertyName, string conditionPropertyName)
Calculates the median of a specified parameter from a collection, with the ability to filter the items included in the calculation.
Parameters
List<FlatModel>
items The items from which the median will be calculated.
string
propertyName The name of the property that contains the value to be calculated.
string
conditionPropertyName The name of the property that returns a boolean specifying if the item should be included in the calculation. If true, the value is included.Returns
double
The median.
Min
Min(params double[]) | Returns the smallest of the specified numbers. |
Min(params double[] values)
Returns the smallest of the specified numbers.
Parameters
params double[]
values The numbers to compare.Returns
double
The specified number with the smallest value.Examples
Min(-2,3,5,-9) // Returns -9
Outliers
Outliers(List<FlatModel>, string) | Calculates the outliers of a specified parameter from a collection. |
Outliers(List<FlatModel>, string, string) | Calculates the outliers of a specified parameter from a collection, with the ability to filter the items included in the calculation. |
Outliers(List<FlatModel> items, string propertyName)
Calculates the outliers of a specified parameter from a collection.
Parameters
List<FlatModel>
items
string
propertyName The name of the property that contains the value to be calculated.Returns
List<double>
The outliers.
Outliers(List<FlatModel> items, string propertyName, string conditionPropertyName)
Calculates the outliers of a specified parameter from a collection, with the ability to filter the items included in the calculation.
Parameters
List<FlatModel>
items
string
propertyName The name of the property that contains the value to be calculated.
string
conditionPropertyName The name of the property that returns a boolean specifying if the item should be included in the calculation. If true, the value is included.Returns
List<double>
The outliers.
Pi
Pi() | Returns the constant value of π |
Pi()
Returns the constant value of π
Returns
double
The constant value of π
Power
Power(double, double) | Computes a given number to a given power. |
Power(double value, double power)
Computes a given number to a given power.
Parameters
double
value The base.
double
power The power.Returns
double
The computed double value.Examples
Power(2,2) // Returns 4
Power(4,0.5) // Returns 2
Power(2,-1) // Returns 0.5
Power(-2,2) // Returns 4
Radians
Radians(double) | Converts degrees into radians. |
Radians(double value)
Converts degrees into radians.
Parameters
double
value A number in degrees.Returns
double
A number in radians.Examples
Radians(180) // Returns Math.PI
Round
Round(double, double) | Rounds a value to the nearest integer or to the specified number of fractional digits. |
Round(double value, double decimals)
Rounds a value to the nearest integer or to the specified number of fractional digits.
Parameters
double
value A number to be rounded.
double
decimals The number of fractional digits in the return value.Returns
double
The rounded number. If value has fewer decimal places than decimals, it is returned unchanged.Examples
Round(2.5,2) // Returns 2.5
Round(2.4563,2) // Returns 2.46
Round(-3.454364,0) // Returns -3
Sign
Sign(double) | Returns the arithmetic sign (+1, -1 or 0) of a supplied number. |
Sign(double value)
Returns the arithmetic sign (+1, -1 or 0) of a supplied number.
Parameters
double
value The numerical value to determine the sign of.Returns
double
An integer representing an arithmetic sign (1, -1 or 0).Examples
Sign(1) // Returns 1
Sign(-2) // Returns -1
Sign(0) // Returns 0
Sin
Sin(double) | Returns the sine of the specified number. |
Sin(double value)
Returns the sine of the specified number.
Parameters
double
value The value to take the sine of.Returns
double
The sine.Examples
Sin(0) // Returns 0
Sin(1.5707963267949) // Returns 1
Sqrt
Sqrt(double) | Returns the square root of a specified number. |
Sqrt(double value)
Returns the square root of a specified number.
Parameters
double
value The number whose square root is to be found.Returns
double
The positive square root.Examples
Sqrt(4) // Returns 2
Sum
Sum(List<double>) | Returns the sum of the items in a list. |
Sum(List<double> values)
Returns the sum of the items in a list.
Parameters
List<double>
values The list to sum.Returns
double
The sum of all items supplied.
Tan
Tan(double) | Returns the tangent of the specified number. |
Tan(double value)
Returns the tangent of the specified number.
Parameters
double
value The value to take the tangent of.Returns
double
The tangent.Examples
Tan(0) // Returns 0
ThirdQuartil
ThirdQuartil(List<FlatModel>, string) | Calculates the thirdquartil of a specified parameter from a collection. |
ThirdQuartil(List<FlatModel>, string, string) | Calculates the thirdquartil of a specified parameter from a collection, with the ability to filter the items included in the calculation. |
ThirdQuartil(List<FlatModel> items, string propertyName)
Calculates the thirdquartil of a specified parameter from a collection.
Parameters
List<FlatModel>
items The items from which the third quartil will be calculated.
string
propertyName The name of the property that contains the value to be calculated.Returns
double
The third quartil
ThirdQuartil(List<FlatModel> items, string propertyName, string conditionPropertyName)
Calculates the thirdquartil of a specified parameter from a collection, with the ability to filter the items included in the calculation.
Parameters
List<FlatModel>
items The items from which the third quartil will be calculated.
string
propertyName The name of the property that contains the value to be calculated.
string
conditionPropertyName The name of the property that returns a boolean specifying if the item should be included in the calculation. If true, the value is included.Returns
double
The third quartil.
Truncate
Truncate(double, double) | Truncates a number to the specified number of decimals. |
Truncate(double value, double count)
Truncates a number to the specified number of decimals.
Parameters
double
value The value to truncate.
double
count The number of decimals to truncate to.Returns
double
Either an integer or a double with less than or equal to count decimals.Examples
Truncate(-53.456677,2) // Returns -53.45
Truncate(-53.454677) // Returns -53
UpperWhisker
UpperWhisker(List<FlatModel>, string) | Calculates the upper whisker of a specified parameter from a collection. |
UpperWhisker(List<FlatModel>, string, string) | Calculates the upper whisker of a specified parameter from a collection, with the ability to filter the items included in the calculation. |
UpperWhisker(List<FlatModel> items, string propertyName)
Calculates the upper whisker of a specified parameter from a collection.
Parameters
List<FlatModel>
items The items from which the upper whisker will be calculated.
string
propertyName The name of the property that contains the value to be calculated.Returns
double
The upper whisker.
UpperWhisker(List<FlatModel> items, string propertyName, string conditionPropertyName)
Calculates the upper whisker of a specified parameter from a collection, with the ability to filter the items included in the calculation.
Parameters
List<FlatModel>
items The items from which the upper whisker will be calculated.
string
propertyName The name of the property that contains the value to be calculated.
string
conditionPropertyName The name of the property that returns a boolean specifying if the item should be included in the calculation. If true, the value is included.Returns
double
The upper whisker.
String Manipulation Functions
Concatenate
Concatenate(double | string | bool, params double[] | string[] | bool[]) | Join two or more values into one string. |
Concatenate(double | string | bool value1, params double[] | string[] | bool[] value2)
Join two or more values into one string.
Parameters
double | string | bool
value1 The first string.
params double[] | string[] | bool[]
value2 The second string.Returns
string
The joined string.Examples
Concatenate("test1","-","test2") // Returns "test1-test2"
Concatenate("tes","t") // Returns "test"
Concatenate(null,"-","test2") // Returns "-test2"
Concatenate("test1","-",3) // Returns "test1-3"
GetCurrentUserProperty
GetCurrentUserProperty(string) | Returns the current username. |
GetCurrentUserProperty(string parameter)
Returns the current username.
Parameters
string
parameter The property to retrieve from the user. Either "Username" or "DisplayName".Returns
string
The current username.Examples
GetCurrentUserProperty("Username") // Returns test@hh-dev.com
GetThemeName
GetThemeName() | Returns the name of the current theme of the software on the users' computer. |
GetThemeName()
Returns the name of the current theme of the software on the users' computer.
Returns
string
A string value of either "Light" or "Dark"
Left
Left(string, double) | Returns the first count characters of a string. |
Left(string text, double count)
Returns the first count characters of a string.
Parameters
string
text The string to return characters from.
double
count The number of characters to return. Must be a non-negative integer, and if a value is specified that is greater than the number of characters in the string, the entire string will be returned.Returns
string
A string of the specified characters.Examples
Left("test",3) // Returns "tes"
Lower
Lower(string) | Returns a copy of a string converted to lowercase. |
Lower(string text)
Returns a copy of a string converted to lowercase.
Parameters
string
text The string to operate on.Returns
string
A lowercase stringExamples
Lower("TesT1") // Returns "test1"
Lower("1234") // Returns "1234"
Mid
Mid(string, double, double) | Returns a specified number of characters from the middle of a supplied string. |
Mid(string text, double start, double count)
Returns a specified number of characters from the middle of a supplied string.
Parameters
string
text The string to copy from.
double
start The 0-based index of the first character to copy.
double
count The number of characters to copy.Returns
string
A substring copied from the supplied string.Examples
Mid("test1",2,2) // Returns "st"
Proper
Proper(string) | Converts all characters in a supplied string to proper case. |
Proper(string text)
Converts all characters in a supplied string to proper case.
Parameters
string
text The string to format.Returns
string
A string in proper case.Examples
Proper("tesT1") // Returns "Test1"
Replace
Replace(string, double, double, string) | Copies a string and replaces part of it with a new substring. |
Replace(string text, double start, double count, string replacement)
Copies a string and replaces part of it with a new substring.
Parameters
string
text The string to operate on.
double
start The zero-based index of where to start the substitution in the base string.
double
count The number of characters to replace in the base string. If0
, replacement will be inserted immediately before the index specified by start.
string
replacement The substring to replace with.Returns
string
The new string with the substitution.Examples
Replace("test",0,2,"yy") // Returns "yyst"
Replace("01234567",2,5,"Hello") // Returns "01Hello7"
Replace("0123456789",4,0,"Hello") // Returns "0123Hello456789"
Right
Right(string, double) | Returns a specified number of characters from the end of a string. |
Right(string text, double count)
Returns a specified number of characters from the end of a string.
Parameters
string
text The string to copy from.
double
count The number of characters to return.Returns
string
The specified substring.Examples
Right("test",3) // Returns "est"
StringToDateTime
StringToDateTime(string, string, string) | Returns a DateTime from the input string. |
StringToDateTime(string dateTime, string timeZone, string pattern)
Returns a DateTime from the input string.
Parameters
string
dateTime The string to parse.
string
timeZone The timezone to return.
string
pattern The pattern datetime is expressed in.Returns
DateTime
The parsed DateTime.Examples
StringToDateTime("2020-01-24 13:41", "America/Argentina/Buenos_Aires", "yyyy-MM-dd HH:mm")
StringToDouble
StringToDouble(string) | Parses a double from a string. |
StringToDouble(string text)
Parses a double from a string.
Parameters
string
text The string to parse. Commas and dots both work as decimal separators. There may not be any other separators (e.g. "10,000" is parsed as 10, not 10000).Returns
double
The parsed double.Examples
StringToDouble("3.5") // Returns 3.5
StringToDouble("3,5") // Returns 3.5
StripLetters
StripLetters(string) | Removes all letter characters and whitespace from a string. |
StripLetters(string text)
Removes all letter characters and whitespace from a string.
Parameters
string
text Value to strip fromReturns
string
The stripped string.Examples
StripLetters("Run 1") // Returns "1"
Substitute
Substitute(string, string, string) | Finds and substitues text in a string. |
Substitute(string text, string old_Text, string new_Text)
Finds and substitues text in a string.
Parameters
string
text The base string to search.
string
old_Text The substring to replace in text.
string
new_Text The string to replace old_text with.Returns
string
The new string.Examples
Substitute("test1","1","2") // Returns "test2"
TextJoin
TextJoin(string, bool, params string[]) | Joins a series of strings with a delimiter. |
TextJoin(string delimiter, bool ignore_Empty, params string[] strings)
Joins a series of strings with a delimiter.
Parameters
string
delimiter The delimiter to insert between strings.
bool
ignore_Empty Whentrue
, if a string is empty, it will be ignored. Useful to avoid having two consecutive delimiters.
params string[]
strings The strings to join. Any number >1 of strings can be supplied.Returns
string
The new joined string.Examples
TextJoin("-",false,"Test1","Test2") // Returns "Test1-Test2"
TextJoin("-",true,"Test1","Test2","","Test3") // Returns "Test1-Test2-Test3"
ToString
ToString(double | string | bool | JsonElement) | Converts the input to a string. |
ToString(double | string | bool | JsonElement value)
Converts the input to a string.
Parameters
double | string | bool | JsonElement
value The value to convert to a string.Returns
string
The converted string.Examples
ToString(3) // Returns "3"
ToString(true) // Returns "True"
Upper
Upper(string) | Returns a copy of this string converted to uppercase. |
Upper(string text)
Returns a copy of this string converted to uppercase.
Parameters
string
text The string to convert to uppercase.Returns
string
The uppercase equivalent of the current string.Examples
Upper("test1") // Returns "TEST1"
Logical Functions
FirstNotNull
FirstNotNull(params double[] | string[] | bool[] | DateTime[] | FlatModel[] | List<FlatModel>[] | List<double>[] | List<string>[] | JsonElement[] | List<bool>[]) | Returns the first parameter that is not null from a list of parameters. |
FirstNotNull(params double[] | string[] | bool[] | DateTime[] | FlatModel[] | List<FlatModel>[] | List<double>[] | List<string>[] | JsonElement[] | List<bool>[] values)
Returns the first parameter that is not null from a list of parameters.
Parameters
params double[] | string[] | bool[] | DateTime[] | FlatModel[] | List<FlatModel>[] | List<double>[] | List<string>[] | JsonElement[] | List<bool>[]
values The parameters to search.Returns
double
The first parameter that is not null.Examples
FirstNotNull(2.5, 2.3) // Returns 2.5
FirstNotNull(Car.Color, "#FF0000") // Returns Car.Color if it is defined, otherwise "#FF0000" will be returned
GetPropertyValue
GetPropertyValue(Part, string, Type) | Returns a PartProperty from a Part. Allows for dynamic part property access. |
GetPropertyValue(Part part, string parameter, Type type)
Returns a PartProperty from a Part. Allows for dynamic part property access.
Parameters
Part
part The part to access.
string
parameter The name of the property on the part.
Type
type The type the specified property will return.Returns
double
The found PartProperty of the specified type.Examples
GetPropertyValue(SpringFL,"Rate","double") // Returns the double value of the property "SpringFL.Rate"
GetPropertyValue(ARBFront,Concatenate("kArb_",PosFL.Name,"_",ARBPosFR.Name),"double") // Returns ARBFront.kArb_1_1 if ARBPosFL & FR are equal to "1".
If
If(bool, double | string | bool | DateTime | FlatModel | List<FlatModel> | List<double> | List<string> | JsonElement | List<bool>, double | string | bool | DateTime | FlatModel | List<FlatModel> | List<double> | List<string> | JsonElement | List<bool>) | Returns the second parameter if the first is true, and the third if the first parameter is false. |
If(bool condition, double | string | bool | DateTime | FlatModel | List<FlatModel> | List<double> | List<string> | JsonElement | List<bool> trueValue, double | string | bool | DateTime | FlatModel | List<FlatModel> | List<double> | List<string> | JsonElement | List<bool> falseValue)
Returns the second parameter if the first is true, and the third if the first parameter is false.
Parameters
bool
condition Condition determining which parameter is returned
double | string | bool | DateTime | FlatModel | List<FlatModel> | List<double> | List<string> | JsonElement | List<bool>
trueValue Parameter to return if the first is true
double | string | bool | DateTime | FlatModel | List<FlatModel> | List<double> | List<string> | JsonElement | List<bool>
falseValue Parameter to return if the first is false.Returns
double
The second parameter if the first is true, and the third if the first parameter is false.Examples
If(1>0,"Correct","Incorrect") // Returns "Correct"
IsNull
IsNull(double | string | bool | DateTime | FlatModel) | Returns true if the input value is null and false otherwise. |
IsNull(double | string | bool | DateTime | FlatModel value)
Returns true if the input value is null and false otherwise.
Parameters
double | string | bool | DateTime | FlatModel
value The value to validate.Returns
bool
A boolean value indicating if the input is null or not.Examples
IsNull("") // Returns true
IsNull(2) // Returns false
IsNull(2+5) // Returns false
Date Time Functions
DateTimeToString
DateTimeToString(DateTime, string) | Formats a DateTime as a string using the provided format. |
DateTimeToString(DateTime dateTime, string format)
Formats a DateTime as a string using the provided format.
Parameters
DateTime
dateTime The DateTime to format.
string
format The string to format with.Returns
string
The formatted string.Examples
DateTimeToString(Event.StartTime,"yyyy") // Returns 2024
DateTimeToString(Event.StartTime,"yy-MM-dd") // Returns "24-01-28"
DateTimeToString(Event.StartTime,"ddd, MMM dd, yyyy") // Returns "Sun, Jan 28, 2024"
Now
Now() | Returns an Instant representing the exact time the function is called in UTC. |
Now(string) | Returns an Instant representing the exact time the function is called in the specified timezone. |
Now()
Returns an Instant representing the exact time the function is called in UTC.
Returns
DateTime
The Instant representing the exact time the function is called.
Now(string timeZone)
Returns an Instant representing the exact time the function is called in the specified timezone.
Parameters
string
timeZone The timezone the returned Instant is expressed inReturns
DateTime
The Instant representing the exact time the function is called.
Flat Model Functions
CalculateChanges
CalculateChanges(FlatModel, FlatModel) | Returns a string that lists the differences between two flat models. The output of this function is impacted by any applicable Change Formatter that is defined. |
CalculateChanges(FlatModel initial, FlatModel current)
Returns a string that lists the differences between two flat models. The output of this function is impacted by any applicable Change Formatter that is defined.
Parameters
FlatModel
initial The first flat model.
FlatModel
current The second flat model.Returns
string
The string listing the differences.Examples
CalculateChanges(Previous,this) // Returns "Setup Double 1: 1.1 to 1\r\nSetup Double 2: 2.2 to 2\r\nSetup Double 3: 3.3 to <not set>"
GetMeasurement
GetMeasurement(List<FlatModel>, DateTime) | Returns the last measurement before the passed in datetime |
GetMeasurement(List<FlatModel>, string) | Returns the last measurement before the passed in datetime |
GetMeasurement(List<FlatModel> measurements, DateTime dateTime)
Returns the last measurement before the passed in datetime
Parameters
List<FlatModel>
measurements The assembly iteration or part item measurements
DateTime
dateTime Datetime that is used to search for the last measurement for that valueReturns
FlatModel
An assembly iteration or part item measurementExamples
GetMeasurement(SpringFLPartItem.PartItemMeasurements, Event.StartDate).Stiffness // Returns The value of the Stiffness parameter of the last part item measurement, before the start of the event
GetMeasurement(List<FlatModel> measurements, string dateTimeText)
Returns the last measurement before the passed in datetime
Parameters
List<FlatModel>
measurements The assembly iteration or part item measurements
string
dateTimeText Datetime that is used to search for the last measurement for that valueReturns
FlatModel
An assembly iteration or part item measurementExamples
GetMeasurement(SpringFLPartItem.PartItemMeasurements, "2024-01-24 13:41").Stiffness // Returns The value of the Stiffness parameter of the last part item measurement, before "2024-01-24 13:41"
Lookup
Lookup(List<FlatModel>, string, double | string | bool) | Finds a flat model in a given collection based on the target property. |
Lookup(List<FlatModel> collection, string targetPropertyName, double | string | bool targetValue)
Finds a flat model in a given collection based on the target property.
Parameters
List<FlatModel>
collection The collection to search.
string
targetPropertyName The target property name.
double | string | bool
targetValue The target property value to look for.Returns
FlatModel
The flat model, if found.Examples
Lookup(Event.Championship.Account.BrakeSets, "Id", NBrakeSetFrontID) // Returns The first brake set found with an "Id" equivalent to the value stored in "NBrakeSetFrontID"
Select
Select(List<FlatModel>, string) | Return a list of property values from a collection of flat models. |
Select(List<FlatModel> collection, string targetPropertyName)
Return a list of property values from a collection of flat models.
Parameters
List<FlatModel>
collection The collection to iterate over.
string
targetPropertyName The property name to return from each flat model.Returns
List<double>
A list with the same number of items as collection containing the property values found on each respective item.
Where
Where(List<FlatModel>, string) | Return a collection filtered by the designated property name where it is equal to true. |
Where(List<FlatModel> collection, string targetBooleanPropertyName)
Return a collection filtered by the designated property name where it is equal to true.
Parameters
List<FlatModel>
collection The collection to filter.
string
targetBooleanPropertyName The property name to evaluate for true to filter the input collection.Returns
List<FlatModel>
A list of the collection items where the defined property is equal to true.Examples
Where(SessionLaps, "IncludeInCalculations")
JSON Functions
AddJsonObject
AddJsonObject(JsonElement, string, string) | Adds a new, empty JSON object to the JSON element provided. |
AddJsonObject(JsonElement json, string path, string name)
Adds a new, empty JSON object to the JSON element provided.
Parameters
JsonElement
json The JSON object to add to.
string
path The path to add the new object to.
string
name The name of the new, empty JSON object.Returns
JsonElement
The resultant JSON object.
AddJsonValue
AddJsonValue(JsonElement, string, string, double | string | bool | DateTime) | Adds a value to a JSON object. |
AddJsonValue(JsonElement json, string path, string name, double | string | bool | DateTime value)
Adds a value to a JSON object.
Parameters
JsonElement
json JSON object to add to.
string
path Path to add the new object to.
string
name The name of the new value.
double | string | bool | DateTime
value The new value to add.Returns
JsonElement
The resultant JSON object.
FindJsonObjectFromJsonObjectArray
FindJsonObjectFromJsonObjectArray(JsonElement, string, string, string) | Searches for and returns the first JSON object within a JSON array that matches a specified search criteria. |
FindJsonObjectFromJsonObjectArray(JsonElement jsonElement, string path, string pathToSearch, string valueToFind)
Searches for and returns the first JSON object within a JSON array that matches a specified search criteria.
Parameters
JsonElement
jsonElement The JSON object to search.
string
path The path to the JSON array.
string
pathToSearch The path to the value to check against.
string
valueToFind The value to match.Returns
JsonElement
The found JSON object.
GetBooleanFromJsonElement
GetBooleanFromJsonElement(JsonElement, string) | Extracts a boolean value from an input JSON object, based on the input path. |
GetBooleanFromJsonElement(JsonElement json, string path)
Extracts a boolean value from an input JSON object, based on the input path.
Parameters
JsonElement
json The JSON object to search in.
string
path The path to the boolean value. Supports indices if an item from array is to be retrieved.Returns
bool
The found boolean value.Examples
GetStringFromJsonElement(jsonObject, "Car.FlSuspension.Points.2.IsInboard") // Returns boolean value (e.g. "False")
GetDoubleFromJsonElement
GetDoubleFromJsonElement(JsonElement, string) | Extracts a double value from an input JSON object, based on the input path. |
GetDoubleFromJsonElement(JsonElement json, string path)
Extracts a double value from an input JSON object, based on the input path.
Parameters
JsonElement
json The JSON object to search in.
string
path The path to the double value. Supports indices if an item from array is to be retrieved.Returns
double
The found double value.Examples
GetDoubleFromJsonElement(jsonObject, "Car.FlSuspension.Points.2.Coordinates.X") // Returns double value (e.g. "2.5")
GetJsonFromOtherProfile
GetJsonFromOtherProfile(string, FlatModel) | Returns the JSON from another profile. |
GetJsonFromOtherProfile(string profileName, FlatModel exportScope)
Returns the JSON from another profile.
Parameters
string
profileName Profile name to retrieve from.
FlatModel
exportScope The scope for the export.Returns
JsonElement
The JSON in the other profile.
GetJsonObjectFromJsonElement
GetJsonObjectFromJsonElement(JsonElement, string) | Extracts one JSON object from another JSON object, based on an input path. |
GetJsonObjectFromJsonElement(JsonElement jsonElement, string path)
Extracts one JSON object from another JSON object, based on an input path.
Parameters
JsonElement
jsonElement The parent JSON object.
string
path The path at which the child JSON object is located. The path supports indices if an item from an array is to be retrieved.Returns
string
The found child JSON object.Examples
GetJsonObjectFromJsonElement(jsonObject, "Car.FlSuspension.Points.2.Coordinates") // Returns a JSON object (e.g. { "X": 2.5, "Y": 1 })
GetStringFromJsonElement
GetStringFromJsonElement(JsonElement, string) | Extracts a string value from an input JSON object, based on the input path. |
GetStringFromJsonElement(JsonElement json, string path)
Extracts a string value from an input JSON object, based on the input path.
Parameters
JsonElement
json The JSON object to search in.
string
path The path to the string value. Supports indices if an item from array is to be retrieved.Returns
string
The found string value.Examples
GetStringFromJsonElement(jsonObject, "Car.FlSuspension.Points.2.Coordinates.Comments) // Returns the found "Comments" property.
IsJsonPathValid
IsJsonPathValid(JsonElement, string) | Checks if the provided path is valid in the provided JsonElement. |
IsJsonPathValid(JsonElement json, string path)
Checks if the provided path is valid in the provided JsonElement.
Parameters
JsonElement
json The JSON object to validate against.
string
path The path to validate.Returns
bool
A boolean indicating whether the path is valid or not.
ParseJson
ParseJson(string) | Parses the provided string and returns the parsed string as a JSON object. |
ParseJson(string json)
Parses the provided string and returns the parsed string as a JSON object.
Parameters
string
json The string to parse to JSON.Returns
JsonElement
The parsed JSON object.Examples
ParseJson(ReadAttachedFile(FrontSpring, "SpringData")) // Returns the parsed attached JSON file
SelectBooleanFromJsonObjectArray
SelectBooleanFromJsonObjectArray(JsonElement, string, string) | Extracts a list of boolean values from objects in an array within the input JSON object, based on an input path. |
SelectBooleanFromJsonObjectArray(JsonElement json, string path, string propertyToSelect)
Extracts a list of boolean values from objects in an array within the input JSON object, based on an input path.
Parameters
JsonElement
json The base JSON object.
string
path The path the list can be found at in the json object.
string
propertyToSelect The property name to return from each item in the list at path.Returns
List<bool>
A list of booleans of the same length as the list found at path containing the values of PropertyToSelect.Examples
SelectBooleanFromJsonObjectArray(jsonObject, "Car.FlSuspension.Points", "IsValid") // Returns A list containing the values of the "IsValid" property on each item in the "Car.FlSuspension.Points" list in the base JSON object.
SelectDoubleFromJsonObjectArray
SelectDoubleFromJsonObjectArray(JsonElement, string, string) | Extracts a list of boolean values from objects in an array within the input JSON object, based on an input path. |
SelectDoubleFromJsonObjectArray(JsonElement json, string path, string propertyToSelect)
Extracts a list of boolean values from objects in an array within the input JSON object, based on an input path.
Parameters
JsonElement
json The base JSON object.
string
path The path the list can be found at in the json object.
string
propertyToSelect The property name to return from each item in the list at path.Returns
List<double>
A list of doubles of the same length as the list found at path containing the values of PropertyToSelect.Examples
SelectDoubleFromJsonObjectArray(jsonObject, "Car.FlSuspension.Points", "Distance") // Returns A list containing the values of the "Distance" property on each item in the "Car.FlSuspension.Points" list in the base JSON object.
SelectStringFromJsonObjectArray
SelectStringFromJsonObjectArray(JsonElement, string, string) | Extracts a list of string values from objects in an array within the input JSON object, based on an input path. |
SelectStringFromJsonObjectArray(JsonElement json, string path, string propertyToSelect)
Extracts a list of string values from objects in an array within the input JSON object, based on an input path.
Parameters
JsonElement
json The base JSON object.
string
path The path the list can be found at in the json object.
string
propertyToSelect The property name to return from each item in the list at path.Returns
List<string>
A list of strings of the same length as the list found at path containing the values of PropertyToSelect.Examples
SelectStringFromJsonObjectArray(jsonObject, "Car.FlSuspension.Points", "Name") // Returns A list containing the values of the "Name" property on each item in the "Car.FlSuspension.Points" list in the base JSON object.
SubstituteJsonValue
SubstituteJsonValue(JsonElement, string, double | string | bool | JsonElement, bool) | Replace a specified item in a JSON object. |
SubstituteJsonValue(JsonElement, string, double, bool, string) | Replace a specified item in a JSON object with formatting applied. |
SubstituteJsonValue(JsonElement json, string path, double | string | bool | JsonElement newValue, bool ignoreNull)
Replace a specified item in a JSON object.
Parameters
JsonElement
json The base JSON object.
string
path The path to the element to replace.
double | string | bool | JsonElement
newValue The new value.
bool
ignoreNull Whether to substitue newValue if it isnull
or not. Iffalse
, and newValue evaluates tonull
, nothing will be done.Returns
JsonElement
The resultant JSON object.
SubstituteJsonValue(JsonElement json, string path, double newValue, bool ignoreNull, string formatString)
Replace a specified item in a JSON object with formatting applied.
Parameters
JsonElement
json The base JSON object.
string
path The path to the element to replace.
double
newValue The new value.
bool
ignoreNull Whether to substitue newValue if it isnull
or not. Iffalse
, and newValue evaluates tonull
, nothing will be done.
string
formatString If newValue is adouble
, this format string will be applied to it before substituting.Returns
JsonElement
The resultant JSON object.
Attached File Functions
AttachedFileExists
AttachedFileExists(FlatModel, string) | Searches for an attached file on a flat model, returns true if there is a file specified with the given name on the specified entity. |
AttachedFileExists(FlatModel model, string attachedFileName)
Searches for an attached file on a flat model, returns true if there is a file specified with the given name on the specified entity.
Parameters
FlatModel
model The flat model the attached file property belongs to.
string
attachedFileName The name of the attached file property to look for.Returns
bool
A boolean representing whether there is a file attached or not.Examples
AttachedFileExists(FrontSpring, "SpringData") // Returns true if the file exists, false otherwise.
NumberOfAttachedFiles
NumberOfAttachedFiles(FlatModel, string) | Returns the number of files in a group of attached files. |
NumberOfAttachedFiles(FlatModel model, string attachedFileGroupName)
Returns the number of files in a group of attached files.
Parameters
FlatModel
model
string
attachedFileGroupName The name of the attached file group.Returns
double
Examples
NumberOfAttachedFiles(this, "AttachedFileGroup")
ReadAttachedFile
ReadAttachedFile(FlatModel, string) | Reads the contents of an attached file on a flat model and returns the contents as a string. Cannot be used on an attached file property that allows multiple files. |
ReadAttachedFile(FlatModel model, string attachedFileName)
Reads the contents of an attached file on a flat model and returns the contents as a string. Cannot be used on an attached file property that allows multiple files.
Parameters
FlatModel
model The flat model that contains the attached file property.
string
attachedFileName The name of the attached file property.Returns
string
The read file as a string.Examples
ReadAttachedFile(FrontSpring, "SpringData") // Returns the contents of the "SpringData" file, if any exists.