{"id":3355,"date":"2026-11-17T18:42:51","date_gmt":"2026-11-17T10:42:51","guid":{"rendered":"https:\/\/resource.fatek.com\/index.php\/2026\/11\/17\/p5hmi-fvd-en-13\/"},"modified":"2026-11-17T18:42:51","modified_gmt":"2026-11-17T10:42:51","slug":"p5hmi-fvd-en-13","status":"publish","type":"post","link":"https:\/\/resource.fatek.com\/index.php\/2026\/11\/17\/p5hmi-fvd-en-13\/","title":{"rendered":"Chapter 13 Script"},"content":{"rendered":"<p>Script provides a simple language to allow users to write their own programs. Available statements include logical judgments, numerical computations, loop executions etc. Users can flexibly use the statements provided by the system to complete a complex task that cannot easily be accomplished with general objects. Existing scripts previously created could also be reused in different projects to save development time.<\/p>\n<h3>13.1 Using Scripts<\/h3>\n<p>In this section, we will introduce how to create and edit the scripts and its related attributes.<\/p>\n<h4>13.1.1 Script List<\/h4>\n<p>Click on\u3010Script\u3011in\u3010Functions\u3011of the\u3010Project Explorer\u3011, which is located to the left side of the FvDesigner, to enter the\u3010Script List\u3011.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-001.png\" \/><\/p>\n<p>Figure 175\u3010Script List\u3011<\/p>\n<p>The following are the description of each column in the script list:<\/p>\n<p>Table 78\u3010Script List\u3011- Descriptions<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Field<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010ID\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Every script must have a unique ID; the range of the ID is from 0 to 65534.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Comment\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Descriptions that help understand the contents or usage of a script.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Password\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Whether this script is protected by password or not. <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Trigger Condition\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Set the conditions that the script will be triggered in the background.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Run at Startup\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Set to execute the script when the project starts.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Valid\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Valid means that no errors were found when the script was compiled.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Reference\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>When a script is used in an object or function, pressing\u3010Go to\u3011can jump to the location where this script is used immediately.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>The following are the descriptions of the buttons on the right side of the script list:<\/p>\n<p>Table 79 Script List\u2013Descriptions of the buttons on the right side<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Button<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Add\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Opens the\u3010Script Editor\u3011and a new empty script to edit.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Edit\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Opens the\u3010Script Editor\u3011and allows the script currently selected in the Script List to be edited; double-clicking on the script of a Script List has the same effect as selecting the script first and then pressing\u3010Edit\u3011.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Duplicate\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Makes a duplicate of the currently selected script.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Delete\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Deletes the currently selected script.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Import\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Imports scripts.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Export\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Exports the currently selected script.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Custom Functions\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Opens the\u3010Script Editor\u3011and displays the\u3010Custom Functions\u3011for editing.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<h4>13.1.2 Script Editor<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-002.png\" \/><\/p>\n<p>Figure 176 Script Editor Screen<\/p>\n<p>The\u3010Function\u3011block to the left has three tab pages available for selection; Their descriptions are as follows:<\/p>\n<p>Table 80 Script Editor\u2013Function Block Description<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Tab Page<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Basic Functions\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Provides a convenient interface for inputting various operators, logical statements and iterative statements; the following menu will appear when users click on the pull-down menu button:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-003.jpg\" \/><\/p>\n<p>Users can select the item to use and the contents of the\u3010Basic Function\u3011tab page will be updated according to the selected item. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-004.png\" \/><\/p>\n<p>Users can quickly input or select the register and data type to use as parameters. Once selected, press\u3010Insert\u3011to add the entire statement into the location where the cursor is located in the editor to the right. The usage description and examples of this statement can be checked below the\u3010Insert\u3011button.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Built-in Function\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Provides a convenient interface to input the system\u2019s built-in functions. Its usage is similar to that of\u3010Basic Functions\u3011, the following menu will appear after the user clicks on the pull-down menu button:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-005.jpg\" \/><\/p>\n<p>Users can select the item to use from the menu and then the contents of the\u3010Built-in Function\u3011tab page will be updated according to the selected item.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-006.jpg\" \/><\/p>\n<p>Users can quickly input or select the registers and its data type to use as parameters. Once selected, press\u3010Insert\u3011to add the entire statement into the location where the cursor is located in the editor to the right. The usage description and examples of this built-in function can be checked below the\u3010Insert\u3011button.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Custom Functions\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Provides users with list of custom functions.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-007.png\" \/><\/p>\n<p>\u3010Call\u3011<\/p>\n<p>Inserts and calls the statement of the currently selected custom function at the location where the cursor is located in the editing section to the right. <\/p>\n<p>\u3010Create\u3011<\/p>\n<p>Creates a new custom functions; the following window will appear once this button is pressed, asking for the name of the custom function. <\/p>\n<p><img decoding=\"async\" alt=\"C:\\Users\\chien yu\\Desktop\\fv 1.5 pic\\t231_2.JPG\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-008.jpg\" \/><\/p>\n<p>A new editor tab page will appear in the\u3010Editor\u3011section to the right for editing the contents of the custom function after entering a legal function name and pressing OK.<\/p>\n<p>\u3010Edit\u3011<\/p>\n<p>Opens a new editor tab page for editing the currently selected custom function. It has the same effect as double-clicking on the function name on the list.<\/p>\n<p>\u3010Delete\u3011<\/p>\n<p>Deletes the currently selected custom function.<\/p>\n<p>\u3010Import\u3011<\/p>\n<p>Import custom function. If it is protected by password, you have to input password before import.<\/p>\n<p>\u3010Export\u3011<\/p>\n<p>Export the selected function.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>Descriptions of the top section of the\u3010Editor\u3011to the right are as follows:<\/p>\n<p>Table 81 Script Editor\u2013Script Properties Descriptions<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Field<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Comment\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Used to input a comment for the script.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010ID\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Used to set the ID of the script.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Protect by Password\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>To decide whether this script is protected by password or not.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Trigger\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Selects when to trigger this script:<\/p>\n<p>\u3010None\u3011<\/p>\n<p>Do not select any triggering condition (but the script may still be executed when the project starts or triggered by other objects or functions).<\/p>\n<p>\u3010Timer\u3011<\/p>\n<p>Script will be triggered continuously but there will be a fixed delay time between the end of the first execution and the start of the next execution.<\/p>\n<p>\u3010When Bit Becomes 1\u3011<\/p>\n<p>Executes the script once when the\u3010Bit\u3011changed from 0 to 1.<\/p>\n<p>\u3010While Bit is 1\u3011<\/p>\n<p>Executes the script continuously once the\u3010Bit\u3011is 1.<\/p>\n<p>\u3010When Bit Becomes 0\u3011<\/p>\n<p>Executes the script once when the\u3010Bit\u3011changed from 1 to 0.<\/p>\n<p>\u3010While Bit is 0\u3011<\/p>\n<p>Executes the script continuously once the\u3010Bit\u3011is 0.<\/p>\n<p>\u3010When Bit is Changed\u3011<\/p>\n<p>Executes the script once when the\u3010Bit\u3011changed from 0 to 1 or 1 to 0.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Run Once when Project Starts\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>Set to execute the script once when the project first starts.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Name\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>The other fields above will disappear when editing a custom function except\u3010Protect by password\u3011, only the name of the custom function can be set. <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u3010Continue when Connection Failed\u3011<\/strong><\/p>\n<\/td>\n<td>\n<p>When there are using external registers in the script, it will stop executing when the connection failed. This function will ignore the connection failed part and execute other parts of the script.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>The mid-bottom section of the\u3010Editor\u3011is divided into the statement editing section and compilation message display section; Every time a change is made in the statement editing section it will make the script compile again immediately, and the compilation results will be displayed below. The user can fix statement errors according to the message content and line number displayed until it displays\u3010Compilation succeeded\u3011.<\/p>\n<h3>13.2 When to execute scripts<\/h3>\n<p>Scripts can be set to be triggered and executed at the following different times:<\/p>\n<ul>\n<li><strong>Global<\/strong><\/li>\n<\/ul>\n<ol>\n<li>Project startup: Execute when the project starts.<\/li>\n<li>Timer: After the script has finished executing, wait a fixed period of time and then execute again.<\/li>\n<li>Trigger by Bit: Execute the script when the status or changes of a specific bit meet the conditions (Please refer to <strong>Table 81 Script Editor\u2013Script Properties Descriptions<\/strong> on the explanations for\u3010Trigger\u3011).<\/li>\n<\/ol>\n<ul>\n<li><strong>Screen<\/strong><\/li>\n<\/ul>\n<ol>\n<li>Screen open: Execute the script when a specific screen is opened.<\/li>\n<li>Screen close: Execute the script when a specific screen is closed.<\/li>\n<li>Screen cycle: Execute the script periodically when a specific screen is displayed in the foreground.<\/li>\n<\/ol>\n<ul>\n<li><strong>Object<\/strong><\/li>\n<\/ul>\n<ol>\n<li>Bit Switch: Execute scripts when the actions meets the conditions.<\/li>\n<li>Function Switch: Execute scripts when a switch is pressed.<\/li>\n<\/ol>\n<ul>\n<li><strong>Schedule<\/strong><\/li>\n<\/ul>\n<ol>\n<li>Execute scripts at the beginning or ending of a scheduled time.<\/li>\n<\/ol>\n<h3>13.3 Script Syntax<\/h3>\n<h4>13.3.1 Basic<\/h4>\n<p>\u203bNotice : If you need to use data types other than 16Bits-UINT, you must use the taqs set in the \u3010Tag Library\u3011, and it could be recognize when you use it in Script, unused tags will use 16Bit-UINT operations.<\/p>\n<h5>13.3.1.1 Assignment<\/h5>\n<p>Assignment operators can be used to save constants into registers or save the contents of the source register into the target register.<\/p>\n<p>Table 82 Script\u2013Assignment<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Assignment<\/strong><\/p>\n<p><strong>=<\/strong><\/p>\n<\/td>\n<td>\n<p>Saves constants into registers, for example<\/p>\n<p>$U:V1 = 1234  \/\/ Saves integer 1234 into $U:V1<\/p>\n<p>$T:FLOAT = 345.67 \/\/ Saves the float integer345.67 into $T:FLOAT<sup>(1)<\/sup><\/p>\n<p>$T:STRING = &quot;FATEK&quot; \/\/ Saves the ASCII string into $T:STRING<sup>(2)<\/sup><\/p>\n<p>Saves the contents of the source register into the target register, for example:<\/p>\n<p>$U:V0 = $U:V3 \/\/ Saves the contents of register$U:V3 into$U:V0<\/p>\n<p>When the data type of the target register is different from the source register, the value read from the source register will first be converted and then saved into the target register. Rounding of decimal places and overflow may occur according to the different data types, for example:<\/p>\n<p>$U:V0 = 0xFFFFFFF \/\/ Only saves 0xFFFF into $U:V0(<strong>16Bit-UINT<\/strong>)<\/p>\n<p>$T:INT32 = 345.67 \/\/  Only saves 345 into $T:INT32(<strong>32Bit-INT<\/strong>)<\/p>\n<p>$T:BCD16 = 1234 \/* Converted 1234 into BCD format and then save, therefore the actual value saved into $T:BCD16 is 0x1234 *\/<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Negative Sign<\/strong><\/p>\n<p><strong>= !<\/strong><\/p>\n<\/td>\n<td>\n<p>Changes operand to positive or negative. If the operand is a positive value, it will return a negative value; if the operand is a negative value, it will return a positive value. For example:<\/p>\n<p>$T:INT16 = 123<\/p>\n<p>$T:INT16 = -$T:INT16 \/\/ The value of $T:INT16 changed to -123<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Complement <\/strong><\/p>\n<p><strong>= ~<\/strong><\/p>\n<\/td>\n<td>\n<p>Returns 1&#8217;s complement of the operand, for example:<\/p>\n<p>$U:V0 = 0x5a5a<\/p>\n<p>$U:V0 = ~$U:V0 \/\/ The value of $U:V0 changed to 0xa5a5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Assignment<\/strong><\/p>\n<p><strong>= \u201c \u201c<\/strong><\/p>\n<\/td>\n<td>\n<p>After establishing an ASCII label in the label library, you can write the ASCII string into the depositor through the script. <\/p>\n<p>For example:<\/p>\n<p>$T:Ascii =  &quot;ABCD&quot;<\/p>\n<p>Put a Text Input\/Display on screen, <\/p>\n<p>choose Ascii String for Text Type in setting,<\/p>\n<p>choose $T:Ascii for Monitor Address in setting,<\/p>\n<p>then the content will present ABCD.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Assignment<\/strong><\/p>\n<p><strong>= L\u201c \u201c<\/strong><\/p>\n<\/td>\n<td>\n<p>After establishing an Unicode label in the label library, you can write the Unicode string into the depositor through the script. <\/p>\n<p>For example:<\/p>\n<p>$T:Unicode =  &quot;ABCD&quot;<\/p>\n<p>Put a Text Input\/Display on screen, <\/p>\n<p>choose Unicode for Text Type in setting,<\/p>\n<p>choose $T: Unicode for Monitor Address in setting,<\/p>\n<p>then the content will present ABCD.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>Note that every character in an ASCII string will take up a byte, and a 0 will be added at the end as the end of a string (which is called a null-terminating character); therefore when \u201cFATEK\u201d is written, the content of the 3 words starting from $T:STRING will be 0x4146(&#8216;F&#8217;,&#8217;A&#8217;), 0x4554(&#8216;T&#8217;,&#8217;E&#8217;), and 0x004B(&#8216;K&#8217;, 0) respectively. <\/p>\n<p>Table 83 Script\u2013Arithmetic<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Example<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Addition<\/strong><\/p>\n<p><strong>+<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 3 + 1 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Subtraction<\/strong><\/p>\n<p><strong>&#8211;<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 6 &#8211; 2 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Multiplication<\/strong><\/p>\n<p><strong>*<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 2 * 2 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Division<\/strong><\/p>\n<p><strong>\/<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 8 \/ 2 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Modulus<\/strong><\/p>\n<p><strong>%<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 9 % 5 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Bitwise-and<\/strong><\/p>\n<p><strong>&amp;<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 12 &amp; 4 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Bitwise-or<\/strong><\/p>\n<p><strong>|<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 0 | 4 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Bitwise-xor<\/strong><\/p>\n<p><strong>^<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 65531 ^ 65535 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Left shift<\/strong><\/p>\n<p><strong>&lt;&lt;<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 1 &lt;&lt; 2 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Right shift<\/strong><\/p>\n<p><strong>&gt;&gt;<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0 = 8 &gt;&gt; 1 \/\/ Result is 4<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>Table 84 Script\u2013Logical<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Example<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Logical and<\/strong><\/p>\n<p><strong>&amp;&amp;<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0.0 = 1 &amp;&amp; 1 \/\/ Result is 1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Logical or<\/strong><\/p>\n<p><strong>||<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0.0 = 0 || 1 \/\/ Result is 1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Equal<\/strong><\/p>\n<p><strong>==<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0.0 = 2 == 2 \/\/ Result is 1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Not equal<\/strong><\/p>\n<p><strong>!=<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0.0 = 1 != 2 \/\/ Result is 1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Less than<\/strong><\/p>\n<p><strong>&lt;<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0.0 = 1 &lt; 2 \/\/ Result is 1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Less than or equal<\/strong><\/p>\n<p><strong>&lt;=<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0.0 = 2 &lt;= 2 \/\/ Result is 1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Greater than<\/strong><\/p>\n<p><strong>&gt;<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0.0 = 2 &gt; 1 \/\/ Result is 1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Greater than or equal<\/strong><\/p>\n<p><strong>&gt;=<\/strong><\/p>\n<\/td>\n<td>\n<p>$U:V0.0 = 2 &gt;= 2 \/\/ Result is 1<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>When there are multiple operators for a statement, their precedence are as shown in the table below:<\/p>\n<p>Table 85 Script\u2013Operator precedence<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>0(Highest)<\/strong><\/p>\n<\/td>\n<td>\n<p>(  )<\/p>\n<\/td>\n<td>\n<p>Parenthesis<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>1<\/strong><\/p>\n<\/td>\n<td>\n<p>! \u2013 ~ <\/p>\n<\/td>\n<td>\n<p>Reverse logic, negative sign, 1&#8217;s complement<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>2<\/strong><\/p>\n<\/td>\n<td>\n<p>*\u00a0\u00a0\u00a0\/\u00a0\u00a0\u00a0%<\/p>\n<\/td>\n<td>\n<p>Multiplication, division, modulus<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>3<\/strong><\/p>\n<\/td>\n<td>\n<p>+\u00a0\u00a0\u00a0\u2212<\/p>\n<\/td>\n<td>\n<p>Addition, subtraction<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>4<\/strong><\/p>\n<\/td>\n<td>\n<p>&lt;&lt;\u00a0\u00a0\u00a0&gt;&gt;<\/p>\n<\/td>\n<td>\n<p>Left shift, right shift<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p><strong>5<\/strong><\/p>\n<\/td>\n<td>\n<p>&lt;\u00a0\u00a0\u00a0&lt;=<\/p>\n<\/td>\n<td>\n<p>Less than, less than or equal<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&gt;\u00a0\u00a0\u00a0&gt;=<\/p>\n<\/td>\n<td>\n<p>Greater than, greater than or equal<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>6<\/strong><\/p>\n<\/td>\n<td>\n<p>==\u00a0\u00a0\u00a0!=<\/p>\n<\/td>\n<td>\n<p>Equal, not equal<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>7<\/strong><\/p>\n<\/td>\n<td>\n<p>&amp;<\/p>\n<\/td>\n<td>\n<p>Bitwise-and<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>8<\/strong><\/p>\n<\/td>\n<td>\n<p>^<\/p>\n<\/td>\n<td>\n<p>Bitwise-xor<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>9<\/strong><\/p>\n<\/td>\n<td>\n<p>|<\/p>\n<\/td>\n<td>\n<p>Bitwise-or<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>10<\/strong><\/p>\n<\/td>\n<td>\n<p>&amp;&amp;<\/p>\n<\/td>\n<td>\n<p>Logical-and<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>11<\/strong><\/p>\n<\/td>\n<td>\n<p>||<\/p>\n<\/td>\n<td>\n<p>Logical-or<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>12(Lowest)<\/strong><\/p>\n<\/td>\n<td>\n<p>=<\/p>\n<\/td>\n<td>\n<p>Assignment operator<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<h5>13.3.1.2 Logical Judgement<\/h5>\n<p>Logical Statement can execute different statement blocks according to different conditions, allowing scripts to flexibly execute corresponding operations for different situations.<\/p>\n<p>Table 86 Logical Statement Syntaxes<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>if &lt;condition&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>End if<\/strong><\/p>\n<\/td>\n<td>\n<p>Executes the statement in the if block when <strong><em>if &lt;condition&gt;<\/em><\/strong> is true, for example:<\/p>\n<p>$U:V0 = 1<\/p>\n<p>if $U:V0.0<\/p>\n<p>  $U:V3 = 2 \/\/ Will be executed<\/p>\n<p>endif<\/p>\n<p>if $U:V0 &gt; 2<\/p>\n<p>  $U:V3 = 3 \/\/ Will not be executed<\/p>\n<p>Endif<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>if &lt;condition&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>else<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>End if<\/strong><\/p>\n<\/td>\n<td>\n<p>Execute the statement in the if block when the <strong><em>if &lt;condition&gt;<\/em><\/strong> is true, or else execute the statement in the <strong>else<\/strong> block if the <strong><em>if &lt;condition&gt;<\/em><\/strong> is false; for example:<\/p>\n<p>$U:V0 = 1<\/p>\n<p>if $U:V0 &gt; 2<\/p>\n<p>  $U:V3 = 2 \/\/ Will not be executed<\/p>\n<p>else<\/p>\n<p>$U:V3 = 3 \/\/ Will be executed<\/p>\n<p>Endif<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>if &lt;condition&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>Else if &lt;condition1&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>Else if &lt;condition2&gt;<\/strong><\/p>\n<p><strong>\u2026 <\/strong><\/p>\n<p><strong>End if<\/strong><\/p>\n<\/td>\n<td>\n<p>When the<strong> <em>if &lt;condition&gt;<\/em><\/strong> is true, execute the statement in the <strong><em>if block<\/em><\/strong>. Otherwise, determine the first<em> <\/em><strong><em>else if &lt;condition&gt;<\/em><\/strong>; if the first <strong><em>else if &lt;condition&gt;<\/em><\/strong> is true, execute the statement in the <strong><em>else if block<\/em><\/strong><em>.<\/em> If the first <strong><em>else if &lt;condition&gt;<\/em><\/strong> is still false, try the next <strong><em>else if &lt;condition&gt;<\/em><\/strong>, and so on. 0 or multiple <strong><em>else if block<\/em>s<\/strong> can exist, for example:<\/p>\n<p>$U:V0 = 1<\/p>\n<p>if $U:V0 == 4<\/p>\n<p>  $U:V3 = 4 \/\/ Will not be executed<\/p>\n<p>Else if $U:V0 == 3<\/p>\n<p>  $U:V3 = 3 \/\/ Will not be executed<\/p>\n<p>Else if $U:V0 == 2<\/p>\n<p>  $U:V3 = 2 \/\/ Will not be executed<\/p>\n<p>Else if $U:V0 == 1<\/p>\n<p>  $U:V3 = 1 \/\/ Will be executed<\/p>\n<p>End if<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>if &lt;condition&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>elseif &lt;condition&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>elseif &lt;condition&gt;<\/strong><\/p>\n<p><strong>\u2026 <\/strong><\/p>\n<p><strong>else<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>Endif<\/strong><\/p>\n<\/td>\n<td>\n<p>When the<strong> <em>if &lt;condition&gt;<\/em><\/strong> is true, execute the statement in the <strong><em>if block<\/em><\/strong>. Otherwise, determine the first<em> <\/em><strong><em>else if &lt;condition&gt;<\/em><\/strong>; if the first <strong><em>else if &lt;condition&gt;<\/em><\/strong> is true, execute the statement in its <strong><em>else if block<\/em><\/strong><em>.<\/em> If the first <strong><em>else if &lt;condition&gt;<\/em><\/strong> is still false, try the next <strong><em>else if &lt;condition&gt;<\/em><\/strong>, and so on. 0 or multiple else if blocks can exist. If the <strong><em>if &lt;condition&gt;<\/em><\/strong> and all of the <strong><em>else if &lt;condition&gt;<\/em><\/strong> are false, the statement in the <strong><em>else block<\/em><\/strong> will be executed.<\/p>\n<p>For example:<\/p>\n<p>$U:V0 = 1<\/p>\n<p>if $U:V0 == 4<\/p>\n<p>  $U:V3 = 4 \/\/ Will not be executed<\/p>\n<p>Else if $U:V0 == 3<\/p>\n<p>  $U:V3 = 3 \/\/ Will not be executed<\/p>\n<p>Else if $U:V0 == 2<\/p>\n<p>  $U:V3 = 2 \/\/ Will not be executed<\/p>\n<p>else<\/p>\n<p>$U:V3 = 3 \/\/ Will be executed<\/p>\n<p>End if<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<h5>13.3.1.3 Iterative <\/h5>\n<p>Iterative Statements can execute statement blocks repeatedly according to different conditions, allowing some repetitive tasks to be completed using fewer statements.<\/p>\n<p>Table 87 Iterative Statement Syntax<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>loop &lt;count&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>Endloop<\/strong><\/p>\n<\/td>\n<td>\n<p>Repeatedly execute the statements in the loop block &lt;count&gt; times<\/p>\n<p>, &lt;count&gt; can be a register or a positive integer constant.<\/p>\n<p>For example:<\/p>\n<p>\/*Calculate the sum of 1 to 10 and save it into $U:V0 *\/<\/p>\n<p>$U:V0 = 0 \/\/ sum<\/p>\n<p>$U:V1 = 0<\/p>\n<p>loop 10<\/p>\n<p>  $U:V1 = $U:V1 + 1<\/p>\n<p>  $U:V0 = $U:V0 + $U:V1<\/p>\n<p>Endloop<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>for &lt;reg&gt; = &lt;start&gt; to &lt;end&gt; step &lt;n&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>Endfor<\/strong><\/p>\n<\/td>\n<td>\n<p>If &lt;start&gt; is less than &lt;end&gt;, &lt;reg&gt; will be set to &lt;start&gt;, and the <strong><em>for block<\/em><\/strong> will be executed once. Then the value of &lt;reg&gt; will be added by &lt;n&gt; and execute <strong><em>for block <\/em><\/strong>again, until &lt;reg&gt; plus &lt;n&gt; is greater than &lt;end&gt;.<\/p>\n<p>If &lt;start&gt; is greater than &lt;end&gt;, &lt;reg&gt; will be subtracted by &lt;n&gt; instead, <strong><em>for block<\/em><\/strong> will be executed every time until &lt;reg&gt; minus &lt;n&gt; is less than &lt;end&gt;.<\/p>\n<p>Note:<\/p>\n<ul>\n<li>\n<ol>\n<li>&lt;reg&gt; should be a register<\/li>\n<li>&lt;start&gt; and &lt;end&gt; can be either registers or integer constants<\/li>\n<li>&lt;n&gt; should be a positive integer or a register containing positive integer value<\/li>\n<li><strong>Step &lt;n&gt;<\/strong> can be ignored. In such case, &lt;n&gt; will be 1<\/li>\n<li>If &lt;n&gt; is 0, <strong><em>for block<\/em><\/strong> will not be executed<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p>For example:<\/p>\n<p>\/* Calculate the sum of $U:V0 to $U:V10 and save it into$U:V11 *\/<\/p>\n<p>$U:V11 = 0<\/p>\n<p>for $S:I0 = 0 to 10<\/p>\n<p>$U:V11 = $U:V11 + $U:V0[$I0]<\/p>\n<p>Endfor<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>while&lt;condition&gt;<\/strong><\/p>\n<p><strong>\u2026<\/strong><\/p>\n<p><strong>Endwhile<\/strong><\/p>\n<\/td>\n<td>\n<p>Execute the statement in the <strong><em>while block<\/em><\/strong> when the <strong><em>while &lt;condition&gt;<\/em><\/strong> is true, and then check whether the <strong><em>while &lt;condition&gt;<\/em><\/strong> is true or false again to determine whether to execute again or exit the loop. If the <strong><em>while &lt;condition&gt;<\/em><\/strong> is false, then the program exits the loop. The <strong><em>while &lt;condition&gt;<\/em><\/strong> can be a register or an expression combined by multiple registers and operators.<\/p>\n<p>For example: <\/p>\n<p>\/* Calculate the sum of 1 to 10 and save it into$U:V0 *\/<\/p>\n<p>$U:V0 = 0 \/\/ sum<\/p>\n<p>$U:V1 = 0<\/p>\n<p>while $U:V1 &lt;= 10<\/p>\n<p>  $U:V1 = $U:V1 + 1<\/p>\n<p>  $U:V0 = $U:V0 + $U:V1<\/p>\n<p>Endwhile<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Break<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>break<\/strong> statement can be used in <strong>loop<\/strong>, <strong>for<\/strong>, or <strong>while<\/strong> loops. When a break statement is executed, the program will exit the current loop and continue execution. <strong>break<\/strong> statement is usually used with an <strong>if<\/strong> statement so that it will exit the loop when specific conditions are met; for example:<\/p>\n<p>\/* Search for the first non-zero word between $U:V0 to $U:V10; if the value of $U:V11 is 3 when the loop ends, then $U:V3 is the first non-zero word; if no non-zero word can be found, the value of $U:V11 will remain as 11 when the loop is finally existed*\/<\/p>\n<p>$U:V11 = 11<\/p>\n<p>for $S:I0 = 0 to 10<\/p>\n<p>  if $U:V0[$S:I0] != 0<\/p>\n<p>    $U:V11 = $S:I0<\/p>\n<p>    break<\/p>\n<p>  end if<\/p>\n<p>endfor<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Continue<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>continue<\/strong> statement can be used in <strong>loop<\/strong>, <strong>for<\/strong>, and <strong>while<\/strong> loops. When the continue statement is executed, the statements in the loops afterwards will be omitted and it will jump directly to the next iteration of the loop for execution, for example:<\/p>\n<p>$U:V0 = 0<\/p>\n<p>$U:V1 = 0<\/p>\n<p>loop 10<\/p>\n<p>  $U:V0 = $U:V0 + 1 \/* Will be executed 10 times *\/<\/p>\n<p>  if $U:V1 &gt;= 5<\/p>\n<p>    continue<\/p>\n<p>  end if<\/p>\n<p>  $U:V1 = $U:V1 + 1 \/* Will only be executed the first 5 times*\/<\/p>\n<p>Endloop<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<h4>13.3.2 Built-in Functions<\/h4>\n<p>The script statement collection provides many built-in functions; users can use these functions to execute numerical computations, string processing, file accessing and other more complicated operations.<\/p>\n<p>Table 88 Script Built\u2013in Functions<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Function<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"5\">\n<p><strong>Memory Operation<\/strong><\/p>\n<\/td>\n<td>\n<p>memcmp <\/p>\n<\/td>\n<td>\n<p>Memory block comparison<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>memcpy <\/p>\n<\/td>\n<td>\n<p>Copy memory block<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>memsrch <\/p>\n<\/td>\n<td>\n<p>Search memory block<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>memset<\/p>\n<\/td>\n<td>\n<p>Memory block value<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>reverse<\/p>\n<\/td>\n<td>\n<p>Reverse Word Order<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"6\">\n<p><strong>Trigonometry<\/strong><\/p>\n<\/td>\n<td>\n<p>sin <\/p>\n<\/td>\n<td>\n<p>Sine<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>cos <\/p>\n<\/td>\n<td>\n<p>Cosine<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>tan <\/p>\n<\/td>\n<td>\n<p>Tangent<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>asin <\/p>\n<\/td>\n<td>\n<p>Arcsine<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>acos <\/p>\n<\/td>\n<td>\n<p>Arccosine<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>atan <\/p>\n<\/td>\n<td>\n<p>Arctangent<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"13\">\n<p><strong>Numeric Computation<\/strong><\/p>\n<\/td>\n<td>\n<p>abs <\/p>\n<\/td>\n<td>\n<p>Absolute value<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>max <\/p>\n<\/td>\n<td>\n<p>Maximum value<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>min <\/p>\n<\/td>\n<td>\n<p>Minimum value<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>arrmax <\/p>\n<\/td>\n<td>\n<p>Maximum value for array<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>arrmin <\/p>\n<\/td>\n<td>\n<p>Minimum value for array<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>arrsum <\/p>\n<\/td>\n<td>\n<p>Sum or array<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>arrxor <\/p>\n<\/td>\n<td>\n<p>And-Or array<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>arrswp <\/p>\n<\/td>\n<td>\n<p>Swap high and low byte of array<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>pow <\/p>\n<\/td>\n<td>\n<p>Power<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sqrt <\/p>\n<\/td>\n<td>\n<p>Square root<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>log <\/p>\n<\/td>\n<td>\n<p>Natural logarithm<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>log10 <\/p>\n<\/td>\n<td>\n<p>Common logarithm<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Rand<\/p>\n<\/td>\n<td>\n<p>Generate random number<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"27\">\n<p><strong>String Operations<\/strong><\/p>\n<\/td>\n<td>\n<p>strcat <\/p>\n<\/td>\n<td>\n<p>Concatenate string<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Strncat<\/p>\n<\/td>\n<td>\n<p>Concatenate string (restrict length)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>strcpy <\/p>\n<\/td>\n<td>\n<p>Copy string<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>strncpy <\/p>\n<\/td>\n<td>\n<p>Copy string (restrict length)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>strcmp <\/p>\n<\/td>\n<td>\n<p>String comparison<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>strncmp <\/p>\n<\/td>\n<td>\n<p>String comparison (restrict length)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>stricmp <\/p>\n<\/td>\n<td>\n<p>String comparison(case-insensitive)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>strlen <\/p>\n<\/td>\n<td>\n<p>String length<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>strsrch <\/p>\n<\/td>\n<td>\n<p>Search string<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>substr<\/p>\n<\/td>\n<td>\n<p>String extraction<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>num2str <\/p>\n<\/td>\n<td>\n<p>Numeric value to string<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a2i <\/p>\n<\/td>\n<td>\n<p>String to integer<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a2f <\/p>\n<\/td>\n<td>\n<p>String to floating point number<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a2x <\/p>\n<\/td>\n<td>\n<p>String (hexadecimal) to integer<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>x2a<\/p>\n<\/td>\n<td>\n<p>Integer (hexadecimal) to string (ASCII)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a2xarr<\/p>\n<\/td>\n<td>\n<p>Convert string to consecutive integers separated by whitespace<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>xarr2a<\/p>\n<\/td>\n<td>\n<p>Convert words with the hexadecimal representation to an ASCII string.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a2harr <\/p>\n<\/td>\n<td>\n<p>Convert the unicode of the string into consecutive integers<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>harr2a<\/p>\n<\/td>\n<td>\n<p>Convert the array of the hexadecimal numbers to an ASCII string.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>n2a<\/p>\n<\/td>\n<td>\n<p>Convert multiple consecutive integers to a string<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a2n<\/p>\n<\/td>\n<td>\n<p>Convert continuous multiple strings to integers<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>unicode2ascii<\/p>\n<\/td>\n<td>\n<p>Convert the UNICODE string into an ASCII string.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>unicode2gb<\/p>\n<\/td>\n<td>\n<p>Convert the UNICODE string into a GB18030 string.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>unicode2big<\/p>\n<\/td>\n<td>\n<p>Convert the UNICODE string into a BIG5 string.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>ascii2unicode<\/p>\n<\/td>\n<td>\n<p>Convert the ASCII string into an UNICODE string.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>gb2unicode<\/p>\n<\/td>\n<td>\n<p>Convert the GB18030 string into an UNICODE string.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>big2unicode<\/p>\n<\/td>\n<td>\n<p>Convert the BIG5 string into an UNICODE string.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"9\">\n<p><strong>File Operations<\/strong><\/p>\n<\/td>\n<td>\n<p>file_open <\/p>\n<\/td>\n<td>\n<p>Open file (Internal Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>file_read <\/p>\n<\/td>\n<td>\n<p>Read file (Internal Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>file_write <\/p>\n<\/td>\n<td>\n<p>Write file (Internal Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>file_close <\/p>\n<\/td>\n<td>\n<p>Close file (Internal Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>file_delete <\/p>\n<\/td>\n<td>\n<p>Delete file (Internal Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>file_ rename<\/p>\n<\/td>\n<td>\n<p>Rename file (Internal Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>file_ copy<\/p>\n<\/td>\n<td>\n<p>Copy file (Internal Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>mkdir <\/p>\n<\/td>\n<td>\n<p>Create Directory (Internal Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>screen_capture<\/p>\n<\/td>\n<td>\n<p>Saves current screen into internal storage<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"9\">\n<p><strong>SD File Operations<\/strong><\/p>\n<\/td>\n<td>\n<p>sd_file_open <\/p>\n<\/td>\n<td>\n<p>Open file (SD Card)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sd_file_read <\/p>\n<\/td>\n<td>\n<p>Read file (SD Card)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sd_file_write <\/p>\n<\/td>\n<td>\n<p>Write file (SD Card)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sd_file_close <\/p>\n<\/td>\n<td>\n<p>Close file (SD Card)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sd_file_delete <\/p>\n<\/td>\n<td>\n<p>Delete file (SD Card)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sd_file_ rename<\/p>\n<\/td>\n<td>\n<p>Rename file (SD Card)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sd_ file_ copy<\/p>\n<\/td>\n<td>\n<p>Copy file (SD Card)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sd_mkdir<\/p>\n<\/td>\n<td>\n<p>Create Directory (SD Card)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>sd_screen_capture<\/p>\n<\/td>\n<td>\n<p>Saves current screen into SD storage<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"9\">\n<p><strong>USB File Operations<\/strong><\/p>\n<\/td>\n<td>\n<p>usb_file_open <\/p>\n<\/td>\n<td>\n<p>Open file (USB Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>usb_file_read <\/p>\n<\/td>\n<td>\n<p>Read file (USB Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>usb_file_write <\/p>\n<\/td>\n<td>\n<p>Write file (USB Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>usb_file_close <\/p>\n<\/td>\n<td>\n<p>Close file (USB Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>usb_file_delete <\/p>\n<\/td>\n<td>\n<p>Delete file (USB Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>usb _file_ rename<\/p>\n<\/td>\n<td>\n<p>Rename file (USB Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>usb _ file_ copy<\/p>\n<\/td>\n<td>\n<p>Copy file (USB Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>usb_mkdir<\/p>\n<\/td>\n<td>\n<p>Create Directory (USB Storage)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>usb_screen_capture<\/p>\n<\/td>\n<td>\n<p>Saves current screen into USB storage<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p><strong>Timer<\/strong><\/p>\n<\/td>\n<td>\n<p>Sleep<\/p>\n<\/td>\n<td>\n<p>Pause the execution of script in seconds<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Msleep<\/p>\n<\/td>\n<td>\n<p>Pause the execution of script in milliseconds<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p><strong>Date\/Time Operation<\/strong><\/p>\n<\/td>\n<td>\n<p>get_datetime <\/p>\n<\/td>\n<td>\n<p>Read date\/time<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>set_datetime <\/p>\n<\/td>\n<td>\n<p>Set date\/time<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Print<\/strong><\/p>\n<\/td>\n<td>\n<p>print_screen<\/p>\n<\/td>\n<td>\n<p>Prints current screen<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"9\">\n<p><strong>Communication<\/strong><\/p>\n<\/td>\n<td>\n<p>io write and read<\/p>\n<\/td>\n<td>\n<p>Write continuous data to the specified device and read continuous data to the specified address<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>io write<\/p>\n<\/td>\n<td>\n<p>Writing the lower bytes of consecutive words to device.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>io read1<\/p>\n<\/td>\n<td>\n<p>Read the needed data length from the target device and display the result.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>io read2<\/p>\n<\/td>\n<td>\n<p>Read the data from the target device and display the result.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>io read3<\/p>\n<\/td>\n<td>\n<p>Read the data from device until the end code is received.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>init crc<\/p>\n<\/td>\n<td>\n<p>Initialize the CRC checksum.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>checksum<\/p>\n<\/td>\n<td>\n<p>Calculate the sum of the codes for consecutive addresses<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>get_link_param_eth<\/p>\n<\/td>\n<td>\n<p>Read the connection parameters of the Ethernet device to the specified address.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>set_link_param_eth<\/p>\n<\/td>\n<td>\n<p>Set the connection parameters of the Ethernet device to the specified address.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"5\">\n<p><strong>Sound<\/strong><\/p>\n<\/td>\n<td>\n<p>play_sound<\/p>\n<\/td>\n<td>\n<p>Play sound<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>play_sound 2<\/p>\n<\/td>\n<td>\n<p>Play a sound file from an external storage device (microSD card or USB drive).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>stop_sound<\/p>\n<\/td>\n<td>\n<p>Stop playing sound<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Beep<\/p>\n<\/td>\n<td>\n<p>Trigger the buzzer once<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Beepf<\/p>\n<\/td>\n<td>\n<p>Force trigger the buzzer once.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">\n<p><strong>Draw<\/strong><\/p>\n<\/td>\n<td>\n<p>change_bs<\/p>\n<\/td>\n<td>\n<p>Change the foreground screen (base screen)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>popup_windows<\/p>\n<\/td>\n<td>\n<p>Pop-up the window screen<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>close_all_windows<\/p>\n<\/td>\n<td>\n<p>Close all the window screens<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\n<p><strong>System<\/strong><\/p>\n<\/td>\n<td>\n<p>get_id<\/p>\n<\/td>\n<td>\n<p>Read the specified ID and store it to the start address.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>reboot_hmi<\/p>\n<\/td>\n<td>\n<p>Reboot HMI<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p><strong>Note: Built-in functions may be added, removed or modified during software updates; please refer to the built-in functions and related documentation listed in FvDesigner if the functions listed in FvDesigner are different from the ones listed in this document.<\/strong><\/p>\n<h4>13.3.3 Custom Functions<\/h4>\n<p>Users can combine the frequently used statements into custom functions. Call the created custom function if these statements need to be used in different scripts. The use of custom functions allows the scripts to be simpler and saves the time to repeatedly write the same statement combinations.<\/p>\n<p>Table 89 Script\u2013Custom function-related statements<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Related Statement<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>call &lt;function&gt;<\/strong><\/p>\n<\/td>\n<td>\n<p>Calls the custom function named &lt;function&gt;, and will start executing from the first statement in the custom function; it will exit the custom function and return to the script to continue executing the next statement after the call statement once it has finished executing the last statement in the custom function. <\/p>\n<p>The example below is used to determine whether it is working hours now, and will save the result into $U:V100; users can make it into a custom function called <em>IsWorkHour<\/em><\/p>\n<p>if $S:TIME_LOCAL_HOUR &gt;= 8 &amp;&amp;<\/p>\n<p>$S:TIME_LOCAL_HOUR &lt;= 17<\/p>\n<p>  $U:V100 = 1<\/p>\n<p>else<\/p>\n<p>$U:V100 = 0<\/p>\n<p>endif<\/p>\n<p>Just call <em>IsWorkHour<\/em> and then check $U:V100 when used in a script; for example:<\/p>\n<p>\/* Determines whether it is working hour to set the brightness level for the backlight of the HMI *\/<\/p>\n<p>call IsWorkHour<\/p>\n<p>if $U:V100<\/p>\n<p>  $S:OP_BACKLIGHT_LEVEL = 80<\/p>\n<p>else<\/p>\n<p>  $S:OP_BACKLIGHT_LEVEL = 30<\/p>\n<p>Endif<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Ret<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>ret<\/strong> statements can be used in custom functions so that it will exit the custom function and return to the script to continue executing the next statement after the call statement once it executes up to the <strong>ret<\/strong> statement; for example: <\/p>\n<p>\/* If $U:V0.0 is 0, then this custom function will exit and return to the script to the line after the call statement; the if $U:V0.1 statement behind will not be executed *\/<\/p>\n<p>if $U:V0.0<\/p>\n<p>  @PLC0:Y0 = 1<\/p>\n<p>else<\/p>\n<p>  ret<\/p>\n<p>endif<\/p>\n<p>if $U:V0.1<\/p>\n<p>  @PLC:Y1 = 1<\/p>\n<p>Endif<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<h4>13.3.4 Comments<\/h4>\n<p>Comments can be used as program code explanations in the script to increase the readability of the program. Comments are omitted during script compilation. Therefore they will not affect the execution results of script. Program code that will not be used immediately can also be added into comments and moved out of the comment block for use when needed.<\/p>\n<p>Table 90 Script\u2013Comments<\/p>\n<div class=\"fatek-tw\">\n<table>\n<tr>\n<td>\n<p><strong>Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Single-Line Comment<\/strong><\/p>\n<\/td>\n<td>\n<p>Texts between the \/\/ symbol up to the end of the line will be treated as comments<\/p>\n<p>For example: <\/p>\n<p>\/\/ This is a single line comment<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>Multi-Line Comment<\/strong><\/p>\n<\/td>\n<td>\n<p>Texts between the \/* symbol and *\/ symbol will be treated as comments<\/p>\n<p>For example: <\/p>\n<p>\/* This is a<\/p>\n<p>multi-line<\/p>\n<p>comment *\/<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<h3>13.4 Examples &#8211; Scrolling Lamp<\/h3>\n<p>The goal of this example is to create a scrolling lamp where the lamps will move back and forth. As shown in the figure below, there are 15 lamps on the screen and three of the lamps are lit. We wish to have a visual effect where these three lamps keep moving to the left and then move back to the right once it reaches the end and continues cycling in this manner.<\/p>\n<p><img decoding=\"async\" alt=\"X:\\Noname.jpg\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-009.jpg\" \/><\/p>\n<p>Figure 177 Scrolling Lamp Example<\/p>\n<p><strong>Idea<\/strong><\/p>\n<p>In order to achieve the effect of the lamps moving towards the left, we can match the 16 lamps on the screen to the 0 to 15<sup>th<\/sup> bit of a register word and then use scripts to execute left shift computing to this register. When the 15<sup>th<\/sup> bit of the register is 1, it means that the lamp has already moved to the left-most part; next the script should right shift the register until the 0<sup>th<\/sup> bit of the register is 1 and then switch to left shift again.<\/p>\n<p>Now that we have an idea what needs to be accomplished, we can start implementing this example.<\/p>\n<ol>\n<li>First we will place 16 lamps on the screen, and set the monitor address of the right-most lamp to $U:V0.0 and the second one to $U:V0.1, and so on and so forth, until the address of all 16 lamps have been set.<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-010.png\" \/><\/p>\n<p>Figure 178 Scrolling Lamp Example Screen Setting<\/p>\n<ol>\n<li>Next we will add a script to control the movement of the lamps; first enter the\u3010Script List\u3011and press\u3010Add\u3011, input <strong>Move Lamp <\/strong>for the comment and then input the following script contents and save:<\/li>\n<\/ol>\n<p>\/* When $U:V1 = 0, move left<\/p>\n<p>When $U:V1 = 1, move right *\/<\/p>\n<p>if !$U:V1<\/p>\n<p>if !$U:V0.15  \/\/ Lamp not yet reached to the left-most position<\/p>\n<p>$U:V0 = $U:V0 &lt;&lt; 1  \/\/ Left shift the lamp<\/p>\n<p>else<\/p>\n<p>$U:V1 = 1  \/\/ Change the lamp movement to right shift<\/p>\n<p>endif<\/p>\n<p>else<\/p>\n<p>if !$U:V0.0   \/\/ Lamp not yet reached the right-most position<\/p>\n<p>$U:V0 = $U:V0 &gt;&gt; 1  \/\/ Right shift the lamp<\/p>\n<p>else<\/p>\n<p>$U:V1 = 0  \/\/ Change the lamp movement to left shift<\/p>\n<p>endif <\/p>\n<p>endif<\/p>\n<ol>\n<li>Next is to add another script to initialize the value of the register; input <strong>Init Lamp <\/strong>as the comment. the content is shown below:<\/li>\n<\/ol>\n<p>$U:V0 = 7 \/\/ Light up the three right-most lamps initially<\/p>\n<p>$U:V1 = 0 \/\/ Start moving the lamp to the left<\/p>\n<ol>\n<li>Finally right click the mouse at an empty space on the screen and select\u3010Properties\u3011to enter the\u3010Screen Properties\u3011to set the two scripts to execute when the screen opens and cycles respectively:<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-011.png\" \/><\/p>\n<p>Figure 179 Using Script Setting for the Screen<\/p>\n<p>Return to the\u3010Script List\u3011screen when the setting is complete and the following results can be seen:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/resource.fatek.com\/wp-content\/uploads\/fatek\/p5hmi-fvd-en-13\/p5hmi-fvd-en-13-012.png\" \/><\/p>\n<p>Figure 180 Script Setting Result<\/p>\n<ol>\n<li>Finally, click on\u3010Simulate\u3011which is located in the functions tab page of \u3010Project\u3011located in the toolbar on the top of the main screen and we will be able to see on the simulation screen that the lamps are moving the way we expected.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Script provides a simple language to allow users to wri [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57],"tags":[],"class_list":["post-3355","post","type-post","status-publish","format-standard","hentry","category-en-p5hmi-fvd"],"_links":{"self":[{"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/posts\/3355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/comments?post=3355"}],"version-history":[{"count":0,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/posts\/3355\/revisions"}],"wp:attachment":[{"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/media?parent=3355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/categories?post=3355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/resource.fatek.com\/index.php\/wp-json\/wp\/v2\/tags?post=3355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}