{"id":1238,"date":"2021-08-16T11:43:58","date_gmt":"2021-08-16T17:43:58","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=1238"},"modified":"2021-08-16T12:25:34","modified_gmt":"2021-08-16T18:25:34","slug":"bit-in-the-ass-by-api-2","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2021\/08\/16\/bit-in-the-ass-by-api-2\/","title":{"rendered":"Bit in the ass by API 2"},"content":{"rendered":"\n<p>Was tracking down a bug in my app and couldnt figure out what was wrong initially.<\/p>\n\n\n\n<p>All the code seemed right but setting a value to code like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>value = string.ToInteger<\/code><\/pre>\n\n\n\n<p>seemed to be the culprit. Sure enough the string contained a value like 3.0e+2 (an integer expressed in exponential form) But the docs say<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">String.ToInteger<\/h1>\n\n\n\n<p>Method<\/p>\n\n\n\n<p>Returns the integer equivalent of the source&nbsp;<a href=\"xojo:\/\/String\">string<\/a>. This function is the same as the&nbsp;<a href=\"xojo:\/\/Val\">Val<\/a>&nbsp;function but is international-savvy.<\/p>\n\n\n\n<p>But experience was telling me this wasnt true<\/p>\n\n\n\n<p>So a quick test in 2021r2.1 with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dim s As String = \"3.0e+2\"\n\nDim i1 As Int32 = Val(s)\nDim i2 As Int32 = s.Val\nDim i3 As Int32 = s.ToInteger\n\nBreak<\/code><\/pre>\n\n\n\n<p>shows that indeed i1 = 300, i2 = 300, and i3 is 3 not 300 like I would have expected. I changed my use of ToInteger to Val and things work as expected.<\/p>\n\n\n\n<p>Be careful out there<\/p>\n\n\n\n<p>EDIT : reported bug <a href=\"http:\/\/feedback.xojo.com\/case\/65567\">http:\/\/feedback.xojo.com\/case\/65567<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Was tracking down a bug in my app and couldnt figure out what was wrong initially. All the code seemed right but setting a value to code like seemed to be the culprit. Sure enough the string contained a value like 3.0e+2 (an integer expressed in exponential form) But the docs say String.ToInteger Method Returns &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2021\/08\/16\/bit-in-the-ass-by-api-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Bit in the ass by API 2&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1238","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=1238"}],"version-history":[{"count":2,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1238\/revisions"}],"predecessor-version":[{"id":1240,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1238\/revisions\/1240"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=1238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=1238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=1238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}