Displaying Multi-Line Strings in TP700 Comfort I/O Fields

David Krause15 min read
HMI ProgrammingSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Displaying Multi-Line Strings in TP700 Comfort I/O Fields with TIA Portal

A common commissioning pain point on the SIMATIC TP700 Comfort panel is the inability of a single I/O field to render a 200+ character operator message on multiple lines. The I/O field's Format property — String, Binary, Decimal, or Hex — does not include a multi-line or wrap mode, and the object is fundamentally sized for single-line operator input or output. Engineers typically discover this limitation when a diagnostic message, batch record summary, or recipe description is bound to one STRING tag and the text expands past the panel edge or gets truncated.

This reference documents three field-proven engineering approaches to display long strings on a TP700 Comfort panel: (1) embed control linefeed characters and bind the result to a multi-line text field, (2) split the source string on the PLC into several shorter tags, each shown in its own I/O field, and (3) drive internal HMI tags from a VB-style script that copies the source string into line-sized buffers. The article compares each approach, supplies SCL code for S7-1200/S7-1500, lists the relevant TIA Portal V20 configuration properties, and ends with a troubleshooting matrix and a verification procedure.

1. TP700 Comfort Panel and I/O Field Constraints

The TP700 Comfort (6AV2 124-1GC01-0AX0, 7" widescreen TFT, 800 × 480, 16 million colors) is configured with WinCC Comfort inside TIA Portal V13 SP1 through V20. The I/O field object on this panel — formally the Input/output field — supports a fixed set of display modes defined by the Format property. According to the official TIA Portal V20 documentation on the I/O field Format (RT Professional) reference, the field can display numerical values in binary, decimal, or hexadecimal, and the String display format must be selected for the field to render text.

Critical properties of the String-mode I/O field on TP700 Comfort:

  • Single-line render: The runtime draws the entire string on one horizontal line, scaled to fit horizontally rather than wrapped.
  • No line-break interpretation: ASCII 0x0A (LF) and 0x0D (CR) characters embedded in the tag value are rendered as the placeholder glyph, not as new lines, because the I/O field's text primitive is a single-line editor.
  • Length limited to tag width: Standard STRING tags carry up to 254 characters in S7-1200/1500; WSTRING up to 16382 characters. The I/O field's visible width still dictates how much is on-screen at one time.
  • Auto-sizing: When the mode is set to Fit, the field expands until it hits the screen edge — which is the typical visual symptom reported.

These behaviors are by design: the I/O field is intended for operator-entry of a single value, not for displaying multi-line messages. Long strings must be redirected to a Text field or split across multiple objects.

2. Three Engineering Solutions Compared

Approach Where Split Happens Display Object Editable by Operator? CPU Load Code Complexity
A. Control linefeed + multi-line text field PLC builds one string with embedded 0x0A Text field (multi-line) No Lowest Low
B. PLC-side segmentation into N STRINGs SCL copies substrings to N output tags N I/O fields stacked Optional per line Low Medium
C. Script-driven internal tags HMI VB script splits at runtime N I/O fields or text fields Optional per line Higher (cycles per refresh) Medium

Pick approach A when the string is read-only and the line breaks can be determined by the PLC. Pick B when the operator must edit each line independently. Pick C when the PLC code cannot be modified and the splits depend on screen width or font metrics known only at runtime.

3. Solution A: Control Linefeed Character in a Text Field

A Text field on TP700 Comfort renders embedded line breaks as actual line breaks when its Line break property is set to Yes in the Properties pane under Appearance → Text. Unlike the I/O field, the text field accepts STRING and WSTRING tags, supports multi-line display, and word-wraps when the box is narrower than the line. The runtime honors ASCII 0x0A (LF, decimal 10) within the source string.

3.1 SCL Code for S7-1200/S7-1500 — Insert Line Breaks

// FB_MessageLinebreak
// Assembles a multi-line display string from a 200-char source.
// Constants tuned for 7" Comfort @ 800x480 with default proportional font,
// approx. 38 chars per line at 14 pt.

CONST
    CHARS_PER_LINE : INT := 38;
    MAX_LINES      : INT := 6;
END_CONST

VAR
    iPos          : INT;
    iLine         : INT;
    sLine         : STRING[40];
    sBreak        : STRING[2];   // holds CHR(10)
    sAccum        : WSTRING[260];
    sRemainder    : WSTRING[254];
END_VAR

BEGIN
    sBreak := CHR(10);            // linefeed character 0x0A
    sAccum := '';
    sRemainder := sSourceMessage; // WSTRING tag, up to 254 chars

    FOR iLine := 1 TO MAX_LINES DO
        // Grab next chunk of up to CHARS_PER_LINE chars.
        iPos := 1;
        WHILE (iPos <= CHARS_PER_LINE)
              AND (iPos <= LEN(sRemainder))
              AND (MID(IN := sRemainder, L := 1, P := iPos) <> ' ')
              AND (MID(IN := sRemainder, L := 1, P := iPos) <> CHR(10))
        DO
            iPos := iPos + 1;
        END_WHILE;

        // If we ran out of room at a non-space, hard-split.
        IF iPos = CHARS_PER_LINE + 1 THEN
            iPos := CHARS_PER_LINE;
        END_IF;

        sLine := LEFT(IN := sRemainder, L := iPos);

        IF LEN(sAccum) > 0 THEN
            sAccum := CONCAT(IN1 := sAccum, IN2 := sBreak);
        END_IF;
        sAccum := CONCAT(IN1 := sAccum, IN2 := sLine);

        sRemainder := DELETE(IN := sRemainder, L := iPos, P := 1);

        IF LEN(sRemainder) = 0 THEN
            EXIT;
        END_IF;
    END_FOR;

    // sDisplayMessage is bound to the multi-line text field.
    sDisplayMessage := sAccum;
END

Key implementation notes:

  • CHR(10) returns the ASCII LF character (0x0A). The runtime interprets this as a line break inside a multi-line Text field.
  • Use WSTRING on the display side to preserve international characters; bind it to the Text field's Text property in the Animation / tag connection.
  • If the target panel is configured with a non-default font, recalibrate CHARS_PER_LINE empirically — render a test string of known length and count displayed characters per row.

3.2 TIA Portal V20 Configuration

  1. Open the screen in the project tree.
  2. Drag a Text field from the toolbox (under Basic objects) onto the screen. Position and size it where the multi-line message should appear.
  3. In the Properties pane, expand Appearance → Text. Confirm Line break = Yes and Word wrap = Yes. This is the property combination that makes the runtime honor embedded LF characters and additionally wrap overflow within the box.
  4. Expand General. Set Text to the dynamic tag path pointing at the PLC's sDisplayMessage WSTRING tag.
  5. Set the font size, color, and background as required. For 7" Comfort at 800×480, 12–14 pt is the practical maximum that still fits 38–42 characters per row.
  6. Compile and download to the panel. Trigger the FB on the PLC and verify that the text wraps as expected.
Note. The TP700 Comfort runtime interprets CHR(10) as a line break inside a multi-line Text field but the same byte sequence is rendered as a placeholder glyph inside an I/O field, even with the String display format set. Do not reuse the I/O field object for this approach — it will not work.

4. Solution B: PLC-Side Segmentation into Multiple I/O Fields

If the operator must edit each line individually — for example, to enter parameter notes per step — segment the long string into N smaller STRINGs on the PLC and bind each to its own I/O field. This approach preserves full I/O field capability (operator entry, format enforcement, mode selection) on every line.

4.1 SCL Code for Fixed-Width Line Splitting

// FB_MessageSegmentation
// Splits a 200-char source string into 6 WSTRING[42] line tags.
// Each line tag maps to one I/O field on the screen.

CONST
    CHARS_PER_LINE : INT := 38;
    NUM_LINES      : INT := 6;
END_CONST

VAR
    iLine  : INT;
    iStart : INT;
    iLen   : INT;
END_VAR

VAR_TEMP
    sBuf : WSTRING[260];
END_VAR

BEGIN
    sBuf := sSourceMessage;

    FOR iLine := 1 TO NUM_LINES DO
        iStart := (iLine - 1) * CHARS_PER_LINE + 1;
        iLen   := CHARS_PER_LINE;

        // Clamp last line to actual remaining length.
        IF (iStart + iLen - 1) > LEN(sBuf) THEN
            iLen := LEN(sBuf) - iStart + 1;
        END_IF;

        IF iLen > 0 THEN
            arrLines[iLine] := MID(IN := sBuf, L := iLen, P := iStart);
        ELSE
            arrLines[iLine] := '';
        END_IF;
    END_FOR;
END

4.2 TIA Portal V20 Configuration

  1. Declare an ARRAY[1..6] OF WSTRING[42] tag arrLines on the PLC and on the HMI tag table.
  2. Place six I/O fields on the screen, one per line. Stack them vertically with the same width as the panel content area minus margins.
  3. For each I/O field, set Mode = Input/output or Output field depending on whether the operator must edit.
  4. Under Properties → Format, set Display format = String. Confirm the field is configured per the official I/O field Format documentation.
  5. Bind Process value to HMI_tag_table::arrLines[i] for i = 1..6.
  6. If editing is enabled, set Apply value on = Exit field or Each input, and confirm that the operator can re-enter edits without the PLC overwriting them on the next cycle.

4.3 Reverse Direction: PLC Reads Operator-Edited Lines

When I/O fields are bidirectional, concatenate the line tags back to a single string on the PLC for downstream logging or printing:

// FB_LinesToMessage - rebuild the 200-char string from 6 I/O fields.
sCombined := '';
FOR iLine := 1 TO NUM_LINES DO
    sCombined := CONCAT(IN1 := sCombined, IN2 := arrLines[iLine]);
END_FOR;
sFullMessage := LEFT(IN := sCombined, L := 254);

5. Solution C: Script-Driven Internal Tags

When the source PLC cannot be modified, push the splitting logic onto the HMI itself. WinCC Comfort supports VB-style scripts bound to events such as Change value on a tag. The script reads the long string from an HMI tag, slices it into internal WSTRING tags, and lets each I/O field bind to its own internal tag.

5.1 VB-Style Script Example

' On change of HMI tag "srcMessage", split into 6 internal tags.
Dim sSrc, sLine
Dim i, iStart, iLen, iCPL

iCPL = 38
sSrc = SmartTags("srcMessage")

If sSrc = "" Then
    SmartTags("line1") = ""
    SmartTags("line2") = ""
    SmartTags("line3") = ""
    SmartTags("line4") = ""
    SmartTags("line5") = ""
    SmartTags("line6") = ""
    Exit Sub
End If

For i = 1 To 6
    iStart = (i - 1) * iCPL + 1
    iLen   = iCPL
    If iStart > Len(sSrc) Then
        SmartTags("line" & i) = ""
    Else
        If iStart + iLen - 1 > Len(sSrc) Then
            iLen = Len(sSrc) - iStart + 1
        End If
        sLine = Mid(sSrc, iStart, iLen)
        SmartTags("line" & i) = sLine
    End If
Next i

5.2 TIA Portal V20 Configuration for the Script

  1. Declare six internal WSTRING tags line1 through line6 on the HMI tag table.
  2. Drag the script into Events → Change value of the source tag srcMessage.
  3. Place six I/O fields on the screen and bind each to line1..line6 with the String display format as documented at the Siemens TIA Portal V20 I/O field Format reference.
  4. Enable Update cycle on the source tag if the value can change without a triggering event.
Performance. Splitting 200 characters in a script that fires on every value change adds about 0.3–0.6 ms of CPU load on TP700 Comfort. This is negligible for diagnostic screens but not appropriate for screens that refresh at > 1 Hz on panels with many other scripts.

6. STRING vs WSTRING on TP700 Comfort

The TP700 Comfort supports both legacy STRING (ASCII, 254 chars) and WSTRING (Unicode, 16382 chars) tags. For multi-line operator messages in any Latin, Cyrillic, or CJK language, declare the source as WSTRING to avoid truncation of non-ASCII bytes. The I/O field Format = String property accepts either type — the runtime internally transcodes as needed.

Property STRING WSTRING
Character set ASCII (single byte per char) UCS-2 / Unicode (2 bytes per char)
Max length on S7-1200/1500 254 chars 16382 chars (configured shorter in practice)
PLC function compatibility CONCAT, LEFT, RIGHT, MID, LEN, INSERT, DELETE, REPLACE, FIND, CHR Same function set with WSTRING variants
TP700 Comfort runtime support Yes Yes (firmware V14.0.1+ recommended for full WSTRING I/O)
Best use for this problem Pure ASCII diagnostic text Multi-language operator messages, recipe notes

7. Display Properties: Word Wrap, Scroll Bar, and Font

Beyond splitting the string, the visual experience depends on three properties:

  • Word wrap (Text field only): Set to Yes. Without it, a single 200-character word in the source string will not wrap and will overflow horizontally.
  • Scroll bar: For Solution B with six I/O fields, omit the scroll bar — each line has its own field. For a single Text field holding 200+ characters, enable the vertical scroll bar (Text field → Properties → Appearance → Scroll bar) when the message exceeds the box height.
  • Font size and family: TP700 Comfort defaults to the proportional Siemens Sans font. A 14 pt size renders roughly 38–42 characters per row at full panel width. Reduce to 12 pt to fit ~50 characters per row; increase to 18 pt for ~28 characters. Re-tune CHARS_PER_LINE accordingly in the PLC code.

8. Verification Procedure

  1. Download the project to the TP700 Comfort panel and to the PLC.
  2. From the PLC's watch table, force sSourceMessage to a 200-character string containing at least one LF character (Solution A) or a string with 200 ASCII characters (Solutions B and C).
  3. Switch the HMI to the configured screen. Confirm the message is fully visible across the expected number of lines.
  4. Toggle a known trigger that updates the source string every second. Confirm no flicker, no truncated rows, and no rendering artifacts.
  5. For Solutions B and C with editable I/O fields, enter a 30-character string into line 3 and confirm the PLC's reconstructed sCombined tag matches the input after the I/O field applies the value.
  6. From the panel's Control Panel → System → Logs, check that no runtime errors reference the HMI tag table or the script execution.
  7. Disconnect the PLC and reconnect — confirm the long string still renders correctly when the connection re-establishes.

9. Troubleshooting Matrix

Symptom Likely Cause Fix
I/O field shows the placeholder glyph for line breaks I/O field cannot interpret 0x0A Switch to a multi-line Text field (Solution A) or segment the string (Solutions B/C)
Text field renders the entire string on one line and overflows Line break property set to No Set Properties → Appearance → Text → Line break = Yes
Line break is interpreted but a single 60-char word still overflows Word wrap is disabled Set Properties → Appearance → Text → Word wrap = Yes, or insert spaces in the source string
Operator edits line 3 but PLC overwrites the value immediately PLC segmentation FB re-runs every cycle Trigger the segmentation FB only when the source tag changes (rising edge or compare with previous cycle)
Diacritics or CJK characters render as ? STRING used instead of WSTRING, or panel firmware < V14 Convert source to WSTRING and upgrade panel firmware to V14.0.1 or later
Script fires but line tags stay empty Script bound to wrong event Bind the script to Change value on the source tag, not to screen load
Compiled project: warning "String tag length exceeds 254 characters" Source tag declared as STRING but the FB writes 260 chars Change source tag to WSTRING[260] or reduce content
Only the first 80 characters display I/O field length set to 80 in the properties Increase Properties → General → Length to 254 (max) or use WSTRING
Panel goes slow after enabling the script Script trigger frequency too high Add a debounce (e.g., only fire when source string changed compared to last cycle) or move logic to the PLC (Solution B)

10. Field-Commissioning Tips

  • Add a manual "Length test" STRING on the screen with all 94 printable ASCII characters plus the LF. Use it to confirm your CHARS_PER_LINE value matches the rendered panel font.
  • Where possible, push the splitting logic to the PLC (Solution A or B) — scripts on the HMI panel share CPU with the runtime's tag polling and screen redraw, which can stutter under load.
  • If the message includes trailing whitespace, the runtime may suppress it. Trim with RIGHT(IN := TRIM(sSource), L := LEN(TRIM(sSource))) style logic on the PLC before assembly.
  • For multi-language deployments, keep the segmentation FB in the PLC; only the language file changes per locale.
  • Reserve at least 10% spare CPU and panel memory — large WSTRING tags and 200+ character messages consume more heap than short operator prompts.

11. Related Object Reference

Two object types on TP700 Comfort are commonly confused for this use case:

  • Symbolic I/O field: Same underlying object; "symbolic" refers to the mode, not the multi-line capability. Limited to one row by design.
  • Text field (multi-line): The recommended object for displaying the embedded-LF string from Solution A. Supports word wrap, vertical scroll bar, and multiple fonts in a single field.
  • Button with parameter set: Useful when the message must trigger an action; the button's label can also render the multi-line text if Solution A is applied.

12. FAQ

Can a TP700 Comfort I/O field render a 200-character string on multiple lines natively?

No. The I/O field is a single-line object whose Format property is limited to Binary, Decimal, Hex, or String per the TIA Portal V20 I/O field documentation. Use a multi-line Text field with an embedded LF character or split the string into multiple I/O fields.

Which character do I embed in the STRING so the Text field breaks to a new line?

Use the ASCII Line Feed character produced by CHR(10) in SCL (S7-1200/1500) or by the equivalent function on other platforms. The Comfort runtime interprets 0x0A as a line break inside a Text field whose Line break property is set to Yes. Verify on the target firmware version, since older panel images handle line breaks differently.

How many characters fit on one row of a TP700 Comfort at 14 pt?

Empirically 38–42 characters fit across the 800-pixel width with the default Siemens font at 14 pt. Use a calibration screen with all 94 printable ASCII characters to set CHARS_PER_LINE for your specific font and panel resolution.

Should I use STRING or WSTRING for the long operator message?

Use WSTRING whenever the message contains non-ASCII characters or is over 80 characters with mixed punctuation. STRING works for pure English ASCII up to 254 chars. WSTRING requires panel firmware V14.0.1 or later for full I/O support on TP700 Comfort.

My PLC segmentation FB runs every cycle and clobbers operator edits. How do I stop that?

Trigger the segmentation FB only on a rising edge of a "message changed" boolean, or compare the source tag against a stored previous value before re-splitting. Bind the segmentation block to a tag-change event rather than to a continuous cyclic OB.

Back to blog