Hi,
I don't think it is related to the toNumber function, but what I am observing is very frustrating! I have spent 3 days on changing source and have gotten nowhere!
I keep receiving an error using the toNumber function. On my display I see a variable with a value of "0.35" but when I use this function an error occurs. I found that if I use the function length (variable), the result is 5! Yes 5, not 4 as it should be!
I have used the trim(variable) function and the result is the same, the length is always 5!
Please advise.
Thanks.
Julian
Something very weird going on here!
Moderator: Martin
Re: Something very weird going on here!
I think your variable is not of type String or Number
Please upload the code or error message!
-
- Posts: 27
- Joined: 13 Jul 2017 08:47
Re: Something very weird going on here!
Percentage_Change_Sixty_Min = left({Percentage_Change_Sixty_Min}, indexOf({Percentage_Change_Sixty_Min}, "%"));
The object value I retrieve via the above function is displayed as "0.45%". I attempt to extract the value without the % then convert to number.
I have used the condition Debug thingie to display the variable value and it displays correctly but I don't know why Auyomate thinks it had another hidden character. I have used the trim fiction also with no good outcome.
Julian.
The object value I retrieve via the above function is displayed as "0.45%". I attempt to extract the value without the % then convert to number.
I have used the condition Debug thingie to display the variable value and it displays correctly but I don't know why Auyomate thinks it had another hidden character. I have used the trim fiction also with no good outcome.
Julian.
-
- Posts: 27
- Joined: 13 Jul 2017 08:47
Re: Something very weird going on here!
I can't seem to find the bottom to upload attachments!
-
- Posts: 27
- Joined: 13 Jul 2017 08:47
Re: Something very weird going on here!
I mean button?
Re: Something very weird going on here!
You should not use curly braces around the variable Percentage_Change_Sixty_Min as it is not in a String.
And what is the value of Percentage_Change_Sixty_Min before? Please use debug dialog and show it here.
Sorry for saying "upload", I just want to see the "Notification error message" when there is error.
Alternatively, you can modify your code like this:
_____________________________________________
Percentage_Change_Sixty_Min = replace(Percentage_Change_Sixty_Min, "%", "");
//remove character '%'
_____________________________________________
Re: Something very weird going on here!
@JC : It seem {Percentage_Change_Sixty_Min} contains invisible char, such as nbsp or other white space. Try to use encodeURL () to check the content
% is ascii code number 25, hence when encoded will be %25. Other example, Space is 20, so will be %20. If you see {check} contain value other than 0.45%25, then you have hidden char inside. trim() only remove whitespace at the end and beginning, not in the middle. It is likely the hidden char is in the middle.
I try to replicate your result, if the 0.45% is clean without hidden char, it should work properly. I also show my method using regex.
Code: Select all
check = encodeURL(Percentage_Change_Sixty_Min); //if 0.45% should be 0.45%25
I try to replicate your result, if the 0.45% is clean without hidden char, it should work properly. I also show my method using regex.
Code: Select all
p = "0.45%";
//p check
e = encodeURL(p); //0.45%25
//your method
q = left(p, indexOf(p, "%"));
r = length(q); //result is 4
//use regex method
f = findAll(p, "(\\d+\\.\\d+)%", true);
g = f[0][1];
h = length(g); //result is 4
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.