Evaluating two variables 1 has a dollar sign

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gamergames

Evaluating two variables 1 has a dollar sign

03 May 2018, 10:25

Code: Select all

gold := $900
unicorn := 1000
if (gold < unicorn)
{
	SoundBeep, 500, 900
}
ExitApp
It always comes back as true and beeps
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Evaluating two variables 1 has a dollar sign

03 May 2018, 16:34

remove the $ then compare. "$900" isn't a number, it's text. basically you're comparing if nothing (text aint a number) is less than 1000, which is true.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: Evaluating two variables 1 has a dollar sign

03 May 2018, 17:51

tidbit wrote:remove the $ then compare. "$900" isn't a number, it's text. basically you're comparing if nothing (text aint a number) is less than 1000, which is true.
More precisely: gold := $900 is not a text (or rather a string), because is not enclosed in quotes. It's improperly formatted number, due to the $, which results in "nothing". Outcome is the same though.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Dobbythenerd1, Google [Bot] and 317 guests