Object array

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
keithh534
Posts: 55
Joined: Thu Nov 23, 2017 12:21 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Object array

Post by keithh534 »

Is it possible to create an object array?
If so, how is it done?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Object array

Post by kersing »

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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

keithh534
Posts: 55
Joined: Thu Nov 23, 2017 12:21 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Re: Object array

Post by keithh534 »

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.

User avatar
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

Post by Benj »

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.
ObjectTest.fcfx
(13.97 KiB) Downloaded 260 times

keithh534
Posts: 55
Joined: Thu Nov 23, 2017 12:21 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Re: Object array

Post by keithh534 »

Thank you for the explanation, albeit not what I was hoping for.
:?

User avatar
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

Post by Benj »

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.

keithh534
Posts: 55
Joined: Thu Nov 23, 2017 12:21 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Re: Object array

Post by keithh534 »

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 218 times

mnf
Valued Contributor
Valued Contributor
Posts: 1191
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Object array

Post by mnf »

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

keithh534
Posts: 55
Joined: Thu Nov 23, 2017 12:21 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Re: Object array

Post by keithh534 »

Thank you for your input. The code does exactly what I want it to do. I'm looking for a way to optimize it.

Post Reply