Mingcedar

Product: Mingcedar Studio DESIGNER

Script Text | Mingcedar Studio

Script Text displays an evaluated string, including units, decimal formatting, conditional wording or multiple values.

Published Updated

<div class="manual-doc-article manual-doc-article-section"><h2 id="script-text">Text: Script Text</h2>

Script Text displays an evaluated string, including units, decimal formatting, conditional wording or multiple values.

<div class="doc-card-list">

<article class="doc-card">

<h3 id="script-text-item-1">Overview</h3>

<p>Script Text is under Behaviors → Text. Bind it to a text box or text-capable shape; Display Text determines the content. Use Tag Text to display a single Tag.</p>

</article>

<article class="doc-card">

<h3 id="script-text-item-2">Field configuration</h3>

<p>Setup Script prepares data, Display Text returns the string and Condition controls execution. Place each example part in its labeled field. Clear the default Setup Script if no preparation is needed.</p>

<ul>

<li>Setup Script: preparation area. Read tags, define variables, compute intermediate values (can be multi-line).</li>

<li>Display Text: return the string to display.</li>

<li>Condition: true applies the text; false skips the behavior.</li>

<li>Use quality outline colors: apply the Good or Bad border color according to communication quality. The border does not represent the process value or alarm state.</li>

</ul>

<div class="manual-code" data-code-language="javascript"><div class="manual-code-toolbar"><span>JavaScript</span><span class="manual-code-tools"><small>JavaScript</small><button type="button" data-copy-code data-copied="Copied" data-failed="Select and copy the code" aria-label="Copy code: JavaScript">Copy code</button><span class="manual-code-status" role="status"></span></span></div><pre tabindex="0" class="docs-code-block shiki github-light" style="background-color:#fff;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#6A737D">// Setup Script</span></span>

<span class="line"><span style="color:#D73A49">var</span><span style="color:#24292E"> pressure </span><span style="color:#D73A49">=</span><span style="color:#6F42C1"> ReadTagDouble</span><span style="color:#24292E">(</span><span style="color:#032F62">"PLC_LINE01.AIR01.PRESSURE"</span><span style="color:#24292E">, </span><span style="color:#005CC5">0.0</span><span style="color:#24292E">);</span></span>

<span class="line"></span>

<span class="line"><span style="color:#6A737D">// Display Text</span></span>

<span class="line"><span style="color:#032F62">"Pressure: "</span><span style="color:#D73A49"> +</span><span style="color:#24292E"> pressure.</span><span style="color:#6F42C1">toFixed</span><span style="color:#24292E">(</span><span style="color:#005CC5">1</span><span style="color:#24292E">) </span><span style="color:#D73A49">+</span><span style="color:#032F62"> " bar"</span></span></code></pre></div>

</article>

<article class="doc-card">

<h3 id="script-text-item-3">When to use it</h3>

<p>Use for formatted or combined dynamic information.</p>

<ul>

<li>Show a measurement with units and fixed decimals, e.g. &quot;Pressure: 3.2 bar&quot;.</li>

<li>Combine several tags into one line, e.g. &quot;Pump1 RUN / Speed 1450 rpm&quot;.</li>

<li>Output different wording by condition, e.g. &quot;Running&quot; when on, &quot;Stopped&quot; when off.</li>

</ul>

</article>

<article class="doc-card doc-card-warn">

<h3 id="script-text-item-4">Troubleshooting</h3>

<p>The Display Text field is an expression position that returns a single value, not a full script.</p>

<ul>

<li>Do not put fetch, setTimeout, or other async code in Display Text; it needs an immediate value; put such logic in a script body like Page Script/Click Script.</li>

<li>Keep heavy reads and calculations in Setup Script; let Display Text only do the final assembly.</li>

<li>Always read tags with a quoted tag name and a fallback, e.g. ReadTagDouble(&quot;PLC_LINE01.AIR01.PRESSURE&quot;, 0.0); avoid bare tag-like text.</li>

<li>The quality border represents communication quality (good/bad), not the process state.</li>

</ul>

</article>

</div>

<div class="docs-note-grid manual-doc-image-grid">

<figure class="docs-note-card manual-doc-image-card" id="script-text-image-1">

<img src="/WEB_img/HQPPT/current/text/script-text.png" alt="Script Text behavior editor" loading="lazy" decoding="async" />

<figcaption>

<strong>Figure 1: Script Text editor</strong>

<p>Read tags and compute in Setup Script, then return the final string to display in Display Text.</p>

</figcaption>

</figure>

</div>

</div>