Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

# Monster: evaluate math expressions in strings

87 replies to this topic
• Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005

Why would this not give the correct result?

It does. You see the inherent floating point representation error. C.f.
```SetFormat Float, 0.16
MsgBox % 5.85 + 0.0```
You could use Eval("\$16g 5.85") or, if you insist on seeing a lot of decimals, Eval("\$15 5.85"). Numbers larger than 2 usually have representation errors in their 16th decimal place, because doubles are only of 52 bit precision.

• Members
• 149 posts
• Last active: Jan 02 2013 08:54 AM
• Joined: 04 Jun 2005
I type:

(17+15)*2

and hit Win+= and get:

(17+15)*2 = 64)

Why the trailing close-parens?

(I would try to fix it myself, but this thing is insanely complex)

Also, I type:

min(2,15,-5) and get:

min(2,15,-5) = 0)

Doesn't seem right; am I using it wrong?

• Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
Min is for two parameters, only. I don't get the closing parenthesis in my XP laptop.

• Spam Officer
• 2186 posts
• Last active: Nov 07 2015 08:15 AM
• Joined: 27 Feb 2009
Don't get the extra ) either on HP laptop with Vista.

Re: Min, you can "daisy chain" I.e. 1 min 2 min -5 = -5

Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”

• Spam Officer
• 2186 posts
• Last active: Nov 07 2015 08:15 AM
• Joined: 27 Feb 2009
to use the suggested format for min use a function like this:

```min2(a,b,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0)
{
return eval(a " min " b " min " c " min " d " min " e " min " f " min " g " min " h " min " i " min " j " min " k " min " l " min " m " min " n " min " o " min " p " min " q " min " r " min " s " min " t " min " u " min " v " min " w " min " x " min " y " min " z)
}```

Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”

• Members
• 7 posts
• Last active: May 25 2015 10:20 PM
• Joined: 23 Jul 2009

I do not get it with notepad but I get it with PsPad.

The magic with PSPad is when you type ( Pspad shows (|). It auto adds closing parenthesis.

This might explain the trick; How to remove it ??

By the way monster is my every day tool.

• 2709 posts
• Hates playing Janitor
• Last active: Jan 15 2016 11:37 PM
• Joined: 09 Mar 2008
It seems the eval() isn't doing Order Of Operations correctly.

4*16^0 is evaluating as 64 when it should be 4.

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .

• Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
XOR with 0 does not make any change. Did you mean power-of (** or @)?

• 2709 posts
• Hates playing Janitor
• Last active: Jan 15 2016 11:37 PM
• Joined: 09 Mar 2008
I meant power. Didn't think of trying ** instead of ^. Will try tomorrow.

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .

• Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
I updated the script to version 1.2 with dynamic function calls to save several lines of code, with unchanged functionality.

guest3456
• Guests
• Last active:
• Joined: --
i'm a little confused, is this a replacement for these:
http://www.autohotke... ... 547#107547
?

• Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
Replacement? Monster was written 14 months earlier than Labouche10's script. They have many differences: Monster is 200 lines, the other one is over 700. Monster let you define functions, assign values to variables and use them until the script is closed, Labouche10's script just runs another dynamically created script with your input, therefore all previous calls are forgotten. Also, Monster can be compiled and run in a PC, where no AHK is installed, while the two-script solution only works if AHK is properly installed in the target machine and you have write access to a disk.

On the other hand, Monster has no GUI (although one can easily write one with 40 lines of code). It just evaluates an arithmetic expression it gets. In the provided example the data is taken from the current application via the clipboard and the result is written back to the active window.

Edit: oops. My browser brought me to the wrong post. Considering the calculator script you point to: yes, Monster is its big brother with much larger functionality.

guest3456
• Guests
• Last active:
• Joined: --

• Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
sorry (browsers have problems with showing the right post in their windows)... Monster is larger with more functionality, but based on the same ideas. For simple needs Monster can be overkill.

• Members
• 7 posts
• Last active: Aug 10 2013 12:44 PM
• Joined: 13 Jun 2009
dear Laszlo