{"id":1418,"date":"2017-12-12T14:30:28","date_gmt":"2017-12-12T14:30:28","guid":{"rendered":"http:\/\/easycoding.tn\/?page_id=1418"},"modified":"2017-12-14T12:04:54","modified_gmt":"2017-12-14T12:04:54","slug":"string-object","status":"publish","type":"page","link":"http:\/\/easycoding.tn\/index.php\/nodemcu\/tuniot-documentation\/string-object\/","title":{"rendered":"String object"},"content":{"rendered":"<p>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.<\/p>\n<ul>\n<li><strong>String declare<\/strong>:<br \/>\nBefore 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 &#8220;rename variable&#8221; button.<strong><br \/>\n<img loading=\"lazy\" class=\"size-medium alignleft\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2017\/12\/String_Declare.jpg\" width=\"271\" height=\"104\" \/><\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>set String<\/strong>:<br \/>\nThis bloc will add the value of attached bloc to the selected variable.<br \/>\n<span style=\"color: #ffcc00;\"><strong>Example<\/strong><\/span>: I am putting the text &#8220;Yes!&#8221; into the String variable called &#8220;i&#8221;.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-medium\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2017\/12\/String_Set.jpg\" width=\"242\" height=\"42\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>get String<\/strong>:<br \/>\nThe <strong>get<\/strong> block provides the value stored in a variable, without changing it.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-medium\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2017\/12\/String_get.jpg\" width=\"258\" height=\"112\" \/><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Char At:<\/strong><br \/>\nAccess a particular character of the String. Accepts as a parameter the position (an unsigned int) and return the character in that position.<br \/>\n<strong><span style=\"color: #00ff00;\">Return type<\/span>:<\/strong> Char<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Compare to<\/strong>:<br \/>\nCompares two Strings, testing whether one comes before or after the other, or whether they\u2019re equal. The strings are compared character by character, using the ASCII values of the characters. That means, for example, that &#8216;a&#8217; comes before &#8216;b&#8217; but after &#8216;A&#8217;. Numbers come before letters.<br \/>\n<strong><span style=\"color: #00ff00;\">Return type<\/span><\/strong>: a number<br \/>\na negative number: if string comes before string2<br \/>\n0: if string equals string2<br \/>\na positive number: if string comes after string2.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Index of<\/strong>:<br \/>\nLocates 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.<br \/>\n<strong><span style=\"color: #00ff00;\">Parameter<\/span><\/strong>: The value to search for: a char or a String<br \/>\n<span style=\"color: #00ff00;\"><strong>Return type: <\/strong><span style=\"color: #000000;\">A number. The index of val within the String, or -1 if not found<\/span><\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Concat:<\/strong><br \/>\nAppends the parameter to a String.<br \/>\n<span style=\"color: #00ff00;\"><strong>Parameter<\/strong><\/span>: Allowed types are String, string, char, byte, int, unsigned int, long, unsigned long, float, double.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Length of<\/strong><br \/>\nReturns the length of the String, in characters.<br \/>\n<span style=\"color: #00ff00;\"><strong>Return type<\/strong><\/span>: a number.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>To Integer:<\/strong><br \/>\nConverts 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.<span style=\"color: #00ff00;\"><strong><br \/>\nReturn type<\/strong><\/span>: Number (long)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>To float<\/strong>:<br \/>\nConverts 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 &#8220;123.45&#8221;, &#8220;123&#8221;, and &#8220;123fish&#8221; are converted to 123.45, 123.00, and 123.00 respectively. Note that &#8220;123.456&#8221; is approximated with 123.46. Note too that floats have only 6-7 decimal digits of precision and that longer strings might be truncate.<br \/>\n<span style=\"color: #00ff00;\"><strong>Return type<\/strong><\/span>: a Float<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>End with<\/strong>:<br \/>\nTests whether or not a String ends with the characters of another String.<br \/>\n<strong><span style=\"color: #00ff00;\">Parameter<\/span><\/strong>: A String variable.<br \/>\n<span style=\"color: #00ff00;\"><strong>Return type<\/strong><\/span>: True if string ends with the characters of the parameter, otherwise it will be false.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Equal to:<\/strong><br \/>\nCompares two strings for equality. The comparison is case-sensitive, meaning the String &#8220;hello&#8221; is not equal to the String &#8220;HELLO&#8221;.<br \/>\n<span style=\"color: #00ff00;\"><strong>Parameter<\/strong><\/span>: A String variable.<br \/>\n<span style=\"color: #00ff00;\"><strong>Return type<\/strong><\/span>: a Boolean.\u00a0true: if string variable equals the string parameter, false: otherwise<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>To Char array<\/strong>:<br \/>\nCopies the string\u2019s characters to the supplied buffer.<br \/>\n<span style=\"color: #00ff00;\"><strong>Parameter<\/strong><\/span>: Char: the buffer to copy the characters into. the size of the buffer (<em>unsigned int<\/em>)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Clear the HTTP request in the server<\/strong>:<br \/>\nWhen 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.<br \/>\n<strong><span style=\"color: #ffcc00;\">Example<\/span><\/strong>: 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.<br \/>\n<a href=\"https:\/\/youtu.be\/Ntzrnsz0MQM\">Video<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Clear the HTTP request in the client<\/strong>:<br \/>\nWhen 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.<br \/>\n<span style=\"color: #ffcc00;\"><strong>Example<\/strong><\/span>: 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.<br \/>\n<a href=\"https:\/\/youtu.be\/Ntzrnsz0MQM\">Video<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Text strings can be represented in two ways. you can use the String data type (String object) or you can&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1007,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages\/1418"}],"collection":[{"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/comments?post=1418"}],"version-history":[{"count":16,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages\/1418\/revisions"}],"predecessor-version":[{"id":1482,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages\/1418\/revisions\/1482"}],"up":[{"embeddable":true,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages\/1007"}],"wp:attachment":[{"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/media?parent=1418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}