Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on November 11, 2019, 06:56:08 AM

Title: Indirect Referencing of UDT's
Post by: RBPLC on November 11, 2019, 06:56:08 AM
Is there any way to reference a UDT field indirectly? For example (see attached photo) I have a UDT named MP. There are 8 instances of this UDT and I know that the UDT can be referenced indirectly like this: MP[0-7], to reference MP0-MP7. Is there any way to extend this indirect referencing down to the field level? For example, if I wanted to access the third field of MP0, is there some way to do this indirectly. Is there something like: MP[0].[2] to access MP0.WP, or MP[1].[4] to access MP1.HSHIGH?
Title: Re: Indirect Referencing of UDT's
Post by: ATU on November 11, 2019, 09:47:22 AM
I think the way that I do it is you have to do an intermediate step and memcopy that instance to a flat int, real or bit array, then you use casting to choose what you want.
Title: Re: Indirect Referencing of UDT's
Post by: RBPLC on November 12, 2019, 05:05:58 PM
Looks like it can be done but I was hoping there was a direct way to do it.
Title: Re: Indirect Referencing of UDT's
Post by: BobO on November 12, 2019, 05:15:18 PM
Looks like it can be done but I was hoping there was a direct way to do it.

Sorry, no. There are massive amounts of potential fail with each index pointing to a different/unknown/changing data type.