Something very weird going on here!

Post your questions and help other users.

Moderator: Martin

Post Reply
JC.INTERNET.STUFF
Posts: 27
Joined: 13 Jul 2017 08:47

Something very weird going on here!

Post by JC.INTERNET.STUFF » 23 Aug 2020 02:35

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

User avatar
Hit
Posts: 91
Joined: 20 Jan 2020 11:31

Re: Something very weird going on here!

Post by Hit » 23 Aug 2020 02:51


I think your variable is not of type String or Number
Please upload the code or error message!

JC.INTERNET.STUFF
Posts: 27
Joined: 13 Jul 2017 08:47

Re: Something very weird going on here!

Post by JC.INTERNET.STUFF » 23 Aug 2020 03:34

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.

JC.INTERNET.STUFF
Posts: 27
Joined: 13 Jul 2017 08:47

Re: Something very weird going on here!

Post by JC.INTERNET.STUFF » 23 Aug 2020 03:53

I can't seem to find the bottom to upload attachments!

JC.INTERNET.STUFF
Posts: 27
Joined: 13 Jul 2017 08:47

Re: Something very weird going on here!

Post by JC.INTERNET.STUFF » 23 Aug 2020 03:57

I mean button?

User avatar
Hit
Posts: 91
Joined: 20 Jan 2020 11:31

Re: Something very weird going on here!

Post by Hit » 23 Aug 2020 04:06


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 '%'
_____________________________________________

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Something very weird going on here!

Post by Desmanto » 23 Aug 2020 05:47

@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

Code: Select all

check = encodeURL(Percentage_Change_Sixty_Min); //if 0.45% should be 0.45%25
% 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

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.

Post Reply