Programatically add values to instance variables?

Questions about GP commands and how to do things

Moderator: MSandro

Post Reply
aok
Posts: 1
Joined: Jul 30th, '17, 02:28

Programatically add values to instance variables?

Post by aok » Jul 30th, '17, 02:39

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?

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Programatically add values to instance variables?

Post by JohnM » Aug 3rd, '17, 22:59

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...

Post Reply