Shortening a string (pulling only a few characters out of it)

Brandon_K

Member
Join Date
Mar 2016
Location
Pittsburgh, PA
Posts
150
Hey guys.

On all of the new builds we're doing I'm trying to get the program revision to display on the onboard OELD display. I'm guilty of not always manually updating it.

The PLC (AD Productivity 2000) has a 50 character system string that contains the program name as I have saved / named it on the PC. So typically it's something like "Customer_Name_Game_Name_Rx.xx.adpro". The revision is always the last 5 characters of the name, before the .adpro extension.

How can I go about pulling just the revision number out of that string? I basically need to drop the last 6 characters (.adpro), keep the next 5 (Rx.xx) and drop everything previous to that.

From there I can copy or repack it into a string usable on the OLED display.
 
I think you will need to make use of the SLEN (string length) function to find the length of the string then use the result to compute the start character index for use in the EXTS (Extract String) function.

I have used the OLED display quite a bit but I have not used those two functions I am suggesting, I just read about them in the software help file.
 
Brilliant! Thanks OkiePC! I've been working with the P2K for a while now and I don't remember ever coming across those instructions. Thanks!

I've attached a screenshot of my code should anyone want to replicate something similar.

Theory;

SLEN determines how many characters the total string is

MATH; Subtracts 10 from the output of the SLEN instruction as the tail of the filename is always the same. This gives me a starting point to extract from.

EXTS; Extracts 5 characters from "x" characters in (determined by SLEN and MATH)

stringextract.jpg
 

Similar Topics

I am creating a global object in FTView SE 13. I want to have a string read from the PLC and display (in this case the tagname). So lets say...
Replies
4
Views
167
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
427
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
128
As the title says, I'm using CCW with a PV800 (and Micro850). I've made a scheduler in which a user can choose a month, day (1-31), hour (0-23)...
Replies
15
Views
507
Hello, So i managed to read the string coming from control logix and put a string display in PanelView 800. Now I am struggling to do the other...
Replies
1
Views
138
Back
Top Bottom