adccommunitymod (AutomationDirect) asked a question.

Need some help understanding strings

Created Date: February 23,2018

Created By: div_by_zero

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I am in need of some help understanding strings. Say on my HMI (a C-More EA9 in this case, which is paired with a Productivity 2000 PLC) I want to have a dynamic sentence like this: "I have a (cat / dog) that is xx (year / years) old. " The sentence could either have "cat " or "dog " in it, xx could be any number from 1-99, and either "year " or "years " could be used. How is this done? I am assuming this is what strings are for? To be honest, I don't know much about them. Thnks for any help!


  • adccommunitymod (AutomationDirect)

    Created Date: February 23,2018

    Created by: div_by_zero

    I am in need of some help understanding strings.

    Say on my HMI (a C-More EA9 in this case, which is paired with a Productivity 2000 PLC) I want to have a dynamic sentence like this:

    "I have a (cat / dog) that is xx (year / years) old. "

    The sentence could either have "cat " or "dog " in it, xx could be any number from 1-99, and either "year " or "years " could be used.

    How is this done?

    I am assuming this is what strings are for?

    To be honest, I don't know much about them.

    Thnks for any help!

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 23,2018

    Created by: plcnut

    What PLC will you be using?

  • adccommunitymod (AutomationDirect)

    Created Date: February 23,2018

    Created by: Ridgeline Mach

    What PLC will you be using?

    Maybe it was stated after his edit; P2K.

  • adccommunitymod (AutomationDirect)

    Created Date: February 23,2018

    Created by: div_by_zero

    What PLC will you be using?

    Sorry, P2K.

    After your reply, I edited my original post, then replied to you, but my reply didn't post for some reason.

  • adccommunitymod (AutomationDirect)

    Created Date: February 23,2018

    Created by: plcnut

    Sorry, I won't be any help with PxK.

    In Do-more I would use STRPRINT, with V0 as the "Pet selector ", V1 as the "Pet age ", and then have a MATH box that would turn C0 on if V1>1.

    "I have a " Lookup(V0, "cat ", "dog ") " that is " V1 " " Lookup(C0, "year ", "years ") " old. "

  • adccommunitymod (AutomationDirect)

    Created Date: February 23,2018

    Created by: div_by_zero

    Sorry, I won't be any help with PxK.

    In Do-more I would use STRPRINT, with V0 as the "Pet selector ", V1 as the "Pet age ", and then have a MATH box that would turn C0 on if V1>1.

    "I have a " Lookup(V0, "cat ", "dog ") " that is " V1 " " Lookup(C0, "year ", "years ") " old. "

    Thanks for the reply. I'll see if I can find something similar in P2K.

    So I'm thinking that regardless of the platform, I'm going to be assembling the string on the PLC, then simply displaying it on the HMI...

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 23,2018

    Created by: OkiePC

    Thanks for the reply. I'll see if I can find something similar in P2K.

    So I'm thinking that regardless of the platform, I'm going to be assembling the string on the PLC, then simply displaying it on the HMI...

    I generally avoid linking strings in the PLC to text on the HMI. There are cases where the PLC is required to process strings like barcode readers and such, but if the PLC does not need to know the actual text, it is much more efficient to simply encode the text you want displayed as a number in a list of messages. I don't use the C-more much, but all HMI that I have used do support the use of a message display object that takes a value and links it to a list of text items.

    So in your case, if the only dynamic piece is the binary choice of cat or dog, and the value of its age, you could do that with a single bit and an integer.

    Expand Post