Multi-PROG Script Manual (en)
Multi-PROG Script Manual (en)
Document
Multi-PROG Script Function Description Document
1 Brief Introduction
2 Local Scripts Interface
3 Released Features Interface
4 Script Programming Related: Basic Syntax
4.1 Data Types
4.2 Literal and Variables
4.3 Statements and Comments
4.4 Function
5 Script Programming Related: Data Types
5.1 Uint8Array
5.1.1 Create byte array
5.1.2 Common Properties and Methods of Byte Arrays
5.1.3 Difference between slice Uint8Array.slice and subarray Uint8Array.subarray operations
5.2 Description of enumeration types
6 Script Programming Related: Built-in Functions
6.1 File
6.1.1 ReadFile
6.1.2 WriteFile
6.1.3 ReadAndEmbedFile
6.1.4 GetOpenFileName
6.1.5 GetSaveFileName
6.1.6 ReadFromSelectedFile
6.1.7 WriteToSelectedFile
6.2 Device operation
6.2.1 SelectBuffer
6.2.2 BlankCheck
6.2.3 WriteData
6.2.4 ReadData
6.2.5 EraseData
6.2.6 IdCheck
6.2.7 PinCheck
6.2.8 OpenPowerSetting
6.3 Interface Operation
6.3.1 Print
6.3.2 ClearLogs
6.3.3 Message
6.3.4 Question
6.3.5 GetInput
6.3.6 RequestInput
6.3.7 ShowDataInBufferArea
6.3.8 GetBufferData
6.3.9 GetBufferName
6.3.10 ShowPicture
6.3.11 AddFunctionButton
6.4 Vertification
6.4.1 SharedMemSetData
6.4.2 SharedMemGetData
6.4.3 SharedMemGetSize
6.4.4 SharedMemClear
6.5 Vertification
6.5.1 MD5
6.5.2 CRC16
6.5.3 CRC32
6.5.4 SHA1
6.5.5 SHA256
6.6 Encryption
6.6.1 AES_ECB_ZERO_Encrypt / DES_ECB_ZERO_Encrypt
6.6.2 AES_ECB_ZERO_Decrypt / DES_ECB_ZERO_Decrypt
6.6.3 AES_ECB_PKCS7_Encrypt / DES_ECB_PKCS7_Encrypt
6.6.4 AES_ECB_PKCS7_Decrypt / DES_ECB_PKCS7_Decrypt
6.6.5 AES_ECB_ISO_Encrypt / DES_ECB_ISO_Encrypt
6.6.6 AES_ECB_ISO_Decrypt / DES_ECB_ISO_Decrypt
6.6.7 AES_CBC_ZERO_Encrypt / DES_CBC_ZERO_Encrypt
6.6.8 AES_CBC_ZERO_Decrypt / DES_CBC_ZERO_Decrypt
6.6.9 AES_CBC_PKCS7_Encrypt / DES_CBC_PKCS7_Encrypt
6.6.10 AES_CBC_PKCS7_Decrypt / DES_CBC_PKCS7_Decrypt
6.6.11 AES_CBC_ISO_Encrypt / DES_CBC_ISO_Encrypt
6.6.12 AES_CBC_ISO_Decrypt / DES_CBC_ISO_Decrypt
6.6.13 AES_Encrypt / DES_Encrypt
6.6.14 AES_Decrypt / DES_Decrypt
6.7 Others
6.7.1 ByteArrayToHexString
6.7.2 HexStringToByteArray
6.7.3 GetLanguageId
6.7.4 CurrentDateTime
6.8 User Defined Functions
7 Script Case Demo
7.1 Create Script File
7.2 Edit Script File
7.3 Test Script File
7.4 Publish Script Files
7.5 View Published Script File Information
8 Multilingual Function
1 Brief Introduction
Multi PROG has a script function, with the Menu option in the menu bar of the system's main
interface, which includes two sub menus: Released Features and Local Scripts.
By selecting the Released Features submenu, the Released Features interface can be brought up.
The interface will display the attribute information of all released scripts under the system
default path in a table format (such as script name, type, manufacturer, function description,
remain times, deadline, etc.). Users can import, export, run, delete, and create new script files for
released scripts.
By selecting the Local Script submenu, you can bring up the local script interface and perform
operations such as creating, opening, modifying, saving, debugging, and publishing scripts.
By running the script file, specific function buttons can be added to the script area of the toolbar
in the system's main interface. Clicking on a specific function button in the script area will execute
the function function corresponding to the button specified in the script. The functions of specific
function buttons (actions performed after clicking) are configured by users through simple
programming of script files.
2 Local Scripts Interface
The local script interface is shown in the above figure, which mainly consists of a title bar, menu
bar, toolbar, and work display area. A brief introduction is as follows:
Title bar
The title bar displays the interface title, with three buttons on the right: minimize, maximize,
and close the current interface.
Menu bar
The menu bar contains six commonly used menu function options: file, edit, search, window,
debug, and help. The corresponding shortcut keys are displayed on the right side of each
submenu.
File menu: includes basic functions such as create, open, save, save as, and exit.
When creating a script, enter basic information about the script as prompted. Where,
Options is not required, and the ID entered is limited to the number coresponding to
the optional device in the database.
If Advanced Setting is selected, you can set additional parameters, including the devices
supported by the script, the number of times the script is available, and whether the
script validity period is enabled, the expiration date of the validity period, and the
unavaliable prompt text.
The function of the Vailable prompt is to configure the interactive prompt text when the
script exceeds the set number of uses or the configured cut-off time. If the
configuration item is not set, the default text is displayed.
Edit menu: Contains commonly used editing operations for text files, such as revoke,
restore, cut, copy, paste, delete, select all, and clear all.
Search menu: Contains functions for finding, replacing, and redirecting to specified
rows.
Window menu: includes local functions, functions, search, and messages. By clicking,
you can select whether the corresponding window is displayed in the work display
area.
Debug menu: includes testing and publishing functions< Test>Function is to run the
currently selected script. If an error occurs during the running process, an error
message will be displayed in the message window; If the entire running process is
correct, close the local script interface after the script is completed.
Help menu: Contains a help menu that provides help information about the script
interface.
Toolbar
The left side contains shortcut operations for creating, opening, saving, revoking, restoring,
cutting, copying, pasting, searching, replacing, jumping to a specified line, and customizing
functions. The right side contains two function buttons for testing and publishing the
currently selected script.
Test:
Check the script syntax and execute it, printing error messages during execution to the
message window; If there are no errors during the execution process, close the local
script window.
Release: (This feature requires connecting to the network and devices)
Display script option information and the storage path of the generated published
scripts, which can be modified before publication as needed. After clicking confirm,
execute the syntax check and online verification of the script, and print the error
message during the execution process to the message window; If the script has no
syntax errors and is validated, generate a published script file (.mjs file) and save it to
the specified publishing path (if Save to Local Default Path is checked, a copy of the .mjs
file will be copied and saved to the default path of the released script in the system.)
Work Display Area
The work display area mainly displays and operates on script files. Includes script text
editing window, local project window, search window, message window, and function
window. You can click on the x symbol in the upper right corner of each window to close it. If
you need to reopen it, you need to click on the window menu in the menu bar and select the
window you want to display.
Display the text information of the current script. Allow users to edit and also provide quick
editing operations from the right-click menu, making it convenient for users to edit text.
Local ProjectWindow
Script files that are opened in New or Open mode are displayed in the local project window
for easy management. Note: New script files are added to the Default group by default. To
move script files, you need to use the change group operation.
Double-click the file in the local project window to open the script file and add the script file
contents to the text editing window.
Search Window
Provide text search and replacement for the currently selected script. By specifying the
number of lines, the display of the text editing window can be redirected to the specified
line, facilitating editing operations on the script.
Message Window
When the script performs testing and publishing operations, error messages generated
during the process will be displayed in the message window, making it convenient for users
to locate programming errors in the script.
Functions Windows
Function window provides File, Device operation, Interface operation, Shared memory, Verty,
Encryption and decryption, Other functions, which is convenient for users to choose for
script programming. Double-click a function to insert it at the cursor position in a text editor
window.
In addition, the function window also provides user-defined functions. Click the + sign to add
user-defined functions, which facilitates the reuse of common functions and improves the
efficiency of script programming. User-defined functions support sub-group management.
Hover the mouse over the user-defined group to bring up the function buttons for
importing, exporting, adding subgroups, and creating user-defined functions.
The export button can copy the selected released script files in the table to the specified file path.
The new button has the same new function as the local script interface.
The delete button is used to delete the selected released script files in the table under the default
script path of the current system.
The run button is used to execute the selected released script file in the table.
Among them, String are the most commonly used in script programming, and this will be
emphasized in the introduction.
String idioms store and process text. Each character in the string can be accessed through the
index position (note: the index starts from 0).
If you want to use quotation marks in a string, you can use them by adding escape characters or
using quotation marks that are different from the string quotation marks (such as "Call him by
'Herry' not 'Potter').
Returns the
var str = “Xhorse”;
character at
charAt var ch = str.charAt(3);
the specified
//ch is r
position
Connect two
var str1 = “Hello ”;
or more
var str2 = “Xhorse”;
concat() strings and
var str3 = str1.concat(str2);
return a new
//str3 is “Hello Xhorse”
string
Check if the
string starts var str = “Hello world, welcome to Xhorse”;
startsWith() with the var res = str.startsWith(“Hello”);
specified //res is true
substring
Determine
whether the
var str = “Hello world, welcome to Xhorse”;
current string
endsWith() str.endsWith(“Xhorse”); //return true
ends with the
str.endsWith(“xhorse”); //return false
specified
string
Returns the
first
occurrence of
var str = “Hello world, welcome to Xhorse”;
a specified
indexOf() var res = str.indexOf(“or”);
string value in
//res is 7
a string, if not
found,
returns -1
Search the
string from
back to front
and calculate
the last
occurrence of var str = “Hello world, welcome to Xhorse”;
lastIndexOf() the returned var res = str.lastIndexOf(“or”);
string starting //res is 26
from the
starting
position. If
not found,
return -1
Find if the
string var str = “Hello world, welcome to Xhorse”;
includes() contains the var res = str.includes(“world”);
specified //res is true
substring
Find the
specified
var str = “Hello world, welcome to Xhorse”;
substring in
search() var res = str.search(“world”);
the string, if
//res is true
not found,
return -1
Find a match
var str = “Hello world, welcome to Xhorse”;
for one or
match() var res = str.match(/or/g);
more regular
//res array [‘or’, ‘or’]
expressions
Copy strings a
specified
number of
var str = “Xhorse”;
times and
repeat() var res = str.repeat(2);
concatenate
//res is ”XhorseXhorse”
them
together to
return
Find matching
substrings in
the string and
var str = “Hello world, welcome to Xhorse”;
replace
replace() var res = str.replace(“or”, “xxx”);
substrings
//res is ”Hello wxxxld, welcome to Xhorse”
that match
the regular
expression
Find a
matching
string in the
string and var str = “Hello world, welcome to Xhorse”;
replaceAll() replace all var res = str.replaceAll(“or”, “xxx”);
substrings //res is ”Hello wxxxld, welcome to Xhxxxse”
that match
the regular
expression
Extract a
specified
number of
var str = “Hello world, welcome to Xhorse”;
characters
substr() var res = str.substr(2, 7);
from the
//res is ”llo wor”
starting index
number of a
string
Extract
characters
between two var str = “Hello world, welcome to Xhorse”;
substring() specified var res = str.substring(2, 7);
index //res is ”llo w”
numbers in a
string
Remove
var str = “ Xhorse ”;
whitespace
trim() var res = str.trim();
on both sides
//res is ” Xhorse”
of the string
The opposite of the literal value is the variable. A variable is essentially a memory space used to
store different types of data, so its value allows for variation. Define variables using the keyword
var and assign values to them using an equal sign. For example:
var length = 6;
3. JavaScript ignores extra spaces, which can be added to the script to improve code
readability.
4. You can use a backslash () to wrap the code in a text string. The specific details are as
follows:
varstr = "Hello \
World";
6. Not all JavaScript statements are commands, and using double slashes // can annotate text
to prevent the execution of code lines. For multi line comments, start with /* and end with
*/。
In addition, JavaScript statements typically start with a statement identifier and execute that
statement. The commonly used statement identifiers are as follows:
function funcName(args) {
function Define a function. body, executed code bolck;
}
Loop statement,execute
a statement block, and
continue executing the
statement block when the
conditional statement is do {
do...while true. (The difference from block;
the while loop is that do... } while(condition);
while will first execute the
code block once before
making conditional
judgments.)
Branch jump statement, switch(expression) {
used to perform different case case1:
actions based on different block;
conditions. First, calculate break;
a switch expression, then case case2:
switch
compare the value of the block;
expression with the label break;
of each case. If there is a default:
match, execute the block;
associated code block. }
4.4 Function
Functions can be referenced repeatedly. By writing statements within functions, it is possible to
simplify the writing of repetitive statements, achieve reuse, and reduce code volume. Calling a
function is equivalent to executing the statement within the function. Function parameters can
be empty, and function return values can also be left blank. The function form is as follows:
When called, it is called through funcName (function parameter), with the same number and type
of parameters as specified when defining the function.
Example:
function addFunc(a, b) {
return a + b;
}
var c = addFunc(2, 3); //c: 2+3=5
The above defines a function called addFunc, whose specific function is to add the two
parameters passed and return the sum result. The function call passes arguments 2 and 3, and
the result of the function call is 5, which is assigned to variable c. The final value of variable c is 5.
5.1 Uint8Array
The byte array Uint8Array is widely used in built-in function parameters and function returns.
Therefore, this section provides a detailed explanation of the usage of this data type.
The Uint8Array type represents an 8-bit unsigned integer array, whose contents are initialized to
0 when created. After creation, elements in the array can be referenced in the form of objects or
using array indices.
5.1.1 Create byte array
The index of a byte array starts from 0. There are several methods to create byte arrays:
var arr = new Uint8Array(n); //n is the size of the array, with default data
of 0
arr[0] = 0x00;
arr[1] = 0x01;
…
arr[n-1] = …;
4. Create by copying
Several functions have been customized here, and the following table is used to demonstrate the
example call usage.
Return the
number of var arr = Uint8Array.of(1,2,3,4);
length
elements in var len = arr.length; //len is 4
Uint8Array.
Return
var arr = Uint8Array.of(1,2,3,4);
byteLength Uint8Array
var len = arr.byteLength; //len is 4
length (in bytes)
Return the
element at the
index position.
(If the index is var arr = Uint8Array.of(1,2,3,4);
at() negative, count var item = arr.at(2); //item is 3
backwards item = arr.at(-1); //item is 4
from the last
item in the
array.)
Copy the
sequence of
elements in the
array to the
starting
var arr = Uint8Array.of(1,2,3,4,5,6,7,8);
position from
copyWithin() arr.copyWithin(3,1,3);
the target
//arr is [1,2,3,2,3,,6,7,8]
(parameter 1).
Copy taken
from interval
[parameter 2,
parameter 3).
Fill an array
var arr = Uint8Array.of(0,0,0,0);
fill() with static
arr.fill(4,1,3); //item is [0,4,4,0]
values
Create a new
array that
contains all
var arr = Uint8Array.of(2,23,12,5,7);
filter() elements
var res = arr.filter(isEven); //res is [2,12]
tested using
the provided
method.
Find the first
element that
satisfies the
var arr = Uint8Array.of(4,5,8,9,12);
find() specified
var res = arr.fine(isOdd); //res is 5
function. If not
found, return
undefined.
Find elements
that meet the
specified
function, and if var arr = Uint8Array.of(4,5,8,9,12);
findIndex()
found, return var res = arr.fineIndex(isOdd); //res is 1
their index; If
not found,
return -1.
Similar to find(),
the difference
var arr = Uint8Array.of(4,5,8,9,12);
findLast() is that the
var res = arr.fineLast(isOdd); //res is 9
search direction
is opposite.
Similar to
findIndex(), the
difference is var arr = Uint8Array.of(4,5,8,9,12);
findLastIndex()
that the search var res = arr.fineLastIndex(isOdd); //res is 3
direction is
opposite.
Execute the
provided
var arr = Uint8Array.of(10,50,70);
function once
forEach() arr.every((element) => console.log(element));
for each
//Perform printing on each element
element in the
byte array.
Judge whether
a byte array var arr = Uint8Array.of(10,20,30,40);
includes() contains a arr.includes(20); //result is true
certain arr.includes(50); //result is false
element.
Returns the
index position
of the given
element, and if
it does not
exist, returns
var arr = Uint8Array.of(10,50,70);
indexOf() -1. (The second
var res = arr.indexOf(50); //res is 1
parameter is
optional,
indicating the
index position
to start the
search.)
Returns the
index position
of the given
element, and if
it does not
exist, returns
var arr = Uint8Array.of(10,20,30,40);
join() -1. (the second
var res = arr.join(‘-‘); //res is ’10-20-30-40’
parameter is
optional,
indicating the
index position
to start the
search.)
Returns a new
array iterator var arr = Uint8Array.of(10,20,30,40);
that contains var keys = arr.keys();
keys()
the key for each keys.next();
index in the var res = keys.next().value; //res = 1
array.
Similar to
indexOf(), the
var arr = Uint8Array.of(10,20,50,50,50,60);
difference is
lastIndexOf() arr.lastIndexOf(50,5); //result is 4
that the search
arr.lastIndexOf(50,3); //result is 3
direction is
opposite.
Create a new
byte array,
where each
element is the
var arr = Uint8Array.of(25,36,49);
map() result of the
var res = arr.map(Math.sqrt); //res is [5,6,7]
original byte
array calling the
specified
function.
Invert byte var arr = Uint8Array.of(10,20,30,40);
reverse()
array. arr.reverse(); //arr is [40,30,20,10]
Slice operation,
obtain a
portion of the
byte array, and
specify the var arr = Uint8Array.of(10,20,30,40,50);
slice()
range by var res = arr.slice(1,3); //arr is [20,30]
specifying the
interval. (left
closed and right
open)
Is there any
element in the
byte array that
var arr = Uint8Array.of(1,3,5,7);
some() meets the
arr.some(isEven); //result is flase
requirements
of the specified
function.
Subarray
operation to
obtain a
portion of a
byte array,
var arr = Uint8Array.of(10,20,30,40,50);
subarray() specifying a
var res = arr.subarray(1,3); //arr is [20,30]
range by
specifying an
interval. (left
closed and right
open)
Returns a new
byte array,
where the var arr = Uint8Array.of(10,20,30,40,50);
elements of the var res = arr.toReversed();
toReversed()
array are the //arr is [10,20,30,40,50]
inverted result //res is [50,40,30,20,10]
of the original
byte array.
Returns a new
byte array,
where the var arr = Uint8Array.of(40,10,50,20,30);
elements of the var res = arr.toSorted();
toSorted()
array are the //arr is [40,10,50,20,30]
sorted results //res is [10,20,30,40,50]
of the original
byte array.
Returns a new
array iterator var arr = Uint8Array.of(10,20,30,40);
that contains var tmp = arr.values();
values()
the value of tmp.next();
each index in var res = tmp.next().value; //res = 20
the array.
Returns a new
byte array,
where the var arr = Uint8Array.of(1,2,3,4,5);
element var res= arr.with(2,6);
with()
derived from //arr is [1,2,3,4,5]
the given index //res is [1,2,6,4,5]
is replaced with
the given value.
Both slicing and subarray operations can obtain a portion of a byte array, specifying a range by
specifying an interval (left closed and right open). The use of the two is basically the same, with
the main difference being the memory space occupation. The detailed usage and differences are
as follows:
As can be seen, Uint8Array.subarray shares memory space with the original array;
Uint8Array.slice is not shared with the original array memory and is located in a separate space.
InputFloat OFB
6.1 File
6.1.1 ReadFile
Parameters:
Return:
Example:
6.1.2 WriteFile
Parameters:
Return:
Example:
6.1.3 ReadAndEmbedFile
Function:
Read the specified file data and embed the file into the script when publishing.
(Note: only accept the absolute path string literal of the file as the is parameter, and
cannot embed the file when passing variables or other types.)
Prototype: ReadAndEmbedFile(path)
Parameters:
Return:
Read data.
Example:
6.1.4 GetOpenFileName
Prototype: GetOpenFileName()
Parameters: None.
Return:
Example:
6.1.5 GetSaveFileName
Prototype: GetSaveFileName()
Parameters: None.
Return:
Example:
6.1.6 ReadFromSelectedFile
Prototype: ReadFromSelectedFile()
Parameters: None.
Return:
Read data.
Example:
6.1.7 WriteToSelectedFile
Prototype: WriteToSelectedFile(data)
Parameters:
Return:
Example:
Prototype: SelectBuffer(name)
Parameters:
Example:
6.2.2 BlankCheck
Prototype: BlankCheck()
Parameters: None.
Return: None.
Example:
BlankCheck();
6.2.3 WriteData
Prototype: WriteData(data)
Parameters:
Example:
WriteData(data);
6.2.4 ReadData
Parameters: None.
Return:
Example:
6.2.5 EraseData
Prototype: EraseData()
Parameters: None.
Return: None.
Example:
EraseData();
6.2.6 IdCheck
Prototype: IDCheck()
Parameters: None.
Return: None.
Example:
IDCheck();
6.2.7 PinCheck
Prototype: PinCheck()
Parameters: None.
Return: None.
Example:
PinCheck();
6.2.8 OpenPowerSetting
Prototype: OpenPowerSetting()
Parameters: None.
Return: None.
Example:
OpenPowerSetting();
Parameters:
Example:
Print(“TEXT”);
Print(“RED TEXT”, MP_Color_Red);
6.3.2 ClearLogs
Prototype: ClearLogs()
Parameters: None.
Return: None.
Example:
ClearLogs();
6.3.3 Message
Function: Generate a message pop-up and retrieve the user's selected operation.
Prototype: Message(text)
Parameters:
Return: None.
Example:
Message(“MESSAGE”);
6.3.4 Question
Function: Generate a message pop-up and retrieve the user's selected operation.
Prototype: Question(type, buttons, title, text)
Parameters:
type <type: MsgWarning / MsgSuccess / MsgError> Three types of messages to choose from.
buttons <type: BtnCancel / BtnOK / BtnNo / BtnYes> Four types of buttons to choose from.
(Note: multiple buttons can be set through the "bitwise OR" operation, such as
BtnCancel | BtnOK)
title Title.
Return:
<BtnCancel / BtnOK / BtnNo / BtnYes> The type of button clicked by the user.
Example:
6.3.5 GetInput
Parameters:
type <Type: InputString / InputInt / InputHex / InputFloat> Four types of type selection to
choose.
Return:
Example:
6.3.6 RequestInput
type <Type: InputString / InputInt / InputHex / InputFloat> Four types of type selection to
choose.
Return:
Example:
6.3.7 ShowDataInBufferArea
Prototype: ShowDataInBufferArea(data)
Parameters:
Return: None.
Example:
ShowDataInBufferArea(data);
6.3.8 GetBufferData
Prototype: GetBufferData()
Parameters: None.
Return:
Example:
6.3.9 GetBufferName
Prototype: GetBufferName()
Parameters: None.
Return:
Buffer name.
Exmaple:
6.3.10 ShowPicture
Parameters:
path The path of picture. (Only accept the absolute path string literal of the picture and
cannot resolve the picture if passing variables or other types.)
Return: None.
Example:
6.3.11 AddFunctionButton
Function: When running in a specified language environment, add a button on the interface
to execute the specified function.
Parameters:
languageId Specify the language to use. (-1: Do not specify language, 0: Simplified Chinese,
1: English Note: Default parameter is -1)
Return: None.
Example:
function MyFunc1()
{
var input = GetInput(InputString, "PLEASE INPUT A STRING:");
Print(input);
}
AddFunctionButton("Message button", "MyFunc1");
function MyFunc2()
{
Message("Message pop-up text information");
}
AddFunctionButton("Pop up button", "MyFunc2");
6.4 Vertification
6.4.1 SharedMemSetData
Prototype: SharedMemSetData(data)
Parameters:
Return: None.
Example:
SharedMemSetData(data);
6.4.2 SharedMemGetData
Prototype: SharedMemGetData()
Parameters: None.
Return:
Example:
6.4.3 SharedMemGetSize
Prototype: SharedMemGetSize()
Parameters: None.
Return:
6.4.4 SharedMemClear
Prototype: SharedMemClear()
Parameters: None.
Return: None.
Example:
SharedMemClear();
6.5 Vertification
6.5.1 MD5
Prototype: MD5(data)
Parameters:
Return:
Calculation result.
Example:
6.5.2 CRC16
Function: Calculate the CRC16 value of data.
Parameters:
Return:
Calculation result.
Example:
6.5.3 CRC32
Parameters:
Return:
Calculation result.
Example:
6.5.4 SHA1
Parameters:
Return:
Calculation result.
Example:
6.5.5 SHA256
Parameters:
Return:
Calculation result.
Example:
6.6 Encryption
6.6.1 AES_ECB_ZERO_Encrypt / DES_ECB_ZERO_Encrypt
Prototype:
AES_ECB_ZERO_Encrypt(data, key)
DES_ECB_ZERO_Encrypt(data, key)
Parameters:
Return:
Encryption result.
Example:
Prototype:
AES_ECB_ZERO_Decrypt(data, key)
DES_ECB_ZERO_Decrypt(data, key)
Parameters:
Return:
Decryption result.
Example:
var data = Uint8Array.of(0x55, 0xC3, 0x82, 0x3A); //Multiple bytes
var key = Uint8Array.of(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F); //16 bytes
var result = AES_ECB_ZERO_Decrypt(data, key);
Function: AES128/DES encryption of data, using ECB mode and PKCS7 padding.
Prototype:
AES_ECB_PKCS7_Encrypt(data, key)
DES_ECB_PKCS7_Encrypt(data, key)
Parameters:
Return:
Encryption result.
Example:
Function: AES128/DES decryption of data, using ECB mode and PKCS7 padding.
Prototype:
AES_ECB_PKCS7_Decrypt(data, key)
DES_ECB_PKCS7_Decrypt(data, key)
Parameters:
Return:
Decryption result.
Example:
Function: AES128/DES encryption of data, using ECB mode and ISO padding.
Prototype:
AES_ECB_ISO_Encrypt(data, key)
DES_ECB_ISO_Encrypt(data, key)
Parameters:
Return:
Encryption result.
Example:
Prototype:
AES_ECB_ISO_Decrypt(data, key)
DES_ECB_ISO_Decrypt(data, key)
Parameters:
Return:
Decryption result.
Example:
Prototype:
Parameters:
iv Initial vector.
Return:
Encryption result.
Example:
var data = Uint8Array.of(0x55, 0xC3, 0x82, 0x3A); //Multiple bytes
var key = Uint8Array.of(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F); //16 bytes
var iv = new Uint8Array(16); //16bytes, content is 0x00
var result = AES_CBC_ZERO_Encrypt(data, key, iv);
Prototype:
Parameters:
iv Initial vector.
Return:
Decryption result.
Example:
Function: AES128/DES encryption of data, using CBC mode and PKCS7 padding.
Prototype:
Parameters:
iv Initial vector.
Return:
Decryption result.
Example:
Function: AES128/DES decryption of data, using CBC mode and PKCS7 padding.
Prototype:
AES_CBC_PKCS7_Decrypt(data, key, iv)
Parameters:
iv Initial vector.
Return:
Decryption result.
Example:
Function: AES128/DES encryption of data, using CBC mode and ISO padding.
Prototype:
AES_CBC_ISO_Encrypt(data, key, iv)
Parameters:
iv Initial vector.
Return:
Decryption result.
Example:
Function: AES128/DES decryption of data, using CBC mode and ISO padding.
Prototype:
Parameters:
iv Initial vector.
Return:
Decryption result.
Example:
Prototype:
Parameters:
iv Initial vector.
Return:
Decryption result.
Example:
Prototype:
Parameters:
level <AES_128 / AES_192 / AES_256> AES digits.
iv Initial vector.
Return:
Decryption result.
Example:
6.7 Others
6.7.1 ByteArrayToHexString
Prototype: ByteArrayToHexString(data)
Parameters:
data Array to be converted.
Return:
Conversion result.
Example:
var arr = Uint8Array.of(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
var strHex = ByteArrayToHexString(arr);
Print(strHex);
//strHex is 0001020304050607
6.7.2 HexStringToByteArray
Prototype: HexStringToByteArray(str)
Parameters:
str The hex string to be converted.
Return:
Conversion result.
Example:
var str= Uint8Array.of(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
var arr = HexStringToByteArray (str);
Print(arr);
//arr is: 0,1,2,3,4,5,6,7
6.7.3 GetLanguageId
Prototype: GetLanguageId()
Parameters: None.
Return:
Example:
6.7.4 CurrentDateTime
Prototype: CurrentDateTime(format)
Parameters:
format The date and time format that needs to be obtained, such as ”yyyy-MM-dd
hh:mm:ss:zzz”
Return:
Date, time (the return value corresponding to the above example parameters is ”2023.12.25
15:01:33:349”).
Example:
creating a new script file (. txt file) → editing script file → testing script file →
releasingscript file (→ viewing information on released script files).
1. Left click on the system's main interface menu bar Script→Local Scriptto bring up the local
script interface. Click on the menu bar File → Create to bring up the attribute configuration
interface for creating a new script file.
2. 1) Left click on the system's main interface menu bar Script→Released Features to bring up
the Released Features interface. Click the New function button to bring up the local script
interface and open the attribute configuration interface for creating a new script file.
Fill in the script attribute information according to the requirements, click confirm, and the
specified script file (. txt file) will be generated and displayed in the local project window. The
newly created script file will have content for user reference by default.
Note: The name attribute is a property of the script and differs from the file name of the
script.
7.2 Edit Script File
After creating a new script file, you can edit it. The function of the script file can be added by
selecting the function window on the right.
This example uses AddFunctionButton () to add a button named "Car Function" in the script area
of the toolbar in the main interface window. Clicking this button will execute the custom function
CarFunc(). In the CarFunc() function, a Message () function in the function window has been
added to open a message pop-up and display the specified prompt message.
As shown in the figure below, the "Car Function" function button appears in the system's main
interface toolbar. Clicking this button will execute the bound function, resulting in a pop-up
message and displaying the executed message pop-up content.
7.4 Publish Script Files
Click the release button on the right side of the toolbar, and a release options interface will pop
up, displaying the attribute information of the script file, allowing users to make modifications,
and providing the release path and the option to "save to local default path at the same time".
Under the premise of connecting to the network and devices, click confirm to perform syntax
check and online verification on the script file (. txt file). After verification, a released script (. mjs
file) will be generated and saved to the specified path.
If there is no connection between the device and the network, a message will pop up saying
"Device not connected, please connect the device and try again!".
8 Multilingual Function
Using multilingual function, the same script can be”test” or “release” in different language
systems, and can display specified language texts on the interface, avoiding the need to write
corresponding scripts for multiple language systems.
When creating a new script, configure the corresponding text to be displayed in the English
language system at the corresponding location. When the script is executed, the specified text
will be displayed at the desired location.