AOI for string.replace method

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.
 
Shocking! PLC programmers probably not aware of this useful function in .NET.

I ended up w/: FIND, GRT, DELETE, INSERT
 
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?
 
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,WorkString);
Insert(WorkString,ReplaceString,FoundPos,WorkString);
end_if;
end_if;
 
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/index.php?PHPSESSID=e9e54c55d67ebd21063134df97c11948&topic=2209.0
 
So why not do the find and replace using VBA in the AAHMI before it even gets to the PLC/printer?
 
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.
 
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.
 

Similar Topics

I have a AOI, inside I have a 'Str_Source' declared as INOUT with STRING data type. It works fine using the same string data type, but I want...
Replies
10
Views
2,862
I'm creating a simple AOI for text display of Valve position feedback. i.e. Open, shut, opening ,closing, alarm etc. I created it a while back...
Replies
7
Views
2,676
Hey guys. I'm hoping you can help me out. I've created an AOI that will convert an array of type SINT, INT, or DINT to a string. I have a large...
Replies
1
Views
2,636
In a AOI if you place built in alarm like ALMD or ALMA. How can you pass the message to it when its in alarm. So it will send the message to...
Replies
7
Views
6,467
Hi everyone, i have an issue with saving a changed value in an AOI, I am using L84E, Everytime i try to save my work to SD card, the program lost...
Replies
1
Views
49
Back
Top Bottom