To satisfy the user’s customization needs, PA-20 / PA-2010 / PA-21 / PA-2110 Basic provides effective
approaches for users to generate programs right to their actual demands. This allows users to collect data,
execute data processing, then store the processed data into proper location for future use.
PA-20 / PA-2010 / PA-21 / PA-2110 Basic interpreter provides a platform for users to develop application
programs to be excuted on the PA2 series data terminals using BASIC language. Users can develop an
application to meet their own individual needs efficiently.
You’ll soon learn how to use BASIC language to write application programs. Please proceed and enjoy the
perfect combination of PA-20 / PA-2010 / PA-21 / PA-2110 Basic and PA2 series and the productivity they can
boost for you in your application.
Numeric constants include positive and negative numbers.
Numeric constants in BASIC cannot contain commas. There are
two types of numeric constants that can be used in the PT-Basic
interpreter.
Integer constants: – 2147483648 ~ + 2147483647
Real number constants: Positive or negative real number, that
contain a decimal point, such as 1.23
or –3.5897
2.2 Variables
Variable are symbols used to represent data items, such as numerical
values or character strings that are used in BASIC program. The value of a
variable may be assigned explicitly and can be changed during the
execution of the program. Value of a variable is assumed to be undefined
until a value is assigned to it.
PT-Basic Programming Manual Ver. 1.00 8/143
2.2.1 Variable Names and Declaration Characters
The following are the rules to declare variable names and
characters:
A variable name must be begun with a letter.
The remaining characters can be letters, numbers, or
underscores.
The last character can be one of these declaration characters:
DIM Str$(60) „declares a string array with 60 elements.
2.3 Expression and Operators
An expression may be a string or numeric constant, or a variable, or it may
be a combination of constants and variables with operators to produce a
string value.
Operators perform mathematical or logical operations.
PT-Basic Programming Manual Ver. 1.00 9/143
Operator
Operation
Example
^
Exponentiation
A% = 9^6
-
Negation
A% = -B%
*
Multiplication
A% = B% * C%
/
Division
A% = B% / C%
+
Addition
A% = B% + C%
-
Subtraction
A% = B% - C%
MOD
Modulo arithmetic
A% = B% MOD C%
Operator
Operation
Example
=
Equality
A% = B%
<>
Inequality
A%<> B%
>
Greater than
A% > B%
<
Less than
A%< B%
>=
Greater than or equal to
A% >= B%
<=
Less than or equal to
A% <= B%
2.3.1 Assignment Operator
PT-Basic interpreter supports an assignment operator “=”
For example:
Size% =100
PI! =3.1415
Str1$=”back”
2.3.2 Arithmetic Operator
The arithmetic operators are:
2.3.3 Relational Operator
Relational operators are used to compare two values. Result of the
comparison is either “True” or “False”.
2.3.4 Logical Operator
Logical operators perform tests on multiple relations and Boolean
operations. Logical operator returns a result which is either
“True” (not zero) or “False” (zero). In an expression, logical
PT-Basic Programming Manual Ver. 1.00 10/143
operations are performed after arithmetic and relational
operations.
Operator
Operation
Example
NOT
Logical negation
NOT (A% = B%)
AND
Logical and
(A% = B%) AND (C% =
D%)
OR
Inclusive or
(A% = B%) OR (C% = D%)
XOR
Exclusive or
(A% = B%) XOR (C% =
D%)
Order of Precedence
Type of Operation
symbol
Highest
Arithmetic
^
↓
Arithmetic
*, /, MOD
↓
Arithmetic
+, -
↓
Relational
=, <>, >, <, >=, <=
↓
Logical
NOT, AND, OR,
XOR
Lowest
Assignment
=
2.4Operator Precedence
The precedence of BASIC operators affects the evaluation of operands in
expressions. Expressions with higher precedence operators are evaluated
first. Precedence of BASIC operators is listed below in the order of
precedence from highest to lowest.
2.5 Labels
Line labels are used to represent some special lines in the BASIC program.
They can be either integer numbers or character strings.
A valid integer number for the line label is in the range from 1 to
65279.
A character string label can have up to 255 characters (if the string
label has more than 255 characters, error can be it cannot be
anticipated).
A character string label that precedes a program line must have a colon
between the label and the program line, but it is not necessary for an
integer label.
PT-Basic Programming Manual Ver. 1.00 11/143
For example:
GOTO 100
…
100
…
GOTO LABEL2
… LABEL2:
…
2.6 Subroutines
A subroutine is a set of instructions with a particular name or a line label.
User can simplify their programming by breaking programs into
subroutines. A subroutine will be executed when being called by a
GOSUB command.
For example:
ON COM (1) GOSUB ReadCOM
…
ReadCOM:
…
RETURN
The command RETURN marks the end of the subroutine and tells the
processor to return to the caller. A subroutine has to be appended at the
end of the main BASIC program. A subroutine can be defined with or
without a pair of brackets.
For example:
GOSUB FUN
GOSUB Place
GOSUB Test
END
…
SUB FUN( )
PRINT "Run function!!"
END SUB
PT-Basic Programming Manual Ver. 1.00 12/143
Place:
PRINT "Run Place!!"
RETURN
SUB Test
PRINT “TEST…”
END SUB
2.7 Exit program
In any place of the program, you can use “END” to exit the
program. The system will go to BASIC Menu.
PRINT "Press key to exit!"
WHILE INKEY$ = ""
WEND
END
2.8Special notes
Commands have to be appeared in uppercase letters
PRINT “OK…” → right
print “NG…” → error
Variable names are case sensitive.
ABC%、ABc%、AbC% → Three kind of different variables
ARGO%、ARGO!、ARGO$ → Three kind of different variables
PT-Basic Programming Manual Ver. 1.00 13/143
ABS
Purpose:
To return the absolute value of a numeric expression.
A% is numeric variable to be assigned to the absolute value
of a numeric expression.
N% or N! is a numeric expression, it can be an integer or a
real number.
DIM
Purpose:
To specify the maximum value of variable subscripts and to
allocate storage accordingly.
Syntax:
DIM Array (range {,range}) {, Array(range {,range})}
Example:
DIM A%(8), B%(5,5),C$(6)
Description:
Array is an array variable.
Range can be an integer or an integer expression.
3 Command Sets
3.1 General commands
PT-Basic Programming Manual Ver. 1.00 14/143
GOSUB
Purpose:
To call a specified subroutine.
Syntax:
GOSUB SubName|SubLabel|SubNumber
Example:
GOSUB FUN
GOSUB Place
GOSUB 100
END
SUB FUN( )
PRINT "Run SUBNAME"
END SUB
Place:
PRINT "Run SUBLABEL"
RETURN
100
PRINT "RunSUBNUMBER"
RETURN
Description:
SubName is the name of a subroutine.
SubLabel is the line label of a subroutine.
SubNumber is the line number of a subroutine.
GOTO
Purpose:
To branch unconditionally to a specified line number or line
lable from the normal program sequence.
Syntax:
GOTO LineNumber|LineLabel
Example:
GOTO FUN
100
PRINT "NUMBER"
WHILE INKEY$=""
WEND
END
FUN:
PRINT "LABEL NAME"
GOTO 100
Description:
LineNumber is the integer number in front of a program line.
LineLabel is the string label of a program line.
PT-Basic Programming Manual Ver. 1.00 15/143
INT
Purpose:
To return the largest integer that is less than or equal to the
giver numeric expression.
Syntax:
A% = INT(N%) or A% = INT(N!)
Example:
A% = INT(9.86)
PRINT A%
B% = INT(-5.68)
PRINT B%
Description:
A% is an integer variable to be assigned to the result.
N% or N! is a numeric expression,it can be an integer or a
real number.
REM
Purpose:
To insert explanatory remarks in a program.
Syntax:
REM remark or 'remark
Example:
REM This is function
' This is BASIC program
Description:
remark may be any sequence of characters. BASIC
interpreter will ignore whatever follows the REM or „ until
end of the line‟.
SET_PRECISION
Purpose:
To set the precision of the decimal points for printing real
number expression.
Syntax:
SET_PRECISION(N%)
Example:
A! = 3.141592654
SET_PRECISION(6)
PRINT "A = ", A! ' A = 3.141593
Description:
N% is a numeric expression in the rang of 0 to 6.
The precision default setting is two digits.
PT-Basic Programming Manual Ver. 1.00 16/143
SGN
Purpose:
To return an indication of the mathematical sign (+ or -) of a
given numeric expression.
N% or N! is a numeric expression,it can be an integer or a
real number.
A% is an integer variable to be assigned to the result.
A%
Meaning
1
N% >0
0
N% =0
-1
N% <0
PT-Basic Programming Manual Ver. 1.00 17/143
IF … THEN … {ELSE IF…} [ELSE…] END IF
Purpose:
To provide a decision structure for multiple-line conditional
execution.
Syntax:
IF condition1 THEN [statements1] {ELSE IF condition2
THEN statements2} [ELSE elsestatements] END IF
Example:
PRINT "Input a number:"
Result%=INPUT("",K%)
IF K% < 10 THEN
PRINT "One digit"
ELSE IF K% < 100 THEN
PRINT "Two digits"
ELSE
PRINT "Over one Hundry!"
END IF
Description:
condition is a logical expression.
statements can be multiple lines of BASIC statements.
3.2 Commands for decision structures
PT-Basic Programming Manual Ver. 1.00 18/143
ON … GOSUB …
Purpose:
To call one of the specified subroutines depending on the
value of the expression.
Syntax:
ON N% GOSUB SubLabel| SubName {,SubLabel|
SubName}
N% is a numeric expression that is rounded to an integer. The
value of N% determines which subroutine is to be called. If
the value of N% is 0 or greater than the number of routines
listed, the interpreter will continue with the next executable
statement.
SubLabel is the name of a subroutine.
PT-Basic Programming Manual Ver. 1.00 19/143
SubName is the line label of a subroutine.
ON … GOTO …
Purpose:
To branch to one of several specified Line Labels depending
on the value of an expression.
Syntax:
ON N% GOTO LineLabel | LineNumber {,LineLabel |
LineNumber}
Example:
D% = DAY_OF_WEEK
ON D% GOTO 1, 2, 3, 4, 5, 6, 7
1
PRINT "MONDAY"
END
2
PRINT "TUESDAY"
END
3
PRINT "WEDNESDAY"
END
4
PRINT "THURSDAY"
END
5
PRINT "FRIDAY"
END
6
PRINT "SATURDAY"
END
7
PRINT "SUNDAY"
END
Description:
N% is a numeric expression which is rounded to an
integer.The value of N% determines which line lable in the
list will be used for branching. If the value N% is 0 or greater
than the number of line labels listed,the interpreter will
continue with the next executable statement.
LineLabel is the string label of a program line.
LineNumber is the integer number in front of a program line.
PT-Basic Programming Manual Ver. 1.00 20/143
EXIT
Purpose:
To provide an alternative exit for looping structures,such as
FOR…NEXT and WHILE…WEND statements.
Syntax:
EXIT
Example:
WHILE 1
IF INKEY$=CHR$(27) THEN „if press ESC key
then quit
EXIT
END IF
WEND
PRINT "EXIT..."
Description:
EXIT can appear anywhere within the loop statement.
FOR … NEXT
Purpose:
To repeat the execution of a block of statements for a
specified number of times.
Syntax:
FOR N% = startvalue TO endvalue [STEP step]
[Statement Block]
NEXT
Example:
FOR N% = 1 TO 6 STEP 1
PRINT "FOR NEXT",N%
NEXT
Description:
N% is an integer variable to be used as loop counter.
Startvalue is a mumeric expression which is the initial value
for the loop counter.
Endvalue is a numeric expression which is the final value for
the loop counter.
Step is a numeric expression to be used as an
increment/decrement of the loop counter. The step is 1 by
default.
If the loop counter ever reaches or beyond the endvalue,the
program execution continues to the statement following the
NEXT statement. The Statement block will be executed again
otherwise.
3.3 Commands for looping structures
PT-Basic Programming Manual Ver. 1.00 21/143
WHILE … WEND
Purpose:
To repeat the execution of a block of statements while a
certain condition is TRUE.
Syntax:
WHILE condition
[Statement Block]
WEND
Example:
N%=1
WHILE 1
PRINT "Cnt=",N%
N%=N%+1
IF N%>5 THEN
EXIT
END IF
WEND
Description:
If the condition is true, loop statements are executed until the
WEND statement is encountered. Then the program
execution returns to WHILE statement and checks the
condition again. If it is still true,the process will be repeated.
Otherwise the execution continues with the statement
following the WEND statement.
A% is an integer variable to be assigned to the result.
N% is a numeric expression. Optional offset N% sets the
position for starting the search.
S1$, S2$ may be a string variable, string expression, or string
constant.
If S2$ is found in S1$, it returns the position of the first
occurrence of S2$ in S1$, from the starting point.
If N% is larger than the length of S1$ or if S1$ is null, of if
S2$ cannot be found,it return 0.
If S2$ is null,it return N%(or 1 if N% is not specified).
3.4 Commands for string processing
PT-Basic Programming Manual Ver. 1.00 23/143
LEFT$
Purpose:
To retrieve a given number of characters from the left side of
the target string.
A$ is a string variable to be assigned to the result.
Str$ may be a string variable, string expression, or string
constant.
N% and M% are numeric expression.
This command returns a string of length M% characters from
Str$ beginning with the N%th character.
If M% is equal to zero, or if N% is greater than the length of
Str$, then it returns a null string.
PT-Basic Programming Manual Ver. 1.00 24/143
RIGHT$
Purpose:
To retrieve a given number of characters from the right side
of the target string.
To resume the event trigger, call ON READER… GOSUB…N% is an integer variable, indicating the reader port (now we
only can choose 1).
PT-Basic Programming Manual Ver. 1.00 31/143
OFF TIMER
Purpose:
To terminate TIMER event trigger.
Syntax:
OFF TIMER(N%)
Example:
ON TIMER(1,200) GOSUB A1
ON TIMER(2,300) GOSUB A2
…
A1:
OFF TIMER(1)
…
RETURN
A2:
OFF TIMER(2)
…
RETURN
Description:
To resume the event trigger, call ON TIMER… GOSUB…N% is an integer variable in the range of 1 to 5, indicating the
timer ID.
ON COM GOSUB
Purpose:
To activate COM event trigger.
Syntax:
ON COM(N%) GOSUB SubLabel | SubName
Example:
ON COM(1) GOSUB READ1
…
READ1:
OFF COM(1)
…ON COM(1) GOSUB READ1
RETURN
Description:
When data is received from the COM port, a specific
subroutine will be executed.
N% is an integer variable, indicating the COM port (now we
only can choose 1).
PT-Basic Programming Manual Ver. 1.00 32/143
ON ESC GOSUB
Purpose:
To activate ESC event trigger.
Syntax:
ON ESC GOSUB SubLabel | SubName
Example:
ON ESC GOSUB ESC_PRESS
…
ESC_PRESS:
OFF ESC
… ON ESC GOSUB ESC_PRESS
RETURN
Description:
When ESC key is pressed, a specific subroutine will be
executed.
ON HOUR GOSUB
Purpose:
To activate HOUR event trigger.
Syntax:
ON HOUR GOSUB SubLabel | SubName
Example:
ON HOUR GOSUB OnHourAlarm
…
OnHourAlarm:
CurrentTime$=TIME$
H%=VAL(LEFT$(CurrentTime$,2))
FOR I%=1 TO H%
BEEP(30,20,0,0) WAIT(100)
NEXT
RETURN
Description:
When the system time is on the hour, a specific subroutine
will be executed.
PT-Basic Programming Manual Ver. 1.00 33/143
ON KEY GOSUB
Purpose:
To activate KEY event trigger.
Syntax:
ON KEY(number%) GOSUB SubLabel | SubName
Example:
ON KEY(1) GOSUB F1
ON KEY(2) GOSUB F2
…
F1:
OFF KEY(1)
…
RETURN
F2:
OFF KEY(2)
…
RETURN
Description:
When a function key is pressed, a specific subroutine will be
executed.
number% is an integer variable in the range of 1 to 6,
indicating a function key of the keypad.
ON MINUTE GOSUB
Purpose:
To activate MINUTE event trigger.
Syntax:
ON MINUTE GOSUB SubLabel | SubName
Example:
ON MINUTE GOSUB AMINUTE
…
AMINUTE:
CurrentTime$=TIME$
CurrentMin%=VAL(MID$(CurrentTime$,3,2))
IF CurrentMin%=30 THEN
BEEP(30,50,0,0)
WAIT(200)
END IF
RETURN
Description:
When the system time is on the minute, a specific subroutine
will be executed.
When data is received from reader port, a specific subroutine
will be executed.
N% is an integer variable, indicating the reader port (now we
only can choose 1).
PT-Basic Programming Manual Ver. 1.00 35/143
ON TIMER GOSUB
Purpose:
To activate TIMER event trigger.
Syntax:
ON TIMER(N%, duration%) GOSUB SubLabel | SubName
Example:
ON TIMER(1,200) GOSUB TimeOut
…
TimeOut:
OFF TIMER(1)
…
RETURN
Description:
When the system runs out of the time duration specified by
user, a specific subroutine will be executed.
Up to five timers can be set in a BASIC program. Be sure the
timer ID‟s are properly differentiated. Otherwise, the latter
created timer will overwrite the former one.
N% is an integer variable in the range of 1 to 5, indicating the
ordinal number of timer.
duration% is an integer variable, indicating a specified period
of time in units of 10 ms.
PT-Basic Programming Manual Ver. 1.00 36/143
LOCK
Purpose:
To hold all the activated event triggers until they are released
by UNLOCK.
Syntax:
LOCK
Example:
ON KEY(1) GOSUB F1
ON KEY(2) GOSUB F2
…
F1:
LOCK
PRINT "press F1"
UNLOCK
RETURN
F2:
PRINT "press F2"
RETURN
In this example, the BASIC program can trap the KEY(1)
and KEY(2) events and reroute to the subroutines F1 and F2
respectively. In F1, the command LOCK disable all the
activated event triggers so that the subroutine F1 will not be
interrupted by a new upcoming KEY(1) and KEY(2) event.
On the other hand, since LOCK is not called in F2, any new
coming KEY(1) and KEY(2) event will interrupt the ongoing
F2, and therefore, may affect the expected results.
Description:
This command can prevent nesting of event triggers. All the
activated event triggers will be disabled until UNLOCK is
called.
PT-Basic Programming Manual Ver. 1.00 37/143
UNLOCK
Purpose:
To release all the activated event triggers held by LOCK.
Syntax:
UNLOCK
Example:
ON KEY(1) GOSUB F1
ON KEY(2) GOSUB F2
…
F1:
LOCK
PRINT "press F1"
UNLOCK
RETURN
F2:
PRINT "press F2"
RETURN
Description:
This command resumes event processing.
PT-Basic Programming Manual Ver. 1.00 38/143
AUTO_OFF
Purpose:
To set auto power off timer.
Syntax:
AUTO_OFF(N%)
Example:
AUTO_OFF(2)
Description:
N% is an integer variable in the range from 30 to 65535,
indicating a specified period of time in units of 1 second. If
the time interval is set to zero, this function will be disabled.
DEVICE_ID$
Purpose:
To get the serial number of the terminal.
Syntax:
A$ = DEVICE_ID$
Example:
PRINT “S/N:” + DEVICE_ID$
Description:
A$ is a string variable to be assigned to the result. That is a
string of the target terminal serial number to be returned.
GET_TARGET_MACHINE$
Purpose:
To get the model name of the target terminal.
Syntax:
A$ = GET_TARGET_MACHINE$
Example:
PRINT “Model Name:”+GET_TARGET_MACHINE$
Description:
A$ is a string variable to be assigned to the result. That is a
string of the model name of the target terminal to be returned.
A% is an integer variable to be assigned to the result, it is the
ordinal number of the menu item that user has selected.
Item$ is a string variable, indicating the menu item that are
separated and ended by carriage return (CR, 0xd).
This command allows user to select an item by using the
UP/DOWN arrow keys (or the shortcut keys), and then the
ENTER key to confirm the selection. Also it allows the use
of ESC key to cancel the current operation.
Menu title:@ (the title can be put anywhere in the menu
string)
PT-Basic Programming Manual Ver. 1.00 40/143
POWER_ON
Purpose:
To determine whether to restart or resume the program upon
powering on.
Syntax:
POWER_ON(N%)
Example:
POWER_ON(0) „Resume
Description:
N% can be set 0 or 1.
N%
Meaning
0
Resume
1
Reset
RESTART
Purpose:
To restart the system.
Syntax:
RESTART
Example:
ON ESC GOSUB ESC_PRESS
…
ESC_PRESS:
RESTART
RETURN
Description:
This command will terminate the execution of the BASIC
program and restart the system.
A$ is a string variable to be assigned to the result.
index% is an integer variable, indicating a specific category
of information.
index%
Meaning
1
Kernel version
2
BASIC version
3
Scanner version
PT-Basic Programming Manual Ver. 1.00 41/143
SYS_SUSPEND
Purpose:
To shut down the system.
Syntax:
SYS_SUSPEND
Example:
SYS_SUSPEND
Description:
This command will shut down the system.
CHECK_AID
Purpose:
To check the agency ID is correct or not.
Syntax:
A%=CHECK_AID(S1$ , S2$)
Example:
IF CHECK_AID("6421","08724") THEN
PRINT "AID OK..."
ELSE
PRINT "AID NG..."
END IF
WHILE INKEY$=""
WEND
Description:
A% is an integer variable to be assigned to the result.
A%
Meaning
0
AID not
correct.
1
AID correct.
S1$ is a string variable, indicating the UserID that needs 4~8
characters.
S2$ is a string variable, indicating the password that needs
4~8 characters.
PT-Basic Programming Manual Ver. 1.00 42/143
DISABLE READER
Purpose:
To disable the reader ports of the terminal.
Syntax:
DISABLE READER(N%)
Example:
DISABLE READER(1)
Description:
N% is an integer variable, indicating the reader port (now we
only can choose 1).
ENABLE READER
Purpose:
To enable the reader ports of the terminal.
Syntax:
ENABLE READER(N%)
Example:
ON READER(1) GOSUB SCAN
ENABLE READER(1)
…
SCAN:
OFF READER(1)
CLS
A$=GET_READER_DATA$(1,4)
PRINT "DATA:"+A$
LOCATE 0,2
A$=GET_READER_DATA$(1,1)
PRINT "Name:"+A$
LOCATE 0,4
PRINT GET_READER_DATALEN
LOOP1:
S1$=INKEY$
IF S1$="" THEN
GOTO LOOP1
END IF
ON READER(1) GOSUB SCAN
RETURN
Description:
N% is an integer variable, indicating the reader port (now we
only can choose 1).
3.7 Reader commands
PT-Basic Programming Manual Ver. 1.00 43/143
SLEEP_READER
Purpose:
To set scanner module to sleep.
Syntax:
SLEEP_READER(N%)
Example:
SLEEP_READER (1) „Scanner to sleep
Description:
N% is an integer variable.
N%
Meaning
0
Not sleep
1
To sleep
GET_READER_DATA$
Purpose:
To get data that is read from a specified reader ports.
Syntax:
A$ = GET_READER_DATA$(N1%,N2%)
Example:
ON READER(1) GOSUB SCAN
ENABLE READER(1)
…
SCAN:
…A$=GET_READER_DATA$(1,4)
…RETURN
Description:
This command will get reader port data.
A$ is a string variable to be assigned to the result.
N1% is an integer variable, indicating the reader port (now we
only can choose 1).
N2% is an integer variable, indicating what kind of data to be
retrieved.
N2%
Meaning
1
Code Name
2
Full Code
3
Code ID
4
Data
The format of Full Code as follows:
Code
name
Preamble
ID* Code
Length
Barcode
data ID*
Postamble
Suffix
The ID position depends on “Code ID position” setting.
PT-Basic Programming Manual Ver. 1.00 44/143
GET_READER_DATALEN
Purpose:
To get data length that is read from a specified reader ports.
Syntax:
A%=GET_READER_DATALEN
Example:
A% = GET_READER_DATALEN
Description:
A% is an integer variable to be assigned to the result.
READER_CONFIG_START
Purpose:
To start scanner setting procedure.
Syntax:
READER_CONFIG_START
Example:
READER_CONFIG_START
A%=READER_SENDCMD(11,1, CHR$(1)) „Code-39
can read
…
READER_CONFIG_END
Description:
This command can start scanner setting procedure.
READER_CONFIG_END
Purpose:
To terminate scanner setting procedure.
Syntax:
READER_CONFIG_END
Example:
READER_CONFIG_END
Description:
This command can terminate scanner setting procedure.
PT-Basic Programming Manual Ver. 1.00 45/143
READER_SENDCMD
Purpose:
To send scanner (CCD) command to change scanner status.
A% is an integer variable to be assigned to the result.
A%
Meaning
PT-Basic Programming Manual Ver. 1.00 46/143
0
Change fail
1
Change OK
N1% is an integer variable, indicating the parameter1.
N2% is an integer variable, indicating the parameter2.
S$ is a string variable.
Refer to “Appendix C” for more details about the parameter
setting.
READER_QUERY$
Purpose:
To query the scanner(CCD) current setting.
Syntax:
A$=READER_QUERY$(N1% , N2%)
Example:
„To query the scanner status (Code-128/Read).
Value$=READER_QUERY$(13, 1)
PRINT "Value:",ASC(Value $)
Preamble$=READER_QUERY$(8, 3) „Preamble
characters
PRINT " Preamble:"+ Preamble $
Description:
A$ is a string variable to be assigned to the result.
N1% is an integer variable, indicating the parameter1.
N2% is an integer variable, indicating the parameter2.
Refer to “Appendix B” for more details about the parameter
setting.
READER_QUERY_LASER$
Purpose:
To query the scanner(Laser) current setting.
Syntax:
A$=READER_QUERY_LASER$(N1% , N2%)
Example:
„To query the scanner status (Code-128/Read).
Value$=READER_QUERY_LASER$(13, 1)
PRINT "Value:",ASC(Value $)
Preamble$=READER_QUERY_LASER$(8, 3)
PRINT " Preamble:"+ Preamble $
Description:
A$ is a string variable to be assigned to the result.
N1% is an integer variable, indicating the parameter1.
N2% is an integer variable, indicating the parameter2.
Refer to “Appendix C” for more details about the parameter
setting.
END IF
IF INKEY$=CHR$(27) THEN
DISABLE READER(1)
END
END IF
GOTO MAIN
Description:
Once the scanner port is initialized (by using ENABLE
READER command), call this DECODE command to
perform barcode decoding. This command should be called
constantly in user's program loops when barcode decoding is
required. If the barcode decoding is not required for a long
period of time, it is recommended that the scanner port be
disabled by using DISABLE READER command.
PT-Basic Programming Manual Ver. 1.00 48/143
SIM_SCANKEY_PRESS
Purpose:
To simulator the “Scan” key press or release.
Syntax:
SIM_SCANKEY_PRESS(N1%)
Example:
„Set the scan key pressed.
SIM_SCANKEY_PRESS(1)
…
„Set the scan key released.
SIM_SCANKEY_PRESS(0)
Description:
This command can simulator the scan key status for pressed
or released.
READER_SETFROMFILE
Purpose:
To set scanner setting by scanner setting file.
Syntax:
A%=READER_SETFROMFILE(FilePath$)
Example:
A%=READER_SETFROMFILE("c:\data\PA21.axs")
Description:
A% is an integer variable to be assigned to the result.
A%
Meaning
0
Setting fail
1
Setting OK
FilePath $ is a string variable, indicating the Scanner setting
file path.
PT-Basic Programming Manual Ver. 1.00 49/143
BEEP
Purpose:
To assign a beeper sequence to designate beeper operation.
Syntax:
BEEP(freq%, duration% {, freq%, duration%})
Example:
BEEP(99,30,0,10,88,30,0,10,66,30,0,0)
Description:
freq% is an integer variable, indicating the value of Beep
frequency ( 76000 / Actual Frequency Desired ).
A beep frequency is an integer used to specify the frequency
(tone) when the beeper been activated. The actual frequency
that the beeper gives is not the value specified to the beep
frequency. It is calculated by the following formula.
For instance, to get a frequency of 2000Hz, the value of beep
frequency should be 38. If no sound is desired (pause), the
beep frequency should be set to 0. A beep with frequency 0
does not terminate the beeper sequence. Suitable frequency for
the beeper ranges from 1 to 2700Hz, while peak volume is at
around 2000Hz.
Duration% is an integer variable, indicating the value of
beeping duration, which is specified in units of 10 ms.
X$is a string variable in the form of “yyyymmdd”.
DATE$ = X$, to set the current date.
Y$ is a string variable to be assigned to the result.
Y$ = DATE$,to get the current date, in the form “yyyymmdd”
DAY_OF_WEEK
Purpose:
To get the day of the week.
Syntax:
A% = DAY_OF_WEEK
Example:
PRINT DAY_OF_WEEK
Description:
A% is an integer variable to be assigned to the result. A value of
1 to 7 represents Monday to Sunday respectively.
TIME$
Purpose:
To set or to get the current time.
Syntax:
TIME$ = X$
Y$ = TIME$
Example:
PRINT TIME$
TIME $="180831"
PRINT TIME$
Description:
X$ is a string variable in the form of “hhmmss”.
TIME$ = X$, to set the current time.
Y$ is a string variable to be assigned to the result.
Y$ = TIME$, to get the current time, in the form of “hhmmss”.
TIMER
Purpose:
To return the number of seconds elapsed since the terminal is
powered on.
Syntax:
A% = TIMER
Example:
PRINT TIMER
Description:
A% is an integer variable to be assigned to the result.
3.9 Calendar and timer commands
PT-Basic Programming Manual Ver. 1.00 52/143
WAIT
Purpose:
To set system delay time.
Syntax:
WAIT(duration%)
Example:
WAIT(1000)
Description:
duration% is a positive integer variable, indicating the time
duration for a hold. This argument is specified in units of 5
ms.
PT-Basic Programming Manual Ver. 1.00 53/143
LED
Purpose:
To set the LED indicators.
Syntax:
LED(number%, mode%, duration%)
Example:
LED(2,2,100)
Description:
number%
description
1
LED displays green light.
2
LED displays red light.
3
LED displays orange light.
mode%
description
1
off for (duration% X 0.01) seconds then on
2
on for (duration% X 0.01) seconds then off
3
flash, on then off each for (duration% X 0.01)
seconds then repeat
3.10 LED Command
PT-Basic Programming Manual Ver. 1.00 54/143
CLR_KBD
Purpose:
To clear the keypad buffer.
Syntax:
CLR_KBD
Example:
CLR_KBD
Description:
This command will clear keypad buffer.
INKEY$
Purpose:
To read one character from the keypad buffer then remove it.
Syntax:
Str$ = INKEY$
Example:
START:
S$=INKEY$
IF S$<>"" THEN
PRINT ASC(S$)
IF ASC(S$)=27 THEN „ESC keyEND
END IF
END IF
GOTO START
…
Description:
Str$ is a string variable to be assigned to character read.
INPUT_LEN
Purpose:
To set or get input length when using “INPUT” or INPUT_S"
command.
Syntax:
X%= INPUT_LEN
INPUT_LEN=A%
Example:
INPUT_LEN=4
PRINT "INPUT STRING:"
A%=INPUT("",S$)
…
PRINT “Input length:”; INPUT_LEN
Description:
A% is an integer variable. When using “INPUT” or
“INPUT_S” command, it can set limit on input length(When
N%=0 indicating not limit).
X% is an integer variable, indicating the input length.
3.11 Keypad commands
PT-Basic Programming Manual Ver. 1.00 55/143
INPUT
Purpose:
To retrieve input from the keypad and store it in a variable.
Syntax:
A%=INPUT(S$ , variable)
Example:
PRINT "INPUT STRING:"
Result%=INPUT("",String$) „Input a string variable
PRINT "INPUT NUMBER:"
Result %=INPUT("123",Number%) „Input a numeric variable
Description:
A% is an integer variable to be assigned to the result.
A%
Meaning
0
Press the ENT
key and has not
input any item.
1
Inputs correctly.
255
Press the ESC
key.
-1
Input error.
S$ is a string variable, indicating the input default value.
variable is numeric or string variable that will receive the input
data. The data entered must match the data type of the variable.
When the input task is properly ended with the ENTER key being
pressed, the data string will be stored in a variable. Otherwise,
press the ESC key to abort the task.
INPUT_S
PT-Basic Programming Manual Ver. 1.00 56/143
Purpose:
To retrieve input from the keypad, scanning and store it in a
variable.
Syntax:
A%=INPUT_S(S$ , variable)
Example:
Result%=INPUT_S("",String$)
Description:
A% is an integer variable to be assigned to the result.
A%
Meaning
0
Press the ENT
key and has not
input any item.
1
Inputs correctly.
255
Press the ESC
key.
-1
Input error.
S$ is a string variable, indicating the input default value.
variable is numeric or string variable that will receive the input
data. The data entered must match the data type of the variable.
When the input task is properly ended with the ENTER key being
pressed, the data string will be stored in a variable. Otherwise,
press the ESC key to abort the task.
INPUT_S_ CARRYENT
Purpose:
To set ENT auto press on/off when using “INPUT_S” command.
Syntax:
INPUT_S_ CARRYENT(N%)
Example:
INPUT_S_ CARRYENT(1)
Description:
N% is an integer variable. When using “INPUT_S” command, it
can set auto press ENT on/off key after scanner reading.
N%
Auto press ENT
0
No 1 Yes
INPUT_S_VIBRATE
Purpose:
To set vibrator on or off when using “INPUT_S” command.
Syntax:
INPUT_S_VIBRATE(N%)
Example:
INPUT_S_VIBRATE(1)
Description:
N% is an integer variable. When using “INPUT_S” command, it
can set vibrator on or off after scanner reading.
N%
Meaning
0
Vibrate off
1
Vibrate on
PT-Basic Programming Manual Ver. 1.00 57/143
INPUT_S_SLEEP
Purpose:
To set scanner sleep on or off when using “INPUT_S” command.
Syntax:
INPUT_S_SLEEP(N%)
Example:
INPUT_S_SLEEP(1)
R%=INPUT_S("",S1$) „Scanner to sleep…
Description:
N% is an integer variable. After using “INPUT_S” command, the
“INPUT_S_SLEEP” command can set scanner to sleep or not.
If use this command and set “1”, when leaving “INPUT_S”
command, scanner will go to sleep.
N%
Meaning
0
Not sleep(scanner go to suspend)
1
To sleep
INPUT_MODE
Purpose:
To set the display mode of the input data.
Syntax:
INPUT_MODE(mode%)
Example:
INPUT_MODE(2)
Description:
mode% is an integer variable, indicating the input mode.
mode%
Meaning
0
Nothing will be displayed on the LCD.
1
The input characters will be displayed on the LCD
(default).
2
“*” will be displayed instead of the input
characters. Usually it is applied for password input.
KEY_CLICK
Purpose:
To enable or disable the key click sound.
Syntax:
KEY_CLICK(status%)
Example:
KEY_CLICK(0)
Description:
status% is an integer variable, indicating the key click status.
status%
Key click sound
0
Disable
1
Enable
PT-Basic Programming Manual Ver. 1.00 58/143
ALPHA_LOCK
Purpose:
To set the ALPHA state for input mode.
Syntax:
ALPHA_LOCK(status%)
Example:
ALPHA_LOCK(1)
Description:
status% is a string variable, indicating the Alpha status.
status%
Alpha status
Default input
0
Unlock
Numeric mode
1
Lock
Alpha mode (lower case)
2
Lock
Alpha mode (upper case)
3
Lock
Numeric mode
GET_ALPHA_LOCK
Purpose:
To get information of the ALPHA state for input mode.
Syntax:
A% = GET_ALPHA_LOCK
Example:
Alpha_lock% = GET_ALPHA_LOCK
Description:
A% is an integer variable to be assigned to the result.
GET_KEY_CLICK
Purpose:
To get current key click status.
Syntax:
A% = GET_KEY_CLICK
Example:
Key_click% = GET_KEY_CLICK
Description:
A% is an integer variable to be assigned to the result.
A% is an integer variable to be assigned to the keypad
backlight timer.
X% is an integer variable indicating a period of time in units
of 1-second.
KEYPAD_BL
Purpose:
To set keypad backlight on or off.
Syntax:
KEYPAD_BL(N%)
Example:
KEYPAD_BL(1)
Description:
N% is an integer variable indicating the keypad backlight on
or off.
N%
Keypad backlight status
0
Off 1 On
PT-Basic Programming Manual Ver. 1.00 60/143
DEF_PKEY
Purpose:
To change the definition of programmable key (P1 & P2) .
Syntax:
DEF_PKEY(N1% ,N2%)
Example:
DEF_PKEY(1,13) ‟P1 key define to ENT key
DEF_PKEY(2,49) „P2 key define to „1‟ key
DEF_PKEY(1,21) ‟P1 key define to P1 key
DEF_PKEY(2,22) „P2 key define to P2 key
DEF_PKEY(1,5) ‟P1 key define to UP key
DEF_PKEY(2,6) „P2 key define to DOWN key
DEF_PKEY(1,7) ‟P1 key define to LEFT key
DEF_PKEY(2,11) „P2 key define to RIGHT keyDEF_PKEY(1,27) ‟P1 key define to ESC key
DEF_PKEY(2,8) „P2 key define to BS key
DEF_PKEY(1,127) ‟P1 key define to DEL key
DEF_PKEY(2,32) „P2 key define to SP key
DEF_PKEY(1,45) ‟P1 key define to „-„ key
Description:
N1%
Meaning
1
Define P1 key
2
Define P2 key
N2% is an integer variable indicating the key to be defined.
PT-Basic Programming Manual Ver. 1.00 61/143
SCANKEYPWON
Purpose:
To set power on by scan key.
Syntax:
A%=SCANKEYPWON(N%)
Example:
Result%=SCANKEYPWON(1)
Description:
N%
Meaning
0
Normal
1
Set power on by scan key
A% is an integer variable to be assigned to the result.
A%
Meaning
0
Setting fail
1
Setting success
GET_SCANKEYPWON
Purpose:
Get state for power on by scan key.
Syntax:
A%= GET_SCANKEYPWON
Example:
Result%= GET_SCANKEYPWON
Description:
A% is an integer variable to be assigned to the result.
A%
Meaning
0
Normal
1
Set power on by scan key
PT-Basic Programming Manual Ver. 1.00 62/143
BACK_LIGHT_DURATION
Purpose:
To specify how long the backlight will last once the terminal
is turned on.
Syntax:
BACK_LIGHT_DURATION(N%)
Example:
BACK_LIGHT_DURATION(20)
Description:
N% is an integer variable indicating the LCD backlight timer
in the range from 0 to 65535. It is specified in units of 1-sec.
If N%=0, then LCD backlight will always be on.
LCD_CONTRAST
Purpose:
To set the contrast level of the LCD.
Syntax:
LCD_CONTRAST(N%)
Example:
LCD_CONTRAST(5)
Description:
N% is an integer variable indicating the LCD contrast level in
the range from 1 to 5. The higher value means higher
contrast.
CURSOR
Purpose:
To turn on/off the cursor indication in the activated
TextBlock.
Syntax:
CURSOR(status%)
Example:
CURSOR(1)
Description:
status% is an integer indicating the cursor on or off.
status%
Meaning
0
Cursor off
1
Cursor on
CURSOR_X
Purpose:
To get the x coordinate of the current cursor position in the
activated TextBlock.
Syntax:
X% = CURSOR_X
Example:
X% = CURSOR_X
Description:
X% is an integer variable to be assigned to the X coordinate
of the current cursor position.
3.12 LCD Commands
The following commands: CURSOR, CURSOR_X, CURSOR_Y, LOCATE,
FILL_RECT, PRINT, CLR_RECT, CLS, SHOW_IMAGE, CLR_EOL, will only
affect the current TextBlock on LCD screen. Parameters of these commands will
be based on TextBlock‟s size and position.
PT-Basic Programming Manual Ver. 1.00 63/143
CURSOR_Y
Purpose:
To get the y coordinate of the current cursor position in the
activated TextBlock.
Syntax:
Y% = CURSOR_Y
Example:
Y% = CURSOR_Y
Description:
Y% is an integer variable to be assigned to the Y coordinate
of the current cursor position.
LOCATE
Purpose:
To move the cursor to a specified location in the activated
TextBlock.
Syntax:
LOCATE X% , Y%
Example:
LOCATE 0,0
…
LOCATE 2,3
…
Description:
X% is an integer variable indicating the new X coordinate
position of the cursor.
Y% is an integer variable indicating the new Y coordinate
position of the cursor.
FILL_RECT
Purpose:
To fill a rectangular area in the activated TextBlock with a
user defined color.
expression may be numeric or string expression.
The position of echo printed item is determined by the
punctuation used to separate items in the list. In the list of
expression, a comma causes the next character to be printed
after the last character with a blank space. A semicolon
causes the next character to be printed immediately after the
last character. If the list of expressions terminates without a
comma or semicolon, a carriage return is printed at the end of
the line.
CLR_RECT
Purpose:
To clear a rectangular area in the activated TextBlock. The
cursor position is not affected after the operation.
Syntax:
CLR_RECT(left% , top% , width% , height%)
Example:
CLR_RECT(100,100,100,100)
Description:
Several key argument as below:
left %
Fill from the start point of X-axis (pixel).
top %
Fill from the start point of Y-axis (pixel).
width%
Fill the width from the start point (pixel).
height%
Fill the height from the start point (pixel).
PT-Basic Programming Manual Ver. 1.00 65/143
CLS
Purpose:
To clear the activated TextBlock.
Syntax:
CLS
Example:
CLS
Description:
After executing this command, whatever being shown on the
LCD will be erased and the cursor will be moved to (0,0).
SHOW_IMAGE
Purpose:
To put a rectangular bitmap in the activated TextBlock.
To clear from where the cursor is to the end of the line. The
cursor position is not affected after the operation.
Syntax:
CLR_EOL
Example:
PRINT "TEST BASIC"
LOCATE 3,0
CLR_EOL
Description:
The CLR_EOL command clears from where the cursor is to
the end of the line and then moves the cursor to the original
place.
PT-Basic Programming Manual Ver. 1.00 66/143
DISPFONT_SETFONT
Purpose:
To set user font from font file.
Syntax:
A%=DISPFONT_SETFONT(FontID% ,FontPath$)
Example:
A%=DISPFONT_SETFONT(2,"D:\Fonts\Font16.cft")
Description:
A% is an integer variable to be assigned to the result.
A%
Meaning
0
Set font fail
1
Set font OK
Several key arguments as below:
FontID%
Font ID (2~9)
FontPath$
Font file path
DISPFONT_INFO_TYPE
Purpose:
To get font type.
Syntax:
A%=DISPFONT_INFO_TYPE(FontID%)
Example:
A%=DISPFONT_INFO_TYPE(2)
Description:
A% is an integer variable to be assigned to the result.
FontID% is an integer variable in the range from 2 to 9.
DISPFONT_INFO_HEIGHT
Purpose:
To get font height.
Syntax:
A%=DISPFONT_INFO_HEIGHT(FontID%)
Example:
C%=DISPFONT_INFO_HEIGHT(2)
Description:
A% is an integer variable to be assigned to the result.
FontID% is an integer variable in the range from 2 to 9.
3.13 Font
This utility “SDK Tool” can be used as the following:
When you need a font file for your application, you can make the font file by
“SDK Tool”, the font generator can help you making a font file.
3.13.1 User font commands
PT-Basic Programming Manual Ver. 1.00 67/143
DISPFONT_INFO_WIDTH
Purpose:
To get font width.
Syntax:
A%=DISPFONT_INFO_WIDTH(FontID %)
Example:
B%=DISPFONT_INFO_WIDTH(3)
Description:
A% is an integer variable to be assigned to the result.
FontID% is an integer variable in the range from 2 to 9.
PT-Basic Programming Manual Ver. 1.00 68/143
3.14 TextBlock
TextBlock is a floating text printing rectangle area on LCD screen. TextBlock
defines activated area anywhere within LCD screen display. An out of display
area definition is not allowed.
Each TextBlock has individual attribute definition for position, size, font,
background color or bmp. There are total 16 TextBlocks. TextBlock(0) is system
default block. The setting of TextBlock(0) can‟t be executed. TextBlock(1~15)
are user defind.
PT-Basic Programming Manual Ver. 1.00 69/143
DEFINETEXTBLOCK_COLOR
Purpose:
To define the TextBlock setting and the background using default
background color or user defined color.
PRINTTEXTBLOCK(2,5,5,"Hello",0) „font color is black
Description:
Several key arguments as below:
BlockNo%
TextBlock number(0~15)
Column%
TextBlock column number.
Row%
TextBlock row number.
Str$
Text data.
FontColor %
Text color.
GETTEXTBLOCKCUR_X
Purpose:
To get the x coordinate of the current TextBlock position.
Syntax:
A% =GETTEXTBLOCKCUR_X(BlockNo %)
Example:
PRINT "X=",GETTEXTBLOCKCUR_X(1)
Description:
A% is an integer variable to be assigned to the result.
BlockNo% is an integer variable in the range from 0 to 15.
PT-Basic Programming Manual Ver. 1.00 72/143
GETTEXTBLOCKCUR_Y
Purpose:
To get the y coordinate of the current TextBlock position.
Syntax:
A% =GETTEXTBLOCKCUR_Y(BlockNo %)
Example:
PRINT "Y=",GETTEXTBLOCKCUR_Y(1)
Description:
A% is an integer variable to be assigned to the result.
BlockNo% is an integer variable in the range from 0 to 15.
SETTEXTBLOCKCUR
Purpose:
To set specific TextBlock as active TextBlock and set position.
Syntax:
SETTEXTBLOCKCUR(BlockNo %, Column%, Row%)
Example:
SETTEXTBLOCKCUR(0,0,0)
Description:
Several key arguments as below:
BlockNo%
TextBlock number(0~15)
Column%
TextBlock column number.
Row%
TextBlock row number.
SHOWTEXTBLOCKCURSOR
Purpose:
To show or hide TextBlock cursor.
Syntax:
SHOWTEXTBLOCKCURSOR(BlockNo %, Show%, Type%)
Example:
SHOWTEXTBLOCKCURSOR(1,1,1)
Description:
Several key arguments as below:
BlockNo%
TextBlock number(0~15)
Show %
1:Show cursor
0:Hide cursor
Type %
0: Cursor off.
1: Cursor on, and cursor type is a line as _.
2: Cursor on, and cursor type is a line as |.
3: Cursor on, and cursor type is a block as ■.
TEXTBLOCK_SETBGCOLOR
Purpose:
To set default background color.
Syntax:
TEXTBLOCK_SETBGCOLOR(Color%)
Example:
TEXTBLOCK_SETBGCOLOR(16711680) „Blue
Description:
Color % is an integer variable indicating which color you want
to set.
After executing this command, all TextBlock will be reset.
PT-Basic Programming Manual Ver. 1.00 73/143
TEXTBLOCK_SETBGIMAGE
Purpose:
To set default background image for bitmap file.
Syntax:
A%= TEXTBLOCK_SETBGIMAGE(FilePath$)
Example:
R%=TEXTBLOCK_SETBGIMAGE("d:\program\test.bmp")
Description:
A% is an integer variable to be assigned to the result.
A%
Meaning
0
Setting fail
1
Setting OK
FilePath $ is a string variable, indicating the bitmap file path.
After executing this command, all TextBlock will be reset.
TEXTBLOCK_MODE
Purpose:
To set or get TextBlock mode for single or multi layer.
F% is an integer variable to assigned to the result.
F%
Meaning
0
Open file fail.
Other
Open successfully.
It returns the file handle.
filename$ is a string variable indicating the file path.
In case of error, open will return an integer value of 0. You
can use the GET_FILE_ERROR command to get the file
error code. Possible error codes and their interpretation are
listed below:
GET_FILE_ERROR
Meaning
1
Filename is a NULL string.
6
Can't create file because the
maximum number of files
allowed in the system is
exceeded.
File path error.
3.15 File manipulation commands
3.15.1 Standard Commands
PT-Basic Programming Manual Ver. 1.00 75/143
OPENOUT
Purpose:
To open (w+) a file and get the file for further processing.
F% is sn integer variable to be assigned to the result.
F%
Meaning
0
Open file failed.
Other
Open successfully. It returns the file.
filename$ is a string variable indicating the file path.
In case of error, open will return an integer value of 0. You
can use the GET_FILE_ERROR command to get the file
error code. Possible error codes and their interpretation are
listed below:
GET_FILE_ERROR
Meaning
1
Filename is a NULL string.
6
Can't create file because the
maximum number of files
allowed in the system is
exceeded.
File path error.
PT-Basic Programming Manual Ver. 1.00 76/143
OPENUP
Purpose:
To open (r+) a file and get the file for further processing.
F% is sn integer variable to be assigned to the result.
F%
Meaning
0
Open file failed.
Other
Open successfully. It returns the file.
filename$ is a string variable, indicating the file path.
In case of error, open will return an integer value of 0. You
can use the GET_FILE_ERROR command to get the file
error code. Possible error codes and their interpretation are
listed below:
GET_FILE_ERROR
Meaning
1
Filename is a NULL string.
6
Can't create file because the
maximum number of files
allowed in the system is
exceeded.
File path error.
CLOSE
Purpose:
To close a file.
Syntax:
CLOSE # F%
Example:
CLOSE # FILEID%
Description:
F% is an integer indicating the file handle.
You can use the GET_FILE_ERROR command to get the
file error code. Possible error codes and their interpretation
are listed below:
GET_FILE_ERROR
Meaning
2
File specified does not exist.
8
File not opened
PT-Basic Programming Manual Ver. 1.00 77/143
BGET
Purpose:
To read a byte from a file. The current position is updated
after reading.
Syntax:
STR% = BGET # FILEID%
Example:
STRING1%=BGET # FILEID%
PRINT CHR$(STRING1%)
Description:
STR% is an integer variable to be returned to the result.
FILEID% is an integer variable indicating the file handle.
You can use the GET_FILE_ERROR command to get the
file error code. Possible error codes and their interpretation
are listed below:
GET_FILE_ERROR
Meaning
2
File specified does not exist.
7
File not opened
BGETEXT
Purpose:
To read a specified number of bytes from a file. The current
position is updated after reading.
STR$ is a string to be returned to the result.
N% is an integer indicating the number of bytes to be read.
FILEID% is an integer variable indicating the file handle.
You can use the GET_FILE_ERROR command to get the
file error code. Possible error codes and their interpretation
are listed below:
GET_FILE_ERROR
Meaning
2
File specified does not exist.
7
File not opened
PT-Basic Programming Manual Ver. 1.00 78/143
GET$
Purpose:
Read a line terminated by a null character “\0” from a file.
Syntax:
FileData$ = GET$ # FILEID%
Example:
WHILE (EOF#FILEID% <> -1)
Str$=GET$ # FILEID%
PRINT Str$
WEND
Description:
FileData$ is a string to be returned to the result.
FILEID% is an integer variable indicating the file handle.
You can use the GET_FILE_ERROR command to get the
file error code. Possible error codes and their interpretation
are listed below:
FILEID% is an integer variable, indicating the file handle.
expr 1 ~ expr n is string expression indicating the string data
to write to file.
You can use the GET_FILE_ERROR command to get the
file error code. Possible error codes and their interpretation
are listed below:
GET_FILE_ERROR
Meaning
2
File specified does not exist.
7
File not opened
10
Not enough memory to write to
file.
PT-Basic Programming Manual Ver. 1.00 79/143
EOF
Purpose:
To check if file pointer of a file reaches end of file.
Syntax:
E%=EOF # FILEID%
Example:
WHILE (EOF#FILEID% <> -1)
Str$=GET$ # FILEID%
PRINT Str$
WEND
Description:
E% is an integer to be assigned to the result.
E%
Meaning
0 (False)
Not end-of-file.
-1 (True)
End-of-file
FILEID% is an integer variable indicating the file handle.
You can use the GET_FILE_ERROR command to get the
file error code. Possible error codes and their interpretation
are listed below:
GET_FILE_ERROR
Meaning
2
File specified does not exist.
8
File not opened
PTR
Purpose:
To get or move the file pointer position of a file.
Syntax:
TELLPTR% = PTR # FILEID%
PTR # FILEID% = NPTR%
Example:
...
TELLPTR%=PTR # FILEID%
…
PTR # FILEID% = 40
Description:
TELLPTR % is an integer variable to be assigned to the
result.
TELLPTR% = PTR # FILEID%, to get the file pointer
position of a file.
NPTR % is an integer variable indicating the offset bytes
address been specified.
FILEID% is an integer variable indicating the file handle.
You can use the GET_FILE_ERROR command to get the
file error code. Possible error codes and their interpretation
are listed below:
FILESIZE% is an integer variable to be returned the file
length.
SIZE% is an integer variable indicating the length to be
changed of the file.
FILEID% is an integer variable indicating the file handle.
You can use the GET_FILE_ERROR command to get the
file error code. Possible error codes and their interpretation
are listed below:
GET_FILE_ERROR
Meaning
2
File specified does not exist.
8
File not opened
GET_FILE_ERROR
Purpose:
To get the file error code.
Syntax:
A%=GET_FILE_ERROR
Example:
A%=GET_FILE_ERROR
PRINT “File error code:”,A%
Description:
A% is an integer to be assigned to the result. If there is no
error, it returns 0. If it returns a value other than 0, it‟s file
error code.
This command can initialize a work of advance searching file. After
inserting every argument, you can to search files.
When using this command to initial a DBMS search, you have to
take care for:
1. This command cannot support Variable field length search.
2. When initial, we will make a index file in C disk, so it has to
take a few time.
3. The index filename will be similar to origin file. For example,
the lookup file name is “AAA.txt”, the index filename will be
“AAA.idx”. So, you have to check the duplicate filename to
avoid error for making index file.
4. You have to reserve some space for the function to make index
file in C disk.
A% is an integer variable to be assigned to the result.
A%
Meaning
0
DBMS initialization fail
1
DBMS initialization OK
5
Open file error
6
The DBMS ID is illegal.
7
DBMS ID already used.
8
The record type is illegal.
9
The field number exceeds 20.
-1
Argument S2$ or N1% is
error, please check it.
-2
Cannot make a IDX file,
PT-Basic Programming Manual Ver. 1.00 83/143
please check your lookup
filename or C disk size.
Several key arguments as below:
FilePath$
DBMS file path
DBMSID%
DBMS ID (1~10)
S1$
This argument has two kinds of meanings.
When search for regular length, it needs to
insert the unsigned char array; the array
represents the length of every field.
When search for variable length, it needs
to insert one character to represent separate
symbol.
S2$
This argument can give max. 8 key fields for
search. We will make a checksum index file for
these key fields.
N1%
This argument can give the sum of key fields
size.
N2%
When N1%=0, search for regular length. It
has no separate symbols between different
fields.
When N1%=1, search for variable length.
It needs a separate symbol between
different fields.
N3%
This argument is each record‟s length.
When N1%=0, needs to insert this value,
not including the symbol of line feed.
When N1%=1, this field can insert any
value.
N4%
This argument is the field‟s quantity of each
record (1~20).
DBMS_CLOSE_SEARCH
Purpose:
To close the file search in disk.
Syntax:
DBMS_CLOSE_SEARCH(DBMSID%)
Example:
DBMS_CLOSE_SEARCH(1)
Description:
DBMSID% is an integer variable in the range from 1 to 10.
ON COM(1) GOSUB READ1
CLS
PRINT "==COM TEST=="
LOCATE 0,1
PRINT "ENT TO WRITE"
SET_COM(1,1,1,2,1)
OPEN_COM(1)
CLEAR_COM(1)
SET_RTS(1,1)
LOOP2:
IF INKEY$="" THEN
GOTO LOOP2 END IF
CLOSE_COM(1)
END
READ1:
A$=READ_COM$(1)
PRINT A$
RETURN
Description:
A$ is a string variable to be assigned to the data.
N% is an integer variable indicating which COM port the
data is to be read (now we only can choose 1).
If the receiver buffer is empty, an empty string will be
returned.
PT-Basic Programming Manual Ver. 1.00 89/143
WRITE_COM
Purpose:
To send a string to the host through a specified COM port.
Syntax:
WRITE_COM(N%, A$)
Example:
CLS
PRINT "===COM TEST==="
PRINT "ENT TO WRITE"
SET_COM(1,1,1,2,1)
OPEN_COM(1)
WHILE INKEY$<>CHR$(13)
WEND
STR1$="Hello!!"
WHILE GET_CTS(1)=0
WEND
WRITE_COM(1,STR1$)
…
CLOSE_COM(1)
END
Description:
N% is an integer variable indicating which COM port the
data is to be sent to (now we only can choose 1).
A$ is a string variable indicating the string to be sent.
GET_CTS
Purpose:
To get CTS level.
Syntax:
A% = GET_CTS(N%)
Example:
PRINT “CTS Status:”,GET_CTS(1)
Description:
A% is an integer variable to be assigned to the result.
A%
Meaning
0
Negated (Space)
1
Asserted (Mark)
N% is an integer variable indicating which COM port to get
CTS level (now we only can choose 1).
PT-Basic Programming Manual Ver. 1.00 90/143
SET_RTS
Purpose:
To set RTS level.
Syntax:
SET_RTS(N1%, N2%)
Example:
SET_RTS(1, 1)
Description:
N1% is an integer variable indicating which COM port to set
RTS level (now we only can choose 1).
N2% is an integer variable indicating the RTS state.
N2%
Meaning
0
Negated (Space)
1
Asserted (Mark)
CLEAR_COM
Purpose:
To clear receiver buffer.
Syntax:
CLEAR_COM(N%)
Example:
CLEAR_COM(1)
Description:
N% is an integer variable indicating which COM port to
clear receive buffer (now we only can choose 1).
COM_DELIMITER
Purpose:
To change delimiter of sending and receiving string for a
specified COM port.
Syntax:
COM_DELIMITER(N% ,C%)
Example:
COM_DELIMITER(1,13) „use carriage return as
delimiter
COM_DELIMITER(1,38) „use „&‟ character as
delimiter
COM_DELIMITER(1,-1) „no delimiter
Description:
N% is an integer variable indicating which COM port is to be
set (now we only can choose 1).
C% is an integer variable indicating the ASCII code of the
delimiter character, in the range from 0 to 255. If it is other
value, no delimiter will be applied.
The default COM_DELIMITER is 0xd.
PT-Basic Programming Manual Ver. 1.00 91/143
FILE_TRANS
Purpose:
Using FILE_TRANS to upload or download files.
Syntax:
FILE_TRANS
Example:
FILE_TRANS
Description:
The FILE_TRANS command provides the transmission
environment to link with Argolink and make file uploading or
downloading.
Pressing ESC key can quit the transmission operation.
FILE_TRANS_REALTIME
Purpose:
Using FILE_TRANS_REALTIME to upload or download
files immediately.
Syntax:
FILE_TRANS_REALTIME(N%)
Example:
FILE_TRANS_REALTIME(1)
Description:
N% is an integer variable indicating the transmission state.
N%
Meaning
0
Transmission, not real-time.
1
Real-time transmission.
PT-Basic Programming Manual Ver. 1.00 92/143
FILE_TRANS_BAUD
Purpose:
To get or set the transmission baud rate.
Syntax:
A% = FILE_TRANS_BAUD
FILE_TRANS_BAUD = X%
Example:
N%=FILE_TRANS_BAUD
…
FILE_TRANS_BAUD=2 „baud rate is 38400 bps
Description:
A% is an integer variable to be assigned for the transmission
baud rate.
X% is an integer variable indicating baud rate to be set.
A% is an integer variable to be assigned for the transmission
interface.
X% is an integer variable indicating interface to be set.
FILE_TRANS_INTERFACE
Interface
0
RS-232
1
USB
PT-Basic Programming Manual Ver. 1.00 93/143
RAM_SIZE
Purpose:
To check the total space in disk C.
Syntax:
RAMSIZE% = RAM_SIZE
Example:
PRINT "RAM_SIZE=",RAM_SIZE
Description:
RAMSIZE% is an integer variable to be assigned for the total
space in disk C.
ROM_SIZE
Purpose:
To check the total space in disk D.
Syntax:
ROMSIZE% = ROM_SIZE
Example:
PRINT "ROM_SIZE=",ROM_SIZE
Description:
ROMSIZE% is an integer variable to be assigned for the total
space in disk D.
FREE_MEMORY
Purpose:
To check the free space in disk C or disk D.
Syntax:
FREESIZE% = FREE_MEMORY(N%)
Example:
PRINT “Free on disk C:”;FREE_MEMORY(0)
PRINT “Free on disk D:”;FREE_MEMORY(1)
…
Description:
FREESIZE% is an integer variable to be assigned for the
free speace in disk C(N%=0) or disk D (N%=1).
DISK_USEDSIZE
Purpose:
To check the occupid space in disk C or disk D.
Syntax:
USEDSIZE% = DISK_USEDSIZE(N%)
Example:
PRINT "USED C SIZE:",DISK_USEDSIZE(0)
PRINT "USED D SIZE:",DISK_USEDSIZE(1)
Description:
USEDSIZE% is an integer variable to be assigned for the
occupied space in disk C (N%=0) or disk D (N%=1).
3.18 Memory commands
PT-Basic Programming Manual Ver. 1.00 94/143
BT_START
Purpose:
Bluetooth module power enable.
Syntax:
BT_START
Example:
BT_START
…
…
BT_STOP
Description:
This command can enable Bluetooth module power. After use this
command, the left led will flash blue light.If you want to use other
Bluetooth command, you must run this command first.
You can use the “GET_BT_ERROR” command to get the error
code. Possible error codes and their interpretation are listed below:
GET_BT_ERROR
Meaning
1
Bluetooth module power enable.
6
The terminal is not PT-20B.
8
Bluetooth module has been power
enable, please run.
BT_STOP
Purpose:
Bluetooth module power disable.
Syntax:
BT_STOP
Example:
BT_START
…
…
BT_STOP
Description:
This command can disable Bluetooth module power. The left led
will stop flashing.
You can use the “GET_BT_ERROR” command to get the error
code. Possible error codes and their interpretation are listed below:
GET_BT_ERROR
Meaning
1
Bluetooth module power disable.
6
The terminal is not PT-20B.
7
Bluetooth module power disable, please
3.19 Bluetooth commands (Only for PT-20B)
These commands only for PT-20B, and our Bluetooth module only support SPP
mode(Serial Port Profile).
PT-Basic Programming Manual Ver. 1.00 95/143
run BT_SART.
BT_OPEN
Purpose:
Bluetooth connect.
Syntax:
BT_OPEN
Example:
BT_OPEN
…
…
BT_CLOSE
Description:
This command can connect to other Bluetooth device.Befor use this
command, you have to set the target Bluetooth MAC address by
using “BT_SETLOCALSET” command.
You can use the “GET_BT_ERROR” command to get the error
code. Possible error codes and their interpretation are listed below:
GET_BT_ERROR
Meaning
1
Bluetooth connect ok.
5
Connect timeout.
6
The terminal is not PT-20B.
7
Bluetooth module power disable, please
run BT_ SART.
10
Bluetooth already connect.
BT_CLOSE
Purpose:
Bluetooth disconnect.
Syntax:
BT_CLOSE
Example:
BT_OPEN
…
…
BT_CLOSE
Description:
This command can disconnect Bluetooth. If you want to
disconnect, you can use “BT_STOP” or this command.
You can use the “GET_BT_ERROR” command to get the error
code. Possible error codes and their interpretation are listed below:
GET_BT_ERROR
Meaning
1
Bluetooth disconnect ok.
5
Connect timeout.
6
The terminal is not PT-20B.
7
Bluetooth module power disable,
please run BT_ SART.
BT_WRITE
PT-Basic Programming Manual Ver. 1.00 96/143
Purpose:
Write characters to Bluetooth module.
Syntax:
N1%=BT_WRITE(A$,N2%)
Example:
BT_START
…
BT_OPEN
IF GET_BT_ERROR=1 THEN
CLS
PRINT " BlueTooth test"
WHILE 1
A$=INKEY$
IF A$<>"" THEN
IF(ASC(A$)=27) THEN EXIT
N1%=0
N1%=BT_WRITE(A$,1)
IF N1%=1 THEN PRINT A$;
END IF
STR1$=BT_READ$(1)
IF LEN(STR1$)<>0 THEN PRINT STR1$;
WEND
BT_CLOSE
ELSE PRINT "Link error!!!"
WHILE INKEY$=""
WEND
END IF
…
BT_STOP
…
Description:
If Bluetooth is connected, this command can write characters to
other Bluetooth device.
N1% is an integer variable.It will tell you how many characters send to
other Bluetooth device.
A$ is a string variable indicating the data is to be sent.
N2% is an integer variable indicating number of bytes to be writen
to other Bluetooth device.
You can use the “GET_BT_ERROR” command to get the error
PT-Basic Programming Manual Ver. 1.00 97/143
code. Possible error codes and their interpretation are listed below:
GET_BT_ERROR
Meaning
1
Write OK.
2
Parameter error, please check your
parmeter.
6
The terminal is not PT-20B.
7
Bluetooth module power disable,
please run BT_ SART.
9
Bluetooth not connect to other
bluetooth device, please run
BT_OPEN.
BT_READ$
Purpose:
Read characters from Bluetooth module.
Syntax:
A$=BT_READ$(N%)
Example:
STR1$=BT_READ$(1)
Description:
If Bluetooth is connected, this command can read characters from
Bluetooth module.
A$ is a string variable to be assigned to the data.
N% is an integer variable indicating number of bytes to be read
from other Bluetooth device.
You can use the “GET_BT_ERROR” command to get the error
code. Possible error codes and their interpretation are listed below:
GET_BT_ERROR
Meaning
1
Read OK.
2
Parameter error, please check your
parmeter.
6
The terminal is not PT-20B.
7
Bluetooth module power disable,
please run BT_ SART.
9
Bluetooth not connect to other
bluetooth device, please run
BT_OPEN.