I want to check the number of command arguments in my Q script and return an error message if .z.x doesn't match the intended number of arguments. So far I came up with this line:
if[count .z.x < 4; '`BadUsage]
"Arguments OK"
I never get past the if statement, it always returns `BadUsage, regardless of the number of arguments I'm using.
How do I check for the correct number of arguments, print an error message and exit the script?
Its because the statements are evaluated right to left. So .z.x < 4 is evaluated first, and then the count of that result.
q)count .z.x < 4
0
q)4 > count .z.x
1b