Functions for Pages and Project

Type

Format

Description

Subroutine

FrameOpen(“FrameFile”)

Opens the frame file.

Function

GetExplorerPath(“PathType”)

Returns the recently selected file’s path.

Function

IsDirectory(“File or Folder Name”)

Checks if the file or folder exists in the Xpanel.

Function

NumToAsc(Decimal value)

Converts a decimal value to an ASCII code value.

Function

NumToStr(TargetValue, Value Type, Format)

Converts the numeric value to a string.

Subroutine

PageOpen(“PageName”)

Opens the page.

Subroutine

PrePage()

Moves to the previous page.

Subroutine

PrePageEx()

Moves to the previous base page.

Subroutine

RunApp(“ProgramName”, “ProgramParameter”)

Executes the external program.

Subroutine

ScrCapture(“SeedName”, Location)

Saves the Xpanel screen in a BMP file.

Subroutine

SetSpeed(Acc./Dec.)

Controls the processing time of the script module.

Subroutine

Sleep(Delay)

Delays the script program.

Subroutine

SoftKeyboard(Show/Hide, X Coordinate, Y Coordinate)

Opens or closes the virtual keyboard.

Function

StrToNum(Target String, Numeral System)

Converts the string to the numeric value.

Subroutine

TimeStr(Acquired Value, “Format”)

Generates the time-displaying string.

FrameOpen

Opens the frame file.

Subroutine

FrameOpen(“FrameFile”)

Description

Opens the frame file. You can only enter the file name without the extension.

Example

Opens the frame file named “FRAME”.

FrameOpen(“FRAME”);

GetExplorerPath

Returns the recently selected file’s path.

Function

n=GetExplorerPath(”PathType”)

Description

Returns the recently selected file’s path.

Path Type can be assigned with the values as shown below.

0: Superordinate of the file or folder.

1: Selected file name.

2: Whole path including superordinate path and the file name.

Example

If you have selected the “Elder.exe” file in the Xpanel folder and then executed the function shown below, the entire path information will be returned.

VAR Path;

Path = GetExplorerPath(2);

IsDirectory

Checks if the file or folder exists in the Xpanel.

Function

n=IsDirectory(“File or Folder Name”)

Description

Checks if the file or folder exists in the Xpanel. The parameter must be entered with double quotation marks.

If the file or folder exists, the function will return 1. If not, the function will return 0.

Example

Checks if the USB Storage folder exists in Xpanel.

VAR FolderCheck;

FolderCheck = IsDirectory(“USB Storage”);

NumToAsc

Converts a decimal value to an ASCII code value.

Function

ASC = NumToAsc(Decimal Value)

Description

Returns the ASCII code value of the converted decimal value.

Example

1) When there is a string tag named “ASC” and an analog tag named “ANA”:

ASC= NumToAsc(ANA);

The ASCII content of the current analog tag value “ANA” is entered in the string tag “ASC”.

2) If the variables are directly registered and used in the script:

VAR ASC, ANA;

ANA=49;

ASC=NumToAsc(ANA);

Returns the ASCII code value of the decimal value 49, which is the letter “1”. In this case, “1” is not a numeric value.

NumToStr

Converts the numeric value to the string.

Function

STR=NumToStr(TargetValue, Value Type, Format)

Description

Recognizes the TargetValue as the data in Value Type. Then the value will be converted according to the Format.

This function supports Value Type as shown below.

_UINT_ : Unsigned Integer

_INT_ : Signed Integer

_FLOAT_ : Floating-Point

_HEX_ : Hexadecimal

Format must be written in the configuration as shown below.

[Width] [. precision]

Width: Assign the number of letters to be returned after the conversion. If you enter 3, the converted string will be composed of 3 letters. If the original value is greater than the Width value, the more significant digits will be deleted. In the opposite case, the spaces will be filled. If the Width contains a leading-zero, the spaces will be replaced with zeros.

Precision: Assign the Precision when you convert the floating-point number. Assign the significant digits for the decimal points to be converted. Precision must be smaller than the Width.

Example

Stores 123 to Val1, 0123 to Val2, 123.46 to Val3.

VAR Val1, Val2, Val3;

Val1 = NumToStr(123.456, _FLOAT_, “3.0”);

Val2 = NumToStr (123.456, _FLOAT_, “04.0”);

Val3 = NumToStr (123.456, _FLOAT_, “6.2”);

……

PageOpen

Opens the page.

Subroutine

PageOpen(“PageName”)

Description

Opens the page.

You must enter the file name except for the extension.

According to the page type, the pages will be opened with different operations. If there is no special configuration, the current page (existing page) will be closed.

Popup Page: If you open the Popup Page with this function, the current page (existing page) will not be closed.

Frame page: The page will be opened at the position where it is assigned in the frame. If you open the page in the same frame position, the page will be replaced with the new page.

Example

Opens the page file named “PAGE”.

PageOpen(“PAGE”);

PrePage

Moves to the previous page.

Subroutine

PrePage()

Description

The script can move to the previously opened pages up to the latest 20, regardless of the page type.

Example

Moves to the previous page.

PrePage();

PrePageEx

Moves to the previous base page.

Subroutine

PrePageEx()

Description

Moves to the previous base page. This function only recognizes the base pages. If the previous page is a Popup Page or Keypad Page, they will be ignored and will move on to the former base page.

Example

Moves to the previous base page.

PrePageEx();

RunApp

Executes the external program.

Subroutine

RunApp(“ProgramName”, “ProgramParameter”)

Description

Executes the external program.

ProgramName must include the file location and extension.

ProgramParameter is recognized as a string, therefore must be written with the double quotation mark. You can only execute the Windows program or the program developed by the user.

Example

Opens DOS and operates the ping test.

RunApp(“Ping.EXE”, “-t 100.100.100.1”);

ScrCapture

Saves the Xpanel screen in the BMP file.

Subroutine

ScrCapture(“SeedName”, Location)

Description

Saves the current Xpanel screen in a BMP image file. The file name will be created as shown below.

“SeedName_HHMMSS.BMP”

The image file will be saved in the path according to the value of Location.

When you assign 0 at Location, it means the local. The value 1 means the SD/MMC and the value 2 means the USB.

You can also assign the Location as shown below.

0: _LOCAL_

1: _SDMEM_

2: _USBMEM_

Example

Saves the current Xpanel screen as a BMP file in the SD/MMC memory.

ScrCapture(“Mybmp”, _SDMEM_);

SetSpeed

Controls the processing time of the script module.

Subroutine

SetSpeed(Acc./Dec.)

Description

When you assign a value other than 0 to the Acc./Dec., the later commands will be processed faster.

Example

The process will be faster after the calling SetSpeed function.

TAG0 = TAG0 + 1;

SetSpeed(1);

TAG1 = TAG1 + 1;

TAG2 = TAG2 + 2;

If you use SetSpeed during the repeated script, it may cause low performance of the Xpanel until the script’s end.

The functions called by the RunScript after the SetSpeed will not be influenced by the SetSpeed function.

Ex)

SetSpeed(1);

RunScript TestScript(); // TestScript is not influenced by SetSpeed

TestScript2(); // TestScript is influenced by SetSpeed

Sleep

Delays the script program.

Subroutine

Sleep(Delay)

Description

Assigns the delay time to Delay specified in milliseconds.

This function will be used in the middle of the script program and pauses the corresponding script for the length of the delay.

Example

Pauses the script for 1 sec (1000msec):

Sleep(1000);

SoftKeyboard

Opens or closes the virtual keyboard.

Subroutine

SoftKeyboard(Show/Hide, X Coordinate, Y Coordinate)

Description

Assigns the position at X Coordinate and Y Coordinate.

Assign a value other than 0 to Show/Hide to open the virtual keyboard. When you assign 0, the keyboard will be closed.

Example

Opens the virtual keyboard at the (10,10) position of the screen:

SoftKeyboard(1,10,10);

StrToNum

Converts the string to the numeric value.

Function

n=StrToNum(Target String, Numeral System)

Description

Target String must contain the string that can be converted into a numeric value. If the Numeral System is 10, the function can process the string in the following format.

[sign][digit][.digit][{d|D|e|E}[sign]digit]

Assign (+) or (-) to the Sign. Digit must be assigned with a single or multiple digit-decimal.

At least one decimal digit must be assigned before or after the decimal character(.).

When the numeral system is decimal, you can process the exponent which is composed of an introductory letter (d|D|e|E) and an optionally signed integer.

If the exponent or decimal point appears, the system will assume that the decimal number follows.

This function returns 0 if no conversion can be performed on the Target String.

 

Assign 0 or 2~36 to the Numeral System.

If the Numeral System is 0, it will be processed according to the following rules.

  • The initial characters define the numeral system.

  • If the first character is “0”, and the second character is not “x” or “X”, the string is recognized as an octal number. (e.g. 01234)

  • If the first character is “0”, and the second character is “x” or “X”, the string is recognized as a hexadecimal number. (e.g. 0x1234)

If the Numeral System is greater than 10, the letters “a” through “z” (or “A” through “Z”) are assigned the values 10 through 35.

This function only operates when the assigned value is smaller than the Numeral System.

Example

Stores the 3140 to the variable VAL.

VAR VAL;

VAL = StrToNum(“3.14e3”,10);

TimeStr

Generates the time-displaying string.

Function

STR=TimeStr(Acquired Value, “Format”)

Description

Assign the value acquired by GetTime(0) function or second-unit counter since Jan/01/1970 (UTC) to Acquired Value.

“Format” will be composed of the following symbols.

%A : Full name of the day (e.g. Sunday)
%a : Abbreviation of the day (e.g. Sun)

%B : Full name of the month (e.g. January)

%b : Abbreviation of the month (e.g. Jan)

%d : Date (1~31)

%H : Hour in 24-hour format (0~23)

%l : Hour in 12-hour format (1~12)

%m : Month (1~12)

%M : Minute (0~59)

%p : Indicator of 12-hour format (AM/PM)

%S : Second (0~59)

%y : 2-digit year (e.g. 00, 99)

%Y : 4-digit year (e.g. 2000, 1999)

Example

Generates the string in Year/Month/Date Hour:Minute:Second format.

CurTime = GetTime(0);

StrTag = TimeStr(CurTime, “%Y/%m/%d/ %H:%M:%S”);