Text strings can be represented in two ways. you can use the String data type (String object) or you can make a string out of an array of type char. In this part, we speak about the String as an object. Once you called the declare bloc, a whole bench of blocs will appear.
- String declare:
Before they are used, all variables have to be declared. This bloc should be called only one in the setup part. You have to snap the double quote bloc. The blocs contain the name of the variable and you can change it by clicking on the “rename variable” button.
- set String:
This bloc will add the value of attached bloc to the selected variable.
Example: I am putting the text “Yes!” into the String variable called “i”.
- get String:
The get block provides the value stored in a variable, without changing it.
- Char At:
Access a particular character of the String. Accepts as a parameter the position (an unsigned int) and return the character in that position.
Return type: Char
- Compare to:
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.
Return type: a number
a negative number: if string comes before string2
0: if string equals string2
a positive number: if string comes after string2.
- Index of:
Locates a character or String within another String. By default, searches from the beginning of the String, but can also start from a given index, allowing for the locating of all instances of the character or String.
Parameter: The value to search for: a char or a String
Return type: A number. The index of val within the String, or -1 if not found
Appends the parameter to a String.
Parameter: Allowed types are String, string, char, byte, int, unsigned int, long, unsigned long, float, double.
- Length of
Returns the length of the String, in characters.
Return type: a number.
- To Integer:
Converts a valid String to an integer. The input string should start with an integer number. If the string contains non-integer numbers, the function will stop performing the conversion.
Return type: Number (long)
- To float:
Converts a valid String to a float. The input string should start with a digit. If the string contains non-digit characters, the function will stop performing the conversion. For example, the strings “123.45”, “123”, and “123fish” are converted to 123.45, 123.00, and 123.00 respectively. Note that “123.456” is approximated with 123.46. Note too that floats have only 6-7 decimal digits of precision and that longer strings might be truncate.
Return type: a Float
- End with:
Tests whether or not a String ends with the characters of another String.
Parameter: A String variable.
Return type: True if string ends with the characters of the parameter, otherwise it will be false.
- Equal to:
Compares two strings for equality. The comparison is case-sensitive, meaning the String “hello” is not equal to the String “HELLO”.
Parameter: A String variable.
Return type: a Boolean. true: if string variable equals the string parameter, false: otherwise
- To Char array:
Copies the string’s characters to the supplied buffer.
Parameter: Char: the buffer to copy the characters into. the size of the buffer (unsigned int)
- Clear the HTTP request in the server:
When a server receives a web request from a client, it contains a lot of non useful information. This bloc will keep only the most important one.
Example: Client-Server communication where a client sends a request to the server. The server will clear the request and show it on the serial monitor.
- Clear the HTTP request in the client:
When a server receives a web answer from a server, it contains a lot of non useful information. This bloc will keep only the most important one.
Example: Client-server communication where the server answer a client with a web request. The client will clear the answer and show it on the serial monitor.