Expression for a Negative Range of Values Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Galaxis
Posts: 26
Joined: 04 Feb 2016, 20:09

Expression for a Negative Range of Values

06 Jun 2018, 12:54

I have issues with invalid results from NEGATIVE values. I'm creating a Character tracking MAP for a game.

The problem is, If I say:

Var is less than -100.
Var is between -1 and -10

BOTH returns invalid/wrong results.


The Expressions below are invalid as well:
Var < -100
(Var <= -1) && (Var >= -10)


All positive functions in the code below works perfectly. Just the Negative ones are jacked up.
Assistance would be much appreciated.


I'm testing other things. I think I may have solved the problem....

Code: Select all

	POSITIVES
		;---------<VALUE = 6.5 >---------------------------------------------------------->
		
		If a between 16576 and 16600
		{
			var1=6.5
			IniWrite, %var1% , %A_ScriptDir%\DoA.ini, DISTANCE, X1
		}
		
		If b between 16576 and 16600
		{
			var2=6.5
			IniWrite, %var2% , %A_ScriptDir%\DoA.ini, DISTANCE, X2
		}
		
		
		
		
		POSITIVES 
		;---------<VALUE = 7 >---------------------------------------------------------->
		
		If a between 16601 and 16700
		{
			var1=7
			IniWrite, %var1% , %A_ScriptDir%\DoA.ini, DISTANCE, X1
		}
		
		If b between 16576 and 16700
		{
			var2=7
			IniWrite, %var2% , %A_ScriptDir%\DoA.ini, DISTANCE, X2
		}
		
		
		
		
		
	
		
		NEGATIVE VALUES
		
		;---------<VALUE = -1 >---------------------------------------------------------->		
		
		If a < -16000
		{
			var1= -1
			IniWrite, %var1% , %A_ScriptDir%\DoA.ini, DISTANCE, X1
		}
		
		
		
		If b < -16000
		{
			var2= -1
			IniWrite, %var2% , %A_ScriptDir%\DoA.ini, DISTANCE, X2
		}
		
Last edited by Galaxis on 06 Jun 2018, 13:01, edited 2 times in total.
User avatar
TheDewd
Posts: 1334
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Expression for a Negative Range of Values  Topic is solved

06 Jun 2018, 12:59

Try adding quotes around the value in your IF statement: If a < "-16000"

Code: Select all

a := -14000

If (a < -16000) {
	MsgBox, Test 1 ; Doesn't work
}

If (a < "-16000") {
	MsgBox, Test 2 ; Works
}
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
swagfag
Posts: 2922
Joined: 11 Jan 2017, 17:59

Re: Expression for a Negative Range of Values

06 Jun 2018, 13:03

Code: Select all

a := -20000
If a <= -16000
	MsgBox % a " is smaller or equal"
else
	MsgBox % a " is bigger"

a := -8000
If a <= -16000
	MsgBox % a " is smaller or equal"
else
	MsgBox % a " is bigger"
seems like right results to me
Galaxis
Posts: 26
Joined: 04 Feb 2016, 20:09

Re: Expression for a Negative Range of Values

06 Jun 2018, 13:04

Thanks! SwagFag & TheDewd for the help!!!!

TheDewd wrote:Try adding quotes around the value in your IF statement: If a < "-16000"

Code: Select all

a := -14000

If (a < -16000) {
	MsgBox, Test 1 ; Doesn't work
}

If (a < "-16000") {
	MsgBox, Test 2 ; Works
}

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Flipeador, flyingDman, gigiiiii, Google [Bot], imnotgay, NewberEnerNeeder1, Permagrin, Sanbenito, x-tremespeed and 63 guests