Mixly Block Category - Text
Input a sequence of characters. Used to assign text to a String value type or as an input parameter that accepts String objects.
Input a character. Used to assign a character to a Char value type or as an input parameter that accepts Char objects.
Read more here: https://www.arduino.cc/en/Reference/Char
String Combination (Concatenation)
Appends the second input to the end of the first input. Then returns the resulting String. Inputs can either be user input (direct characters) or variables that are the String data type.
Example: ["abc" join "def"] will return "acbdef"
Read more here: https://www.arduino.cc/en/Tutorial/StringAdditionOperator
String to Number Datatype
Converts the String input (user input or String variable) into a numeric data type (Integer or Float) and returns it.
- toInt - Converts the input String into an Integer (int) data type.
- toFloat - Converts the input String into a Float (float) data type.
Example 1: [toInt "7.11"] returns 7 of int data type.
Example 2: [toFloat "7.11"] returns 7.11 of float data type
Note: Did you know that in the examples above that "7.11" is of data type String? Which is just a sequence of characters( 7, ., 1, 1).
Read more here: https://www.arduino.cc/en/Reference/StringToInt , https://www.arduino.cc/en/Tutorial/StringToIntExample , https://www.arduino.cc/en/Reference/StringToFloat , https://www.arduino.cc/en/Tutorial/StringToFloatExample
Numberic Datatype to String
Converts the input number to a String and returns it. Input can be a user value or in a numeric data type (int, float, double) variable.
Read more here: https://www.arduino.cc/en/Reference/StringConstructor
Returns the length (number of characters) of the input String. Input can either be a direct user String or a variable that is a String.
Example 1: [length of "hello"] will return 5.
Example 2: var is a String variable that contains "6chars". [length of var] will return 6.
Read more here: https://www.arduino.cc/en/Reference/StringLength
Character Access in String
Return the Character in the String at the Index number. Each String object starts at index 0. Therefore, the first Character of a String is indexed at 0. If a String is of length 10. The last index is 9.
- Input String - User input string or a variable of String type. This is the String that the block will look accessible the Character at Index Number from.
- Index Number - The index number that this block will return the Character from the Input String.
Example: If the String is "Hello!". The Characters and their Indexing is shown below. The size of the String is 6.
- To access the first character H would be ["Hello!" char at 0].
- To access the character e would be ["Hello!" char at 1].
- To access the character o would be ["Hello!" char at 4].
- To access the last character ! would be ["Hello!" char at 5]. Note: 5 = 6 (size of the String) - 1
Read more here: https://www.arduino.cc/en/Reference/StringCharAt
String Content Comparison
There are several operations for comparisons between two Strings. Inputs can either be user String inputs or a String data type variable. If the statement is correct a boolean true is returned. If incorrect a boolean false is returned.
equals - Checks if the two input Strings are equals. That is, the two Strings are exactly identical.
Example 1: ["abcdef" equals "abcdef"] returns true
Example 2: ["abcdef" equals "abcde"] returns false
Example 3: ["abcdef" equals "bcdef"] returns false
Read more here: https://www.arduino.cc/en/Reference/StringEquals
startsWith - Checks if the first input String (left) starts with the second input String (right).
Example 1: ["abcdef" startsWith "abcdef"] returns true
Example 2: ["abcdef" startsWith "abcde"] returns true
Example 3: ["abcdef" startsWith "bcdef"] returns false
Read more here: https://www.arduino.cc/en/Reference/StringStartsWith
endsWith - Checks if the first input String (left) ends with the second input String (right).
Example 1: ["abcdef" endsWith "abcdef"] returns true
Example 2: ["abcdef" endsWith "abcde"] returns false
Example 3: ["abcdef" endsWith "bcdef"] returns true
Read more here: https://www.arduino.cc/en/Reference/StringEndsWith
String Order Comparison
This block is used for comparing which of the two input Strings has a greater "value". This is useful for sorting Strings.
Compares two Strings, testing whether one comes before or after the other, or whether they're equal. The strings are compared character by character, using the ASCII values of the characters. That means, for example, that 'a' comes before 'b' but after 'A'. Numbers come before letters.
Read more here: https://www.arduino.cc/en/Reference/StringCompareTo