{"id":65494,"date":"2026-11-25T19:15:21","date_gmt":"2026-11-25T18:15:21","guid":{"rendered":"https:\/\/amit-automation.cz\/podpora\/casto-kladene-otazky\/amit-designer-napoveda\/entering-advanced-functions-equations\/"},"modified":"2026-11-25T19:15:21","modified_gmt":"2026-11-25T18:15:21","slug":"entering-advanced-functions-equations","status":"publish","type":"napoveda","link":"https:\/\/amit-automation.cz\/en\/support\/faq\/amit-designer-help\/entering-advanced-functions-equations\/","title":{"rendered":"Entering advanced functions (equations)"},"content":{"rendered":"<p style=\"text-align: justify;\">To create complex and feature-rich components, you need to enter complex formulas instead of simple variables. You can use functions anywhere you like: inside animations, instead of constants, or as a text replacement in the text fields.<\/p>\n<p style=\"text-align: justify;\">Formulas are evaluated with JavaScript, so you can enter any formula that is a valid JavaScript expression. You can also include any of the Component Variables that you have defined.<\/p>\n<p style=\"text-align: justify;\">To show the functionality, we will extend our example by implementing the scale along the slide bar we have just created.<\/p>\n<ul style=\"list-style-type: square;\">\n<li style=\"text-align: justify;\">Open the slide bar created in the previous chapter and adjust as follows:<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/myscada.org\/downloads\/manuals_image\/img_7.7.1.jpg\" alt=\"7.7.1\" width=\"294\" height=\"122\" \/><\/p>\n<ul style=\"list-style-type: square;\">\n<li style=\"text-align: justify;\">Delete the <em>Min<\/em> and <em>Max<\/em> fields and stretch the blue rectangle, including the frame. After that, insert additional lines with the <em>Drawing-Line<\/em> tool to divide the rectangle into thirds. With <em>Transforms -&gt; Order -&gt; Lower to background<\/em> send both lines and the frame into the background<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/myscada.org\/downloads\/manuals_image\/img_7.7.2.jpg\" alt=\"7.7.2\" width=\"302\" height=\"45\" \/><\/p>\n<ul style=\"list-style-type: square;\">\n<li>Now insert additional text fields.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/myscada.org\/downloads\/manuals_image\/img_7.7.3.jpg\" alt=\"7.7.3\" width=\"302\" height=\"56\" \/><\/p>\n<p style=\"text-align: justify;\">For each text field we need to specify the <em>Text<\/em> in the <em>Replacement<\/em> in the <strong>Rep.<\/strong> tab:<\/p>\n<ul style=\"list-style-type: square;\">\n<li>Left text field:\u00a0<em>(min).toFixed(1)<\/em><\/li>\n<li>Second text field (from left): <em>((min+max)\/3+min).toFixed(1)<\/em><\/li>\n<li>Second text field (from right): <em>(2*(min+max)\/3+min).toFixed(1)<\/em><\/li>\n<li>Right text field: <em>(max).toFixed(1)<\/em><\/li>\n<\/ul>\n<p style=\"text-align: justify;\">The left text field will show the value of the variable <em>min.toFixed(x)<\/em>, which is a function that rounds the result to x decimal places. In our case, the value will be formatted to show one decimal place.<\/p>\n<p style=\"text-align: justify;\">The second text field from the left should show 1\/3 of the scale; therefore, we have used the formula <em>min+(min+max)\/3<\/em> to get 1\/3 of the scale. We will use the <em>toFixed(1)<\/em> function to round the result.<\/p>\n<p style=\"text-align: justify;\">The other two text fields are similar to those two; we can add units and a label to our component to finish:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/myscada.org\/downloads\/manuals_image\/img_7.7.4.jpg\" alt=\"7.7.4\" width=\"600\" height=\"301\" \/><\/p>\n<p style=\"text-align: justify;\">To use the Label and Units text fields, we need to create two new variables. Both will be of the type \u2018string\u2019. The first variable will be named <em>label<\/em>, and the second will be named <em>unit<\/em>. For the text field label, add Text Replacement equal to the variable label. For Units text field, add Text Replacement equal to variable units. Finally, click on the <strong>Save<\/strong> button to see the changes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/myscada.org\/downloads\/manuals_image\/img_7.7.5.jpg\" alt=\"7.7.5\" width=\"350\" height=\"202\" \/><\/p>\n","protected":false},"menu_order":42,"template":"","class_list":["post-65494","napoveda","type-napoveda","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/amit-automation.cz\/en\/wp-json\/wp\/v2\/napoveda\/65494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/amit-automation.cz\/en\/wp-json\/wp\/v2\/napoveda"}],"about":[{"href":"https:\/\/amit-automation.cz\/en\/wp-json\/wp\/v2\/types\/napoveda"}],"version-history":[{"count":0,"href":"https:\/\/amit-automation.cz\/en\/wp-json\/wp\/v2\/napoveda\/65494\/revisions"}],"wp:attachment":[{"href":"https:\/\/amit-automation.cz\/en\/wp-json\/wp\/v2\/media?parent=65494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}