News:

  • October 13, 2025, 05:39:19 AM

Login with username, password and session length

Author Topic: Structures within UDT's  (Read 5754 times)

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Structures within UDT's
« Reply #15 on: July 11, 2022, 09:50:28 AM »
I tried this again after updating to 2.9.4 and the .done is still not replaced.

Hmm...  Please provide the steps to duplicate.

In 2.9.4, I tried the following.
I had 2 structures, one a block of Timers called MaintTimer that was a Timer Struct block, and another block of a UDT MaintStruct called Maint that contained a nested Timer struct field called tTimer.

1. I had logic that used MaintTimer6.Done and MaintTimer6.Acc (see attachment MaintTimer1.png)

2. I brought up the Replace dialog to replace the Timer structure MaintTimer6 with the nested Timer structure Maint6.tTimer, keeping the Match Exactly UNchecked (see attachment MaintTimer2.png)

3. It properly replaced the MaintTimer6.Done and MaintTimer6.Acc elements with Maint6.tTimer.Done and Maint6.tTimer.Acc, respectively (see attachment MaintTimer3.png).  This was not do-able when 2.9 first shipped (2.9.1).

Let me know any details of what you are seeing.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Structures within UDT's
« Reply #16 on: July 11, 2022, 02:11:13 PM »
You like 3D???  :-\
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Bolt

  • Hero Member
  • *****
  • Posts: 591
Re: Structures within UDT's
« Reply #17 on: August 10, 2022, 02:13:51 PM »
I'm noticing some Replace issues with nested structures.  I can replace Machine1 with Machine2 no problem, as long as Machine1 does not consist of any sub-structures.  However, when I try to Replace Machine1.Sensor1 with Machine1.Sensor2 or Machine2.Sensor1 it does not replace anything, no messages or popups.  Sensor1 is a sub-structure.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Structures within UDT's
« Reply #18 on: August 10, 2022, 03:27:14 PM »
I'm noticing some Replace issues with nested structures.  I can replace Machine1 with Machine2 no problem, as long as Machine1 does not consist of any sub-structures.  However, when I try to Replace Machine1.Sensor1 with Machine1.Sensor2 or Machine2.Sensor1 it does not replace anything, no messages or popups.  Sensor1 is a sub-structure.

With 2.9.4, I was able to replace a relational contact with nested structures
MyDeep4.FieldA.MyReal = MyDeep5.FieldB.MyReal2
and replace
MyDeep4.FieldA
with
MyDeep6.FieldB
(i.e. I replaced both the main structure element and the substructure element)

Pre-replace:
STRE MyDeep4.FieldA.MyReal MyDeep5.FieldB.MyReal2

Replace MyDeep4.FieldA with MyDeep6.FieldB (UNchecked Match Exactly):
STRE MyDeep6.FieldB.MyReal MyDeep5.FieldB.MyReal2

Here are my UDTs:
Code: [Select]
#BEGIN UDT_CONFIG
MyStruct
// Field Name, Data Type, Memory Layout, Read/Write, Display Format, Data View Detail
BaseKey, SDWORD, 0:0, Read-Write, Native, Short
BitA, BIT, 1:0, Read-Write, Native, Short
BitB, BIT, 1:1, Read-Write, Native, No
BitC, BIT, 1:2, Read-Write, Native, Long
SByteA, SBYTE, 1:1, Read-Write, Native, Short
SByteB, SBYTE, 1:2, Read-Write, Native, No
SByteC, SBYTE, 1:3, Read-Write, Native, Long
MyReal, REAL, 2:0, Read-Write, Native, Short
MyReal1, REAL, 3:0, Read-Write, Native, No
MyReal2, REAL, 4:0, Read-Write, Native, No
MyReal3, REAL, 5:0, Read-Write, Native, No
MyReal4, REAL, 6:0, Read-Write, Native, No
MyReal5, REAL, 7:0, Read-Write, Native, No
MyReal6, REAL, 8:0, Read-Write, Native, No
MyReal7, REAL, 9:0, Read-Write, Native, No
MyReal8, REAL, 10:0, Read-Write, Native, No
MyReal9, REAL, 11:0, Read-Write, Native, Long

MyDeepStruct
// Field Name, Data Type, Memory Layout, Read/Write, Display Format, Data View Detail
MyStringA, STRING16, 0:0, Read-Write, Native, Short
FieldA, MyStruct, 5:0, Read-Write, Native, Short
MyStringB, STRING32, 17:0, Read-Write, Native, No
Key, SDWORD, 26:0, Read-Write, Native, Short
FieldB, MyStruct, 27:0, Read-Write, Native, Long
MyStringC, STRING8, 39:0, Read-Write, Native, Long
#END

Copy a single rung having the issue, then paste the clip of a rung of your code (you can remove the SYSCONFIG section, but keep the blocks and UDT details), along with details of what you're replacing, I can try to duplicate it.  If you'd rather email, send it to support at hosteng.com with details on how to duplicate it, we can definitely look at it.  There could be an issue with a specific instruction (e.g. it works in a relational contact, but not in an INIT instruction).  It's almost always true that if we can duplicate it, we can fix it.

Bolt

  • Hero Member
  • *****
  • Posts: 591
Re: Structures within UDT's
« Reply #19 on: August 11, 2022, 02:20:32 AM »
Well, I imported your structures into a new project, and it worked as you said.  Then I copied and pasted some of my program's INIT instructions into the new project, and Replace worked fine there.  Copied some contacts and MATH instructions over, it still worked, even when limiting it to a specific rung.  Go back to my original project, and try some rung specific replaces there, and it works as well.  Now I'm thoroughly confused.  Thought it maybe isn't working without first Accepting changes, nope that still works.  It even lets me replace "up" a level, from My1.Deep.Element to My1Deep.Element, if structures match, of course, as expected.

I don't understand. I've tried to replace structures dozens of times these last few days, and manually changed hundreds of structure entries because of it not working.  Even tried to do it with help of text editor, but that was more trouble than it's worth.  Now, I'm pretty much done, and it works as expected.

Thanks for looking into it.  I promise I'm not crazy...

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Structures within UDT's
« Reply #20 on: August 11, 2022, 09:23:23 AM »
Software does exactly what you tell it to do, not necessarily what you want it to do.  Trust me, there is some explanation for the behavior you saw, including possible settings in the Replace dialog.

Do you use Locked code blocks (where you give a specific code block a password)?  Replace will only replace code that is in a locked password protected code block when it is UNlocked (i.e. you've entered the password to allow viewing/editing).  There is no message that the Replace operation skipped over the locked code block, we don't want anyone knowing anything about a locked code block (other than the fact it exists) - secure is secure is secure.

Also realize this issue was fixed after the initial 2.9 shipped (2.9.3?), so if you have multiple PCs/laptops (e.g. one in your office, a laptop on the factory floor, etc.), possibly you were trying it on an "old" 2.9 version?

Regardless, glad it's working!