Decimal place > 2

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
andreasrothe
Newbie
Posts: 1
Joined: Sat Oct 01, 2005 7:46 am

Decimal place > 2

Post by andreasrothe » Sat Oct 01, 2005 8:31 am

I am having problems with decimal places > 2.

This code:
GetClipBoard>myvalue //myvalue=1.1234
Sub>myvalue,0.01

results in 1.11, which is ok.

This code:
GetClipBoard>myvalue //myvalue=1.1234
Sub>myvalue,0.001

results in 1.12, which is not ok - it is simply chopped off, with no calculation being done.

I have changed my regional settings, but that has made no difference.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sat Oct 01, 2005 9:02 am

Instead of Sub use:

Let>myvalue=myvalue-0.001


More accurate. Add and Sub commands are there for backwards compatibility but are largely unnecessary now. Use Let for calculations. You can also use complex expressions and VBScript.
MJT Net Support
[email protected]

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Oct 04, 2005 7:16 pm

More accurate. Add and Sub commands are there for backwards compatibility but are largely unnecessary now.
Not to be argumentative and certainly not questioning the answer to this particular user but I would like to point out that "Add" and "Sub" work great with dates. "Let" does not work at all.

For example:

GetDate>var
Add>var,28


Will add 28 days onto today's date. Today is 10/04/2005 so the variable var will be set to 11/01/2005.

On the other hand:

GetDate>var
Let>var=var+28


Will set var to be "var+28"

And adding percents to the variable:

GetDate>var
Let>var=%var%+28


Will result in var being set to "11/04/2005+28"

There may be some way to make "Let" add and subtract numbers from dates by using a complex expression or using VB script, but nothing could be easier than using "Add" and "Sub". These two helpful tools are good for more than backward compatability.

Thanks for listening,
Dick

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Oct 05, 2005 7:04 am

No, Let cannot add days to dates. Add and Sub have special functionality to add days to dates. Let will do only pure mathematical calculations.
MJT Net Support
[email protected]

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