Hi I've managed to perfect using the Params function to retrieve a list of additional parameters passed to my function. However now I'm stuck with the possibility of forwarding these onto a registered module for my event system. If my DispatchEvent() function is passed an event name called PlayerLogon and then is given a username and a session ID these count as 2 additional parameters which can be retrieve using the params function.
The way I've programmed my function is so that it places each additional parameter along with the event name into a variable called tArguments which looks like "PlayerLogon, Administrator, 0". I tried making use of just Dispatch Function "EventDispatched" To Stack "MyStack" With tArguments however upon examining the debugger I find that rather than passing each argument as per what I would have thought given the comma inbetween, it instead clumped them all together as one argument.
So my question is, is there anyway to make use of dispatch and pass each item of the tArguments variable without it clumping together? If not I'll quite happily resort to using something like an array.
Thanks, Mike.
Dispatch Function with a Variable of Parameters
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 246
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Dispatch Function with a Variable of Parameters
Mike-
The clumping thing is a feature, as it allows complex data to be passed without messing up the parsing. You can pass an entire script with embedded commas, carriage returns, etc, which would completely foul things up if you couldn't pass this as a single argument.
The fact that you've put the different arguments into a single variable is what has enabled this magic. So one possibility would be *not* to do that, but to pass the arguments individually, i.e.,
Another approach would be to take the arguments apart at the receiving end if you can be sure there are no embedded commas other than the argument separators.
A third approach would be array encoding and decoding, as you suggested.
The clumping thing is a feature, as it allows complex data to be passed without messing up the parsing. You can pass an entire script with embedded commas, carriage returns, etc, which would completely foul things up if you couldn't pass this as a single argument.
The fact that you've put the different arguments into a single variable is what has enabled this magic. So one possibility would be *not* to do that, but to pass the arguments individually, i.e.,
Code: Select all
dispatch someCommand with argument1 & comma & argument2, etc
A third approach would be array encoding and decoding, as you suggested.
-
- VIP Livecode Opensource Backer
- Posts: 246
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Dispatch Function with a Variable of Parameters
Hmm I think in that case then I think I'll go for the array encoding and decoding method, thanks for the help man. 
