Skip to content

HMI Split long string to 2 lines of text.

Hello,

I need to display a String on the HMI that is quite long. Too long to display on one line.
What would be the easiest way to split this string if it does not go completely on the screen and preferably where there is a space in the text?
(String describes the machine steps so it changes every step)
Or is there a function on the HMI to use 2 lines of text?

Comments

  • I am fairly sure that this answer from two years ago still applies:
    https://www.plcnext-community.net/en/discussions/multi-line-string-for-hmi.html
    ... in which case, the string may need to be split in the PLC, and displayed in two or more stacked text boxes.
  • This may not be the answer you're looking for, but someone else may find it useful. If you convert the byte value of 16#0A to a string then concatenate it with your string it will show a new line in the HMI.
    newLineBuffer is an instance of ARRAY [1..1] OF BYTE.
    newLineBuffer[1] := 16#0A
    
    BUF_TO_STRING1(REQ := TRUE
        , BUF_OFFS := 0
        , BUF_CNT := 1
        , BUFFER := newLineBuffer
        , DST := newLineChar);
    
    multiLineText := 'Line 1';
    multiLineText := CONCAT(multiLineText, newLineChar);
    multiLineText := CONCAT(multiLineText, 'Line 2');
    
  • Ooh, nice. Rob's solution is better than mine - the string still needs to be "split" in the PLC (i.e. have newline chars inserted), but it doesn't require multiple text boxes on the HMI page. Good to know.
Sign In or Register to comment.