AutoHotkey Community

It is currently May 27th, 2012, 5:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: March 14th, 2010, 1:31 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
How can I deduct 2 from a variable containing 005 float number?
I've tried it here, but it doesn't work:
Code:
CheckCounter = 5
SetFormat, Float, 03 ; making it 3-number format
CheckCounter += 0.0
msgbox, CheckCounter: %CheckCounter%
SetFormat, Float, 03 ; making it 3-number format
Counter :=  CheckCounter – 2
msgbox, here is the result: %Counter%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 1:40 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
You need to subtract a floating point number for SetFormat, Float to take effect; also you only need to specify the format once, since you're in the auto-execute section.
Code:
CheckCounter = 5
SetFormat, Float, 03 ; making it 3-number format
CheckCounter += 0.0
msgbox, CheckCounter: %CheckCounter%

Counter :=  CheckCounter - 2.0
msgbox, here is the result: %Counter%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 1:49 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
Thank you very much, jaco0646!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 1:58 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
also you posted it with – (a horizontal line) instead of - ( a Hyphen)
They look the same to you but the computer doesn't think so. :D

Code:
CheckCounter = 5
SetFormat, FloatFast, 03 ;You could also use FloatFast
CheckCounter += 0.0
msgbox, CheckCounter: %CheckCounter%
Counter :=  CheckCounter - 2 ;and leave the 2 alone
msgbox, here is the result: %Counter%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 2:21 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
Aaaaaaaaah!
Tha was the problem! Thank you, None!
How did you notice it?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 2:46 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
I noticed that the Expression was not giving the expected results. I tried a few thing and finaly narrowed it down to that. The – is also slightly longer than -.
The Expression treated It like a period in Concatenate. :shock:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 8:35 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
None wrote:
I noticed that the Expression was not giving the expected results. I tried a few things and finally narrowed it down to that.
Oh, I see. That's just great! Thank you.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], dra, Google [Bot], HotkeyStick, rbrtryn, XstatyK and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group