Defining arrays in event handlers and functions
PsyenceFact
Posts: 29
New AMX programmer with first post here, so I hope I'm not asking about something that's widely known.
I'm trying to define a char array inside a channel event handler that is then used as a parameter in a function call. However, the compiler throws a syntax error at the assignment statement (C10201: Syntax error; Illegal or Invalid syntax in code).
A simplified version of the event handler is:
Can anyone cast any light on this?
Thanks,
Andy
I'm trying to define a char array inside a channel event handler that is then used as a parameter in a function call. However, the compiler throws a syntax error at the assignment statement (C10201: Syntax error; Illegal or Invalid syntax in code).
A simplified version of the event handler is:
CHANNEL_EVENT[dvTP, BTN_ALLOFF] { on: { stack_var char cLabels[2][10]; cLabels[1] = 'OK'; cLabels[2] = 'Cancel'; fnShowDialog(cLabels); } }If the variable is defined (but not initialised) at the module level in DEFINE_VARIABLE, the assignment in the event handler is fine. The same thing seems to happen inside functions as well.
Can anyone cast any light on this?
Thanks,
Andy
0
Comments
A work around would be: Basically just do anything first. You can search and find more info about this but basically it's a bug that you just have to deal with.
However...
I've come back to my code this morning to try your workaround and the compiler error no longer occurs! I've added and deleted a couple of send_strings as I've been trying things out, but I've now reverted to my code exactly as it was before and no error!
At least I'll know it's something to look out for in the future. Thanks again.
Andy