News:

  • October 20, 2026, 03:28:01 AM

Login with username, password and session length

Author Topic: Replace just part of the address?  (Read 9139 times)

jcb

  • Full Member
  • ***
  • Posts: 41
Replace just part of the address?
« on: May 13, 2020, 03:57:51 PM »
I tend to write my code in blocks that i feel make since. Example

C123 = HMI PB
C223 = PB Oneshot
C323 = Output Set to Run
C423 = HMI PB Fault Reset
C523 = Starter Faulted
Y23 = Starter Output
X23 = Aux Input

Then I might have a whole routine for these MCC Controls. In the past i would just copy and paste and update the address values manually.

I just started using the Replace Function and the add to list works well do double check everything is good and then updating a block. Cuts down on the typo's or missed instructions.

I was just wondering if there was a way to say just change 23->24 so that it left the C1xx , C2xx, C3xx, C4xx,C5xx alone and only updated the last two digits.

Thanks
John.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3851
    • Host Engineering
Re: Replace just part of the address?
« Reply #1 on: May 13, 2020, 04:14:06 PM »
Sorry, no.

What you could try is to use Project Export and utilize a more advanced text editor to do that, then Project Import.  There are much more advanced text editors out there that let you do all kinds of cool stuff like that.

Have you looked at User Data Types?  This completely eliminates the need for knowing how/where these bits are mapped.  Create a UDT called MachineStruct with the fields you have

.HMIPB
.PBOneShot
.OutputSetToRun
.HMIPBFaultReset
.StarterFaulted
.StarterOutput
.AuxInput

Create a block of 10 of those e.g. Machine of type MachineStruct, then access

Machine0.HMIPB
vs.
Machine2.HMIPB
vs.
Machine0.AuxInput

or even use array indexing

Machine[V0].HMIPB where V0 can equal 0..9

Then at Top of Scan, move your X's to the various actual .AuxInput members, and similarly at Bottom Of Scan, move your .StarterOutput members to the various actual Y's.

jcb

  • Full Member
  • ***
  • Posts: 41
Re: Replace just part of the address?
« Reply #2 on: May 13, 2020, 04:26:06 PM »
I honestly never thought of using a UDT for something that simple, but it makes perfect sense.

I will give that a try.

Thanks.
John.


franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3851
    • Host Engineering
Re: Replace just part of the address?
« Reply #3 on: May 13, 2020, 04:45:24 PM »
I honestly never thought of using a UDT for something that simple, but it makes perfect sense.

I will give that a try.

Thanks.
John.

From your question, you seemed to have a very logical/structured/well-thought-out elements of your ladder logic.  UDTs are just an extension of that mindset.

Note that you can also create heap items, not just blocks of structure types.   And you can create multiple blocks of the same structure.  For example, you might have a structure called RecipeStruct, then have 2 blocks of RecipeStruct's
CurrentRec0..99
that operators can select/edit from
OriginalRec0..99
the "Original" set of recipes that can NEVER be edited, that were written in stone from Corporate, but where they can be RESTORED back INTO CurrentRec0..99

jcb

  • Full Member
  • ***
  • Posts: 41
Re: Replace just part of the address?
« Reply #4 on: May 13, 2020, 06:21:47 PM »
Yes I just Created a UDT called Motors and added all my Elements for Basic Motor Control.

Then Created a Block Called MCC ranging 0-999.

I can now address my Motor Controls as MCC245.SetToRun or MCC245.Faulted and it is very easy to do the search and replace I was looking for by just changing MCC245 to MCC246.

It's also nice because we Tag our Motor Control Buckets with Numbers so for troubleshooting the other electricians know right where to go from the Name in the Logic.

Another added bonus is by Giving the MCC245 a nickname of BSC_AUGER i get automatic nicknames that actually display the definition of my UDT Like BSC_AUGER.SettoRun and break the 16 character barrier.

This also appears to export and import to the EA9 which also makes my job way easier.

Thanks for the fast response. You saved me a ton of time on the code and touchscreen side.

Have a great week,
John.
 
« Last Edit: May 13, 2020, 06:38:09 PM by jcb »

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3851
    • Host Engineering
Re: Replace just part of the address?
« Reply #5 on: May 14, 2020, 08:36:35 AM »
You saved me a ton of time on the code and touchscreen side.

That's what good tools are supposed to do.  Glad it's working out!!