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.
Accessing items in a list
Items in a list can be accessed using their zero-based position in the list surrounded by square brackets [].
For example:
Event.TestEventCollection[0]
Returns the first item in the "TestEventCollection" collection.
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
trueorfalse
Keywords
The following keywords are available
null: mainly used in a boolean comparison to check if a parameter is set, e.g.FrontSpring != nullthis: 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
doublevalue A number that is greater than or equal to Decimal.MinValue, but less than or equal to Decimal.MaxValue.Returns
doubleA 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
doublevalue A number representing a cosine, where value must be greater than or equal to -1, but less than or equal to 1.Returns
doubleAn 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
doublevalue A number representing a sine, where value must be greater than or equal to -1, but less than or equal to 1.Returns
doubleAn 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
doublevalue A number representing a tangent.Returns
doubleAn 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
doubleThe 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.
doublequantity The quantity to use for the X.
stringpropertyName The name of the property that contains the value to be averaged.
boolsortAscending 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.
boolcalculateAverage Defines whether the function will return the Xth best value from a collection or the average of the best x quantity of items.Returns
doubleThe 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.
doublequantity The quantity to use for the X.
stringpropertyName The name of the property that contains the value to be averaged.
boolsortAscending 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.
boolcalculateAverage Defines whether the function will return the Xth best value from a collection or the average of the best x quantity of items.
stringconditionPropertyName 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
doubleThe 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.
doublepercent The percent to use for the X.
stringpropertyName The name of the property that contains the value to be averaged.
boolsortAscending 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.
boolcalculateAverage Defines whether the function will return the X% best value from a collection or the average of the best x% quantity of items.Returns
doubleThe 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.
doublepercent The percent to use for the X.
stringpropertyName The name of the property that contains the value to be averaged.
boolsortAscending 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.
boolcalculateAverage Defines whether the function will return the X% best value from a collection or the average of the best x% quantity of items.
stringconditionPropertyName 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
doubleThe 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
doublevalue The number to take the cosine of.Returns
doubleThe 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
doubleThe 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
doublevalue The value to convert.Returns
doubleThe 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
doublevalue The double to convert.Returns
stringThe 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.
stringpropertyName The name of the property that contains the value to be calculated.Returns
doubleThe 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.
stringpropertyName The name of the property that contains the value to be calculated.
stringconditionPropertyName 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
doubleThe 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.
stringxParameterName The name of the parameter on the flat model to use to build the x variables for interpolation.
stringvalueParameterName The name of the parameter on the flat model to interpolate.
doublexValue The x value to interpolate for.
boolextrapolate Whether to extrapolate or not (in which case it would take the min or max value of valueParameterName).Returns
doubleThe interpolated value.Examples
Interpolate(Engine.BoostCollection, "rpm", "pBoost", 6300, true)
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.
stringxParameterName The name of the parameter on the flat model to use to build the x variables for interpolation.
stringyParameterName The name of the parameter on the flat model to use to build the y variables for interpolation.
stringvalueParameterName The name of the parameter on the flat model to interpolate.
doublexValue The x value to interpolate for.
doubleyValue The y value to interpolate for.
boolextrapolate Whether to extrapolate or not.Returns
doubleThe interpolated value.Examples
Interpolate(RearWing.AeroBalanceCollection, "frh", "rrh", "ab", RideHeightFront, RideHeightRear, true)
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.
stringpropertyName The name of the property that contains the value to be calculated.Returns
doubleThe 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.
stringpropertyName The name of the property that contains the value to be calculated.
stringconditionPropertyName 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
doubleThe 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
doubleThe 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.
stringpropertyName The name of the property that contains the value to be calculated.Returns
doubleThe 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.
stringpropertyName The name of the property that contains the value to be calculated.
stringconditionPropertyName 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
doubleThe 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
doubleThe 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
stringpropertyName 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
stringpropertyName The name of the property that contains the value to be calculated.
stringconditionPropertyName 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
doubleThe 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
doublevalue The base.
doublepower The power.Returns
doubleThe 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
doublevalue A number in degrees.Returns
doubleA 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
doublevalue A number to be rounded.
doubledecimals The number of fractional digits in the return value.Returns
doubleThe 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
doublevalue The numerical value to determine the sign of.Returns
doubleA value 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
doublevalue The value to take the sine of.Returns
doubleThe 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
doublevalue The number whose square root is to be found.Returns
doubleThe 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
doubleThe 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
doublevalue The value to take the tangent of.Returns
doubleThe 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.
stringpropertyName The name of the property that contains the value to be calculated.Returns
doubleThe 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.
stringpropertyName The name of the property that contains the value to be calculated.
stringconditionPropertyName 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
doubleThe third quartil.
Truncate
| Truncate(double, double) | Truncates a number to the specified number of decimals. |
| Truncate(double) | Truncates a number to 0 decimal places. |
Truncate(double value, double count)
Truncates a number to the specified number of decimals.
Parameters
doublevalue The value to truncate.
doublecount The number of decimals to truncate to.Returns
doubleA number with less than or equal to count decimals.Examples
Truncate(-53.456677,2) // Returns -53.45
Truncate(-53.454677) // Returns -53
Truncate(double value)
Truncates a number to 0 decimal places.
Parameters
doublevalue The value to truncate.Returns
doubleA number with no decimal places.
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.
stringpropertyName The name of the property that contains the value to be calculated.Returns
doubleThe 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.
stringpropertyName The name of the property that contains the value to be calculated.
stringconditionPropertyName 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
doubleThe 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 | boolvalue1 The first string.
params double[] | string[] | bool[]value2 The second string.Returns
stringThe 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
stringparameter The property to retrieve from the user. Either "Username" or "DisplayName".Returns
stringThe 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
stringA 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
stringtext The string to return characters from.
doublecount 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
stringA string of the specified characters.Examples
Left("test",3) // Returns "tes"
Length
| Length(string) | Returns the length of a supplied string. |
Length(string text)
Returns the length of a supplied string.
Parameters
stringtext The string to compute the length of.Returns
doubleA non-negative integer representing the length of the string.Examples
Length("test") // Returns 4
Length("test")*2 // Returns 8
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
stringtext The string to operate on.Returns
stringA 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
stringtext The string to copy from.
doublestart The 0-based index of the first character to copy.
doublecount The number of characters to copy.Returns
stringA 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
stringtext The string to format.Returns
stringA 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
stringtext The string to operate on.
doublestart The zero-based index of where to start the substitution in the base string.
doublecount The number of characters to replace in the base string. If0, replacement will be inserted immediately before the index specified by start.
stringreplacement The substring to replace with.Returns
stringThe 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
stringtext The string to copy from.
doublecount The number of characters to return.Returns
stringThe 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
stringdateTime The string to parse.
stringtimeZone The timezone to return.
stringpattern The pattern datetime is expressed in.Returns
DateTimeThe 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
stringtext 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
doubleThe 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
stringtext Value to strip fromReturns
stringThe 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
stringtext The base string to search.
stringold_Text The substring to replace in text.
stringnew_Text The string to replace old_text with.Returns
stringThe 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
stringdelimiter The delimiter to insert between strings.
boolignore_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
stringThe 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 | JsonElementvalue The value to convert to a string.Returns
stringThe 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
stringtext The string to convert to uppercase.Returns
stringThe 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
doubleThe 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
Partpart The part to access.
stringparameter The name of the property on the part.
Typetype The type the specified property will return.Returns
doubleThe 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
boolcondition 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
doubleThe 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 | FlatModelvalue The value to validate.Returns
boolA 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
DateTimedateTime The DateTime to format.
stringformat The string to format with.Returns
stringThe 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
DateTimeThe 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
stringtimeZone The timezone the returned Instant is expressed inReturns
DateTimeThe 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
FlatModelinitial The first flat model.
FlatModelcurrent The second flat model.Returns
stringThe 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
DateTimedateTime Datetime that is used to search for the last measurement for that valueReturns
FlatModelAn 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
stringdateTimeText Datetime that is used to search for the last measurement for that valueReturns
FlatModelAn 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 the first flat model in a collection where the target property matches a specified value. |
Lookup(List<FlatModel> collection, string targetPropertyName, double | string | bool targetValue)
Finds the first flat model in a collection where the target property matches a specified value.
Parameters
List<FlatModel>collection The collection to search.
stringtargetPropertyName The target property name.
double | string | booltargetValue The target property value to look for.Returns
FlatModelThe 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"
LookupClosest
| LookupClosest(List<FlatModel>, string, double | DateTime) | Finds the flat model in a collection where the target property is closest to a specified value. |
LookupClosest(List<FlatModel> closest, string targetPropertyName, double | DateTime targetValue)
Finds the flat model in a collection where the target property is closest to a specified value.
Parameters
List<FlatModel>closest The collection to search.
stringtargetPropertyName The target property name.
double | DateTimetargetValue The target property value to look for.Returns
FlatModelThe flat model, if found.
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.
stringtargetPropertyName 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.
stringtargetBooleanPropertyName 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
JsonElementjson The JSON object to add to.
stringpath The path to add the new object to.
stringname The name of the new, empty JSON object.Returns
JsonElementThe 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
JsonElementjson JSON object to add to.
stringpath Path to add the new object to.
stringname The name of the new value.
double | string | bool | DateTimevalue The new value to add.Returns
JsonElementThe 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
JsonElementjsonElement The JSON object to search.
stringpath The path to the JSON array.
stringpathToSearch The path to the value to check against.
stringvalueToFind The value to match.Returns
JsonElementThe 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
JsonElementjson The JSON object to search in.
stringpath The path to the boolean value. Supports indices if an item from array is to be retrieved.Returns
boolThe 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
JsonElementjson The JSON object to search in.
stringpath The path to the double value. Supports indices if an item from array is to be retrieved.Returns
doubleThe 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
stringprofileName Profile name to retrieve from.
FlatModelexportScope The scope for the export.Returns
JsonElementThe 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
JsonElementjsonElement The parent JSON object.
stringpath 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
stringThe 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
JsonElementjson The JSON object to search in.
stringpath The path to the string value. Supports indices if an item from array is to be retrieved.Returns
stringThe 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
JsonElementjson The JSON object to validate against.
stringpath The path to validate.Returns
boolA 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
stringjson The string to parse to JSON.Returns
JsonElementThe 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
JsonElementjson The base JSON object.
stringpath The path the list can be found at in the json object.
stringpropertyToSelect 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
JsonElementjson The base JSON object.
stringpath The path the list can be found at in the json object.
stringpropertyToSelect 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
JsonElementjson The base JSON object.
stringpath The path the list can be found at in the json object.
stringpropertyToSelect 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
JsonElementjson The base JSON object.
stringpath The path to the element to replace.
double | string | bool | JsonElementnewValue The new value.
boolignoreNull Whether to substitue newValue if it isnullor not. Iffalse, and newValue evaluates tonull, nothing will be done.Returns
JsonElementThe 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
JsonElementjson The base JSON object.
stringpath The path to the element to replace.
doublenewValue The new value.
boolignoreNull Whether to substitue newValue if it isnullor not. Iffalse, and newValue evaluates tonull, nothing will be done.
stringformatString If newValue is adouble, this format string will be applied to it before substituting.Returns
JsonElementThe 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
FlatModelmodel The flat model the attached file property belongs to.
stringattachedFileName The name of the attached file property to look for.Returns
boolA 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
FlatModelmodel
stringattachedFileGroupName The name of the attached file group.Returns
doubleExamples
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
FlatModelmodel The flat model that contains the attached file property.
stringattachedFileName The name of the attached file property.Returns
stringThe read file as a string.Examples
ReadAttachedFile(FrontSpring, "SpringData") // Returns the contents of the "SpringData" file, if any exists.