IfMsgbox invalid parameter?

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

IfMsgbox invalid parameter?

09 Apr 2018, 11:29

I have been breaking my head on this for so long I'm not able to understand this..

When I run this:

Code: Select all

IfMsgBox, OK {
	Var := 0
	Send, %Retrieved%
	return
}
return
It says parameter #1 for IfMsgBox is invalid.

But when I run:

Code: Select all

IfMsgBox, OK 
	Var := 0
There is no error?

There was no #warn either.
I am your average ahk newbie. Just.. a tat more cute. ;)
gregster
Posts: 3007
Joined: 30 Sep 2013, 06:48

Re: IfMsgbox invalid parameter?

09 Apr 2018, 11:46

The opening { on the same line is only allowed with if in expression syntax, for example if(x = 2) { ... so, put in on the next line.
User avatar
Cuadrix
Posts: 204
Joined: 07 May 2017, 08:26

Re: IfMsgbox invalid parameter?

09 Apr 2018, 11:51

IfMsgBox is a command, which means that you can't put {}-brackets in the same line. Instead, place the {}-brackets under the command, like this:

Code: Select all

IfMsgBox, OK 
{
	Var := 0
	Send, %Retrieved%
	return
}
return
You can use {}-brackets in the same line as functions and expressions; Ex:

Code: Select all

Function(){
	; -- Something
}
Last edited by Cuadrix on 09 Apr 2018, 11:53, edited 1 time in total.
----
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: IfMsgbox invalid parameter?

09 Apr 2018, 11:53

gregster wrote:The opening { on the same line is only allowed with if in expression syntax, for example if(x = 2) { ... so, put in on the next line.
Thanks gregster!

Cuadrix wrote:IfMsgBox is a command, which means that you can't use {}-brackets in the same line as the command. Instead, place the {}-brackets under the command, like this:

Code: Select all

IfMsgBox, OK 
{
	Var := 0
	Send, %Retrieved%
	return
}
return
You can use {}-brackets in the same line as functions; Ex:

Code: Select all

Function(){
	; -- Something
}
Makes sense thanks! :P
I am your average ahk newbie. Just.. a tat more cute. ;)

Return to “Ask For Help”

Who is online

Users browsing this forum: ac1234, LiangShuii, misiek5510, Villitz and 263 guests