decimal point and compare

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
erik
Newbie
Posts: 3
Joined: Sun Sep 24, 2017 9:17 pm

decimal point and compare

Post by erik » Thu Dec 31, 2020 3:20 pm

let>DECIMAL_SEPARATOR=,
let>a=9,1
let>b=10,2
if>%a%>%b%
messagemodale>yes
else>
messagemodale>no
endif>

Hi i get yes i expected no whats wrong? if i use decimal point i get expected result??

User avatar
PepsiHog
Automation Wizard
Posts: 494
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: decimal point and compare

Post by PepsiHog » Sat Jan 02, 2021 12:51 am

Hi erik,
If decimal works for you, why are you trying to use comma? I know some countries use comma instead. I guess what I am asking is what is the purpose for this macro. This is difficult to express. I'm thinking you may need to process information that has commas and not decimals. The reason I ask, is if decimal is an option, and it isn't giving you a problem then...... But you might consider using StringReplace> to replace commas with a decimal, just before you process it. And if need be you could replace it in reverse after you check or do whatever you are doing.

Maybe something like this.

Code: Select all

let>Input=782365,1
StringReplace>Input,comma,.,NewInput

mdl>%NewInput%
...rest of program.

StringReplace>NewInput,.,comma,Input

mdl>%Input%
...rest of rest of program.
I'm just suggesting it may be the easier route to take.

PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2021) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

erik
Newbie
Posts: 3
Joined: Sun Sep 24, 2017 9:17 pm

Re: decimal point and compare

Post by erik » Sat Jan 02, 2021 9:02 am

Thank you i edited the program now its working.

It looks like the decimal point separator setting to comma does not change the numbers to floats but keeps them of type text thats why the compare does not function correctly. All my files i process have numbers with comma as decimal. So i need to need to do the stringreplace to do with each number which i read from a file.

let>DECIMAL_SEPARATOR=,
let>a=9,1
let>b=10,2
let>DECIMAL_SEPARATOR=.
StringReplace>a,comma,.,NewA
StringReplace>b,comma,.,NewB
//mdl>%NewA%

if>%NewA%>%NewB%
messagemodale>yes
else>
messagemodale>no
endif>

User avatar
PepsiHog
Automation Wizard
Posts: 494
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: decimal point and compare

Post by PepsiHog » Sat Jan 02, 2021 2:01 pm

Hi erik,
Hey! Awesome! I'm glad you were able to get it to work. Great job. I'm gonna call and see that they give you a well deserved raise. :lol:

PepsiHog

[edit] - Just as a side note, in your actual script you shouldn't need to specify the separator any longer. You're processing the info and the separator now shouldn't matter.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2021) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 885
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: decimal point and compare

Post by Dorian (MJT support) » Fri Feb 19, 2021 10:20 am

This has been fixed in dev, and will be in an upcoming update.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 885
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: decimal point and compare

Post by Dorian (MJT support) » Tue Feb 23, 2021 2:21 pm

This was released today. V15.0.17. Version History.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts