How to make Min(Number1 , Number2, ...) no longer output null values Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
emanate22
Posts: 52
Joined: 11 May 2021, 00:03

How to make Min(Number1 , Number2, ...) no longer output null values

Post by emanate22 » 30 Nov 2021, 07:14

Min [v1.1.27+]
Returns the minimum value of one or more numbers.

Value := Min(Number1, Number2, ...)
If one of the input values is non-numeric, an empty string is returned.

The function description says that if there is a non-number, it outputs a null value. How can I find the minimum value regardless of the null value?

Code: Select all

DistA:= Min(DistA1,DistA2,DistA3,DistA4,DistA5,DistA6,DistA7,DistA8,DistA9)

Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to make Min(Number1 , Number2, ...) no longer output null values  Topic is solved

Post by Rohwedder » 30 Nov 2021, 07:30

Hallo,
try:

Code: Select all

DistA2 = 4
DistA7 = 7
DistA := 1.7976931348623157E+308 ; FloatMax
Loop, 9
	IF DistA%A_Index%
		DistA := Min(DistA, DistA%A_Index%)
MsgBox,% DistA
or:

Code: Select all

DistA2 = 4
DistA7 = 7
DistA:= Min0(DistA1,DistA2,DistA3,DistA4,DistA5,DistA6,DistA7,DistA8,DistA9)
MsgBox,% DistA

Min0(params*)
{
	Min := 1.7976931348623157E+308 ; FloatMax
	For index,param In params
		IF param
			Min := Min(Min, param)
	Return, Min
}

emanate22
Posts: 52
Joined: 11 May 2021, 00:03

Re: How to make Min(Number1 , Number2, ...) no longer output null values

Post by emanate22 » 30 Nov 2021, 08:29

Rohwedder wrote:
30 Nov 2021, 07:30
Hallo,
try:

Code: Select all

DistA2 = 4
DistA7 = 7
DistA := 1.7976931348623157E+308 ; FloatMax
Loop, 9
	IF DistA%A_Index%
		DistA := Min(DistA, DistA%A_Index%)
MsgBox,% DistA
or:

Code: Select all

DistA2 = 4
DistA7 = 7
DistA:= Min0(DistA1,DistA2,DistA3,DistA4,DistA5,DistA6,DistA7,DistA8,DistA9)
MsgBox,% DistA

Min0(params*)
{
	Min := 1.7976931348623157E+308 ; FloatMax
	For index,param In params
		IF param
			Min := Min(Min, param)
	Return, Min
}
Thank you for your code,first one seems runs perfectly :D

Code: Select all

DistA:= 1.7976931348623157E+308 ; FloatMax
Loop,200
IF DistA%A_Index%
DistA:= Min(DistA, DistA%A_Index%)
May I ask what is the meaning of

Code: Select all

DistA2 = 4
DistA7 = 7
In the beginning you sent it out without this part

Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to make Min(Number1 , Number2, ...) no longer output null values

Post by Rohwedder » 30 Nov 2021, 09:45

That was just for testing.

Post Reply

Return to “Ask for Help (v1)”