Is it possible to create an object array?
If so, how is it done?
Object array
Moderator: Benj
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: Object array
You can create an array for any of the known data types by adding '[ <length> ]' after the name when creating it. You can not create your own data types.
So for an array of 20 bytes use 'b[20]' as a name and select 'byte' from the list of data types.
So for an array of 20 bytes use 'b[20]' as a name and select 'byte' from the list of data types.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
Re: Object array
I understand how to create data type arrays.
What I want to do is scan a number of like objects to get the results of the same method of each object.
Is the "Object handle" type used to create object arrays?
If so, can someone give me an example of how to fill it with objects, then recover the value from a method of the object?
Thank you in advance.
What I want to do is scan a number of like objects to get the results of the same method of each object.
Is the "Object handle" type used to create object arrays?
If so, can someone give me an example of how to fill it with objects, then recover the value from a method of the object?
Thank you in advance.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Object array
Hello,
Object handles are used for the simulation only and cannot be downloaded to hardware.
What you want to do is possible but only in the simulation.
Here is a quick example.
Object handles are used for the simulation only and cannot be downloaded to hardware.
What you want to do is possible but only in the simulation.
Here is a quick example.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Object array
I didn't quite give you the full story, The redirect stuff does work for download but is fixed to a single object, i.e. you cannot redirect after compilation. This is how we do things like the Bitmap drawer component for the GLCD where the drawer can target any of the GLCDs.
What you might need instead is a intermediate macro that has say an index parameter and then use a switch icon to talk to various different components.
What you might need instead is a intermediate macro that has say an index parameter and then use a switch icon to talk to various different components.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Object array
I'm trying to eliminate the redundant code in the "Decode_PB" macro. Since I can't use object arrays, I'm at a loss. Any ideas?
- Attachments
-
- Interrupt Test.fcfx
- (29.34 KiB) Downloaded 257 times
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: Object array
I'd asked about a similar problem a while ago - how to access a pin defined by a variable so that it could be defined at runtime rather than compile time..
One idea I had was to connect multiple switches (or in my case outputs) to one port - then read (or write) all at once using a input whole port to variable and using some bit handling to decide which switch(s) are pressed.
One problem - what to do if multiple switches are pressed - your current code handles the first pressed only (where 'first' is defined by the checking order). You would need to write your own 'debounce' routine which is complicated by the need to wait and check multiple inputs at once.
This would probably lead to a 'multi' switch component.
I'd also wondered about using the Flowcode FCP_Set/Get macros in a C routine taking a pin as the argument - though this is probably frowned upon (and may result in things breaking if Flowcode is updated). Some documentation on these 'low-level' routines would be helpful (and I think these could be a 'feature' if implemented correctly!)
Martin
One idea I had was to connect multiple switches (or in my case outputs) to one port - then read (or write) all at once using a input whole port to variable and using some bit handling to decide which switch(s) are pressed.
One problem - what to do if multiple switches are pressed - your current code handles the first pressed only (where 'first' is defined by the checking order). You would need to write your own 'debounce' routine which is complicated by the need to wait and check multiple inputs at once.
This would probably lead to a 'multi' switch component.
I'd also wondered about using the Flowcode FCP_Set/Get macros in a C routine taking a pin as the argument - though this is probably frowned upon (and may result in things breaking if Flowcode is updated). Some documentation on these 'low-level' routines would be helpful (and I think these could be a 'feature' if implemented correctly!)
Martin