-
Notifications
You must be signed in to change notification settings - Fork 1
CharacterCount
jdubs edited this page Oct 21, 2016
·
1 revision
Returns the number of instances of a particular character or character set.
SpecName (constant) The name of the variable for operation result assignment
Text (multiple) The variable containing the text to examine in the count operation
CharacterToFind (constant) The variable containing the text to find and count in the text
StartPosition (multiple) The starting position index in the text to begin searching. Default value is 0.
ErrorMessage (multiple | optional) The error message to return when any error occurs.
Counts the number of instances of the CharacterToFind input in the Text input then returns the result to a defined variable which may be used in other defined actions.
public static void CharacterCount(string SpecName, object Text, object CharacterToFind, object StartPosition, object ErrorMessage)
{
Break();
try
{
var begin = ((string)Text).Length;
var end = ((string)Text).Replace((string)CharacterToFind, String.Empty).Length;
var result = begin - end;
Variable(SpecName).Value = result.ToString();
}
catch (Exception ex)
{
throw new Four51ActionsException(ex.Message, (string)ErrorMessage);
}
}