You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old February 7th, 2019, 08:23 PM   #1
BachPhi
Member
United States

BachPhi is offline
 
Join Date: Dec 2007
Location: Los Alamos
Posts: 270
AOI for string.replace method

I am looking for an AOI that can do string.replace(sSearch,sReplace).

Thanks.
  Reply With Quote
Old February 7th, 2019, 10:13 PM   #2
ASF
Lifetime Supporting Member
Australia

ASF is offline
 
Join Date: Jun 2012
Location: Australia
Posts: 2,841
I'd imagine it would be pretty easy to put together with a few COP, FIND, DELETE and CONCAT instructions. I've never actually built one though.
  Reply With Quote
Old February 8th, 2019, 08:01 AM   #3
BachPhi
Member
United States

BachPhi is offline
 
Join Date: Dec 2007
Location: Los Alamos
Posts: 270
Shocking! PLC programmers probably not aware of this useful function in .NET.

I ended up w/: FIND, GRT, DELETE, INSERT
  Reply With Quote
Old February 10th, 2019, 03:40 PM   #4
ASF
Lifetime Supporting Member
Australia

ASF is offline
 
Join Date: Jun 2012
Location: Australia
Posts: 2,841
Ah, I didn't even think of insert, that'd make it even easier!

PLC's are generally not geared toward string handling at all. They can do it, but it's never been a focus, because why would you do string handling in a PLC when you could do it in the HMI/OIT/software? You'd need a HMI/OIT/etc to allow for string manipulation in the first place, so it makes sense to do it at that level.

I'm curious now - I can't think of any likely reason to need a string search-and-replace function within a PLC - what's your application?
  Reply With Quote
Old February 10th, 2019, 10:39 PM   #5
Geoff White
Member
Australia

Geoff White is offline
 
Join Date: Oct 2005
Location: Brisbane
Posts: 330
I use an AOI with this in it:
if WorkString.LEN>0 and SearchString.LEN>0 then
Find(WorkString,SearchString,1,FoundPos);
if FoundPos>0 then
Delete(WorkString,SearchString.LEN,FoundPos,WorkSt ring);
Insert(WorkString,ReplaceString,FoundPos,WorkStrin g);
end_if;
end_if;
  Reply With Quote
Old February 11th, 2019, 03:15 PM   #6
BachPhi
Member
United States

BachPhi is offline
 
Join Date: Dec 2007
Location: Los Alamos
Posts: 270
Quote:
Originally Posted by ASF View Post
Ah, I didn't even think of insert, that'd make it even easier!

PLC's are generally not geared toward string handling at all. They can do it, but it's never been a focus, because why would you do string handling in a PLC when you could do it in the HMI/OIT/software? You'd need a HMI/OIT/etc to allow for string manipulation in the first place, so it makes sense to do it at that level.

I'm curious now - I can't think of any likely reason to need a string search-and-replace function within a PLC - what's your application?

Zebra Printing - further info here: https://www.advancedhmi.com/forum/in...8&topic=2209.0
  Reply With Quote
Old February 11th, 2019, 03:28 PM   #7
ASF
Lifetime Supporting Member
Australia

ASF is offline
 
Join Date: Jun 2012
Location: Australia
Posts: 2,841
So why not do the find and replace using VBA in the AAHMI before it even gets to the PLC/printer?
  Reply With Quote
Old February 11th, 2019, 03:35 PM   #8
BachPhi
Member
United States

BachPhi is offline
 
Join Date: Dec 2007
Location: Los Alamos
Posts: 270
Quote:
Originally Posted by ASF View Post
So why not do the find and replace using VBA in the AAHMI before it even gets to the PLC/printer?
If using PC & AAHMI, then yes. No PLC requirement
If using PLC only, then the new AOI will do the search & replace the variables in the ZPL string.
  Reply With Quote
Old February 11th, 2019, 05:19 PM   #9
ASF
Lifetime Supporting Member
Australia

ASF is offline
 
Join Date: Jun 2012
Location: Australia
Posts: 2,841
Right, got it. In that case, I'd probably build the ZPL string up piece by piece using CONCAT instructions, instead of starting with a complete string with placeholders and replacing them. But there are plenty of ways to skin this zebra.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Setting up a MSG in an AOI pierrer LIVE PLC Questions And Answers 7 November 22nd, 2018 03:37 PM
Editing AOI's in RS LOGIX 5000 dalcoleman LIVE PLC Questions And Answers 6 July 25th, 2018 01:22 AM
Programming Exercise: Sorting Algorithm w/Dynamic AOI Results Paully's5.0 LIVE PLC Questions And Answers 19 January 29th, 2017 04:32 PM
AB AOI design Inputs, Outputs, or InOuts? abishur LIVE PLC Questions And Answers 5 November 16th, 2016 08:55 AM
WallClock and AOI Method remullis LIVE PLC Questions And Answers 12 January 30th, 2015 04:05 PM


All times are GMT -5. The time now is 05:58 AM.


.