Page 1 of 1

IfMsgbox invalid parameter?

Posted: 09 Apr 2018, 11:29
by Nwb
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.

Re: IfMsgbox invalid parameter?

Posted: 09 Apr 2018, 11:46
by gregster
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.

Re: IfMsgbox invalid parameter?

Posted: 09 Apr 2018, 11:51
by Cuadrix
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
}

Re: IfMsgbox invalid parameter?

Posted: 09 Apr 2018, 11:53
by Nwb
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