Page 1 of 1
Something very weird going on here!
Posted: 23 Aug 2020 02:35
by JC.INTERNET.STUFF
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
Re: Something very weird going on here!
Posted: 23 Aug 2020 02:51
by Hit
I think your variable is not of type String or Number
Please upload the code or error message!
Re: Something very weird going on here!
Posted: 23 Aug 2020 03:34
by JC.INTERNET.STUFF
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.
Re: Something very weird going on here!
Posted: 23 Aug 2020 03:53
by JC.INTERNET.STUFF
I can't seem to find the bottom to upload attachments!
Re: Something very weird going on here!
Posted: 23 Aug 2020 03:57
by JC.INTERNET.STUFF
I mean button?
Re: Something very weird going on here!
Posted: 23 Aug 2020 04:06
by Hit
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!
Posted: 23 Aug 2020 05:47
by Desmanto
@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