Programatically add values to instance variables?
Moderator: MSandro
Programatically add values to instance variables?
Since GP reads values from the serial port, is there a way to programatically add the values to variables of a new instance each time new data is received?
Re: Programatically add values to instance variables?
I don't totally what you have in mind, but I think it's possible.
You can supply an argument to the blocks that make new instances. That value is passed to the "initialize" method. Thus, you could have a top-level class that reads bytes from the serial port and steps through those bytes calling "new instance of <class> data <byte value>". It would then be up to the initialize method to do something interesting with the byte value.
Hope that puts you on the right track...
You can supply an argument to the blocks that make new instances. That value is passed to the "initialize" method. Thus, you could have a top-level class that reads bytes from the serial port and steps through those bytes calling "new instance of <class> data <byte value>". It would then be up to the initialize method to do something interesting with the byte value.
Hope that puts you on the right track...