Discussing the article: "MQL5 Developer Gotchas (Part 2): A Multi-Line Text Block for Chart Labels Beyond the 63-Character Limit"

Check out the new article: MQL5 Developer Gotchas (Part 2): A Multi-Line Text Block for Chart Labels Beyond the 63-Character Limit.

CLabelBlock lets an EA show a long text as labels wrapped by pixel width and detect a truncated label. On the tested builds, native text objects and object names keep only the first 63 UTF-16 code units without an error. CCanvasBlock draws wider lines on one bitmap without that cap but cannot read its text back. Unit tests and screenshot checks cover one system and a few fonts.

A status line of 158 characters that I set on an OBJ_LABEL object in the demo script of this article ended in the middle of a word. The chart showed "...3 open positions, floatin" and nothing after that. The ObjectSetString() call had returned true, and GetLastError() returned 0. When I read the text back from the object, I got the first 63 characters.

This article is the second part of a series on MQL5 behaviors that compile and run but produce wrong results without any message. Part 1 treated the input group lines that shift the parameters of iCustom(). Here the subject is the text of chart objects. On build 6230, each of the five native text object types that I tested kept 63 UTF-16 code units of a longer text and dropped the rest without a message. A panel that shows an order comment, a news headline, or a status sentence of more than 63 code units loses the end of the text in the same way.

Author: Ali Akbar