Difference between revisions of "Mixly Block Category - Text"

From Microduino Wiki
Jump to: navigation, search
(Numberic Datatype to String)
(String Length)
Line 35: Line 35:
  
 
=String Length=
 
=String Length=
 +
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=
 
=Character Access in String=
 
=String Content Comparison=
 
=String Content Comparison=

Revision as of 22:21, 15 February 2017

String

Input a sequence of characters. Used to assign text to a String value type or as an input parameter that accepts String objects.

Read more here: https://www.arduino.cc/en/Reference/String , https://www.arduino.cc/en/Reference/StringObject

Character

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

String Length

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

String Content Comparison

  • equals
  • startsWith
  • endsWith

String Length Comparison