Passing parameters to a method
Gerry Keely
Posts: 75
Hi
Just wondering if it is possible to pass a·varying number of parameters to a method.
What I want to do is to send data to the serial port which would consist of a command(defined as a CON) plus byte variables.However the no. of variables passed to the method could be different each time.Is this possible in spin?
Regards
Gerry
·
Just wondering if it is possible to pass a·varying number of parameters to a method.
What I want to do is to send data to the serial port which would consist of a command(defined as a CON) plus byte variables.However the no. of variables passed to the method could be different each time.Is this possible in spin?
Regards
Gerry
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum
NTSC & PAL driver templates: ObEx Forum
OnePinTVText driver: ObEx Forum
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
or an array.
Then pass to the method two parameters. The first one is the number of parameters and the second
is the address of the first variable in the set of contiguous variable or the address of the first element
of the array.
Your method can then use Long[noparse][[/noparse]address][noparse][[/noparse]k] or byte[noparse][[/noparse]address][noparse][[/noparse]k] or word[noparse][[/noparse]address][noparse][[/noparse]k] to access the
variables needed. If the contiguous set is not of the same type then you can calculate the offsets required.
If the variables are not possible to put into a contiguous set or an array then you can use an array of pointers
where each element in the array holds the address of each variable in the set of the parameters needed.
·
Samuel
·
Post Edited (SamMishal) : 8/7/2009 9:01:54 AM GMT