Copyright © DENSO WAVE INCORPORATED, 2001 All rights reserved. No part of this publication may be reproduced in any form or by any means without permission in writing from the publisher. Specifications are subject to change without prior notice. All products and company names mentioned in this manual are trademarks or registered trademarks of their respective holders. BHT is a trademark of DENSO CORPORATION.
Preface This manual describes the syntax and development procedure of BHT-BASIC 3.5 which is a programming language for developing application programs of the BHT-100Q/100B. It is intended for programmers who already have some experience in BASIC programming. For the basic description about the BASIC language, refer to documentations concerning Microsoft BASIC® or QuickBASIC®. For the details about Windows™, refer to the Microsoft Windows documentations.
How this book is organized This manual is made up of 18 chapters and appendices. Chapter 1. Software Overview for the BHT Surveys the software structure of the BHT and introduces the programs integrated in the ROM and the language features of BHT-BASIC. Chapter 2. Development Environment and Procedures Describes hardware and software required for developing application programs and the developing procedure. Chapter 3.
Chapter 12. Power-related Functions Describes low battery warning, the prohibited simultaneous operation of the beeper/illumination LED, the wakeup, and remote wakeup. Chapter 13. Backlight Function Describes the backlight function Chapter 14. Statement Reference Describes the statements available in BHT-BASIC, including the error codes and messages. Chapter 15. Function Reference Describes the functions available in BHT-BASIC, including the error codes and messages. Chapter 16.
■ Notational Conventions Used in This Book Several notational conventions are used in this book for the sake of clarity. 1. Reserved words are printed in UPPERCASE. These are BHT-BASIC’s keywords. You should not use them as label names or variable names. Example: CHAIN, GOSUB, and ABS 2. Parameters or arguments which should be specified in the statements or functions are expressed in italics. Example: characode and onduration 3. Items enclosed in square brackets [ ] are optional, which can be omitted.
■ Icons Used in This Book Statements and functions unique to BHT-BASIC. ■ Syntax for the Statement Reference and Function Reference The syntax in programming is expressed as shown in the example below.
■ Bar Code and 2D Code The BHT-100B is capable of reading bar codes; the BHT-100Q is capable of reading 2D codes and bar codes. In descriptions common to bar codes and 2D codes, both of those codes are expressed as "bar code" in this manual.
Chapter 1 Software Overview for the BHT CONTENTS 1.1 Software Overview........................................................................................... 2 1.1.1 Software Structure of the BHT ............................................................. 2 1.1.2 Overview of BHT-BASIC ...................................................................... 4 1.2 BHT-BASIC...................................................................................................... 5 1.2.1 Features ...........
1.1 Software Overview 1.1.1 Software Structure of the BHT The structure of software for the BHT is shown below. Flash memory User data User programs Application programs Extension libraries and extended functions System Mode System programs BHT-BASIC Interpreter Font files Drivers Hardware The BHT has a flash ROM and RAM. All of the system programs, user programs, extension libraries, and extended functions are stored in the flash ROM. The RAM is used to run those programs efficiently.
Chapter 1. Software Overview for the BHT System Programs Drivers A set of programs which is called by the BHT-BASIC Interpreter or System Mode and directly controls the hardware. The drivers include the Decoder Software used for bar code reading. BHT-BASIC Interpreter Interprets and executes user programs. System Mode Sets up the execution environment for user programs.
1.1.2 Overview of BHT-BASIC With BHT-BASIC, you can customize application programs for meeting your specific needs as given below. • Retrieving products names, price information, etc. in a master file. • Making a checking procedure more reliable with check digits in bar code reading. • Improving the checking procedure by checking the number of digits entered from the keyboard. • Calculating (e.g., subtotals and totals).
Chapter 1. Software Overview for the BHT 1.2 BHT-BASIC 1.2.1 Features BHT-BASIC is designed as an optimal programming language in making application programs for the bar code handy terminal BHT, and to enable efficient program development, with the following features: ■ Syntax Similar to Microsoft™ BASIC BHT-BASIC uses the BASIC language which is the most widely used one among the high-level languages. The syntax of BHT-BASIC is as close as possible to that used in Microsoft BASIC (MS-BASIC).
1.2.2 What’s New in BHT-BASIC 3.5 Upgraded from BHT-BASIC 3.0? Based on BHT-BASIC 3.0, BHT-BASIC 3.5 newly supports the following functions: [ 1 ] Compiler ■ Object linkage editor, Linker While BHT-BASIC 3.0 Compiler compiles a single source program into a single user program, BHT-BASIC 3.5 Compiler can convert more than one source program into individual object programs (intermediate code files for a user program) and then combine them together through Linker to build a user program.
Chapter 1. Software Overview for the BHT ■ Defining and declaring user-defined functions more easily BHT-BASIC 3.5 has added FUNCTION…END FUNCTION, SUB...END SUB, and DECLARE statements. With the former two, you may easily define your own functions—FUNCTION and SUB. With the latter one, you may declare FUNCTION and SUB functions which are defined in any other source files. ■ Scoping variables to be local or global (with PRIVATE or GLOBAL statement) In BHT-BASIC 3.
1.3 Program Development and Execution BHT-BASIC consists of Compiler and Interpreter. 1.3.1 Compiler BHT-BASIC 3.5 Compiler consists of the following Compiler, Linker and Librarian: ■ Compiler Compiler, which is one of the development tools, compiles source programs written on a PC into the resulting "object files." It checks syntax of source programs during compilation and makes an error file if any syntax error is found.
Chapter 2 Development Environment and Procedures CONTENTS 2.1 Overview of Development Environment ........................................................ 11 2.1.1 Required Hardware ............................................................................ 11 2.1.2 Required Software.............................................................................. 12 2.2 Overview of Developing Procedures ............................................................. 13 2.2.1 Developing Procedures ...........
2.4.7 Options ............................................................................................... 30 [ 1 ] Compiling options...................................................................... 30 [ 2 ] Linking options .......................................................................... 31 [ 3 ] Outputting debug information files............................................. 31 [ 4 ] Outputting list files .....................................................................
Chapter 2. Development Environment and Procedures 2.1 Overview of Development Environment The following hardware and software are required for developing user programs: 2.1.1 Required Hardware ■ Personal computer Use a computer operating with Windows95/98 or WindowsNT4.0/Windows2000. ■ BHT (Bar code handy terminal) Any of the following BHTs is required: • BHT-100Q • BHT-100B ■ CU (Optical communications unit) For IrDA communication, the following CU is required.
2.1.2 Required Software • OS Windows95/98 or WindowsNT4.0/Windows2000 • Editor • BHT-BASIC 3.5 Compiler • Transfer Utility (option) BHTC35W.EXE (Integrated environment manager) BHT35CPL.DLL (Compiler) BHT35LNK.DLL (Linker) BHT35LIB.DLL (Librarian) BHTC35W.MSG (Error message file) TU3.EXE (MS-DOS–based) TU3W.EXE (16-bit Windows-based) TU3W32.EXE (Windows-based) • Ir-Transfer Utility C (option) IT3C.EXE (MS-DOS–based) IT3CW32.
Chapter 2. Development Environment and Procedures 2.2 Overview of Developing Procedures 2.2.1 Developing Procedures The program developing procedures using BHT-BASIC 3.5 are outlined below. • Making source programs Make source programs with an editor according to the syntax of BHT-BASIC. • Producing a user program (compiling and linking) Compile the source programs into object programs by BHT-BASIC Compiler.
2.2.2 Functions of BHT-BASIC 3.5 BHT-BASIC 3.5 contains Compiler, Linker, and Librarian whose functions are listed below. Functions of Compiler Description Syntax check Detects syntax errors in source programs. Output of object files Translates source programs into object files and outputs them. Output of debug information Outputs list files and debug information files required for debugging.
Chapter 2. Development Environment and Procedures 2.3 Writing a Source Program 2.3.1 Writing a Source Program by an Editor To write a source program, use an editor designed for operating environments where the BHTBASIC 3.5 Compiler will execute. The default editor is Windows Notepad. TIP To write a source program efficiently, use of a commercially available editor is recommended. For the operation of such an editor, refer to the instruction manual for the editor. 2.3.
• Comment lines starting with a single quotation mark (') and those with a REM should have the following description rules each. A single quotation mark (') can be put starting from the 1st or the following columns, or immediately following any other statement. A REM should be put starting from the 2nd column or the following columns. To put a REM following any other statement, a colon (:) should precede the REM.
Chapter 2. Development Environment and Procedures 2.4 Producing a User Program 2.4.1 Starting the BHT-BASIC 3.5 Compiler Start the Compiler, e.g., by choosing the "BHTC35W.EXE" from the Windows Explorer or the "BHT-BASIC 3.5" registered to the Start menu. Menu bar Tool bar Main window The BHT-BASIC 3.
2.4.2 Outline of User Program or Library Production Procedure Unlike the BHT-BASIC 3.0 Compiler that converts a single source program into a user program (file named XXX.PD3), the BHT-BASIC 3.5 Compiler converts source programs into object programs (files named XXX.OBJ) and then links those object programs to produce a user program (XXX.PD3). A sequence of the compiling and linking processes is called "Build." The BHT-BASIC 3.5 Compiler can also build a library (XXX.LIB).
Chapter 2. Development Environment and Procedures 2.4.3 Designating a Single Source File or a Project File 2.4.3.1 Designating a single source file Just as in the conventional BHT-BASIC 3.0 Compiler, you may designate a single source file to build a user program or library. [ 1 ] Select a source file (1) In any of the following methods, display the Open File dialog box shown below: ■ From the File menu, choose the Open command. ■ Click the open file button in the toolbar.
2.4.3.2 Designating a project file To build a library out of a single source file or to build a user program or library out of multiple source files, you need to create a project file (described in [ 1 ] later) or select an existing project file (in [ 2 ]). You may add files or delete existing files to/from the designated project file (described in [ 3 ] and [ 4 ], respectively).
Chapter 2. Development Environment and Procedures [ 2 ] Select an existing project file You may select an existing project file in the Select Project File dialog box or in the Open File dialog box. Selecting in the Select Project File dialog box (1) In any of the following methods, display the Select Project File dialog box shown below: ■ From the File menu, choose the Open Project command. ■ Click the open project button (yellow) in the toolbar. ■ While holding down the Ctrl key, press the P key.
[ 3 ] Add files to a project file You may add one or more source files and libraries to a project file at a time. (1) Create a new project (Refer to [ 1 ] in this subsection) or select an existing project file to which you want to add files (Refer to [ 2 ] in this subsection). (2) In either of the following methods, display the Add File(s) dialog box shown below: ■ From the Project menu, choose the Add File command. ■ Click the add file button in the toolbar.
Chapter 2. Development Environment and Procedures [ 4 ] Select files in the active project From files existing in the active project, you may select files that you want to compile or build. (1) In either of the following methods, display the Project Configuration Files dialog box shown below: ■ From the Project menu, choose the Select File command. ■ Click the select file button TIP (red) in the toolbar.
• Main Object display area This area shows the name of a main object in a user program if you have selected "User program (PD3)" with the "Type of File to be Created" selection button. If you have selected "Create library (LIB)," nothing will appear on this area. • Type of File to be Created Lets you select whether you create a user program (PD3) or library (LIB). • Add File button Adds the currently selected files to the active project. (Refer to “[ 3 ] Add files to a project file.
Chapter 2. Development Environment and Procedures 2.4.4 Compiling and Building First specify the options and then proceed to the compiling or building process. [ 1 ] Specifying the compiling and linking options (1) In either of the following methods, display the Set Options dialog box shown below: ■ From the Tools menu, choose the Options command. ■ Click the option button in the toolbar. (2) Select the check boxes of the options you want to specify. For details about the options, refer to Subsection 2.
[ 2 ] Compiling In any of the following methods, compile the currently selected source file(s) into an object file(s): ■ From the Build menu, choose the Compile command. ■ In the Project Configuration Files dialog box, click the Compile button. (For details about the Project Configuration Files dialog box, refer to Subsection 2.4.3.2, [ 4 ].) ■ Click the compile start button in the toolbar. ■ While holding down the Ctrl key, press the G key. If compiling ends normally, the screen shown below will appear.
Chapter 2. Development Environment and Procedures 2.4.5 Setting the Editor for Displaying Files Set the editor that you want to use for displaying source files and error message files (XXX.ERR) according to the steps below. (1) From the Tools menu, choose the Set Editor command. The Set Editor dialog box appears as shown below. (2) In the Command line edit box, type the filename of the editor.
2.4.6 Error Messages and Their Indication onto the Main Window [ 1 ] Selecting either an editor or main window as an error message output device According to the procedure below, you may select whether error messages should be outputted to an editor or main window if an error message file (XXX.ERR) is produced. (1) From the Tools menu, choose the Options command. The Set Options dialog box appears as shown below.
Chapter 2. Development Environment and Procedures [ 2 ] How error messages are displayed on the editor or main window During building, the BHT-BASIC 3.5 Compiler may detect errors which can be divided into two types: syntax errors and fatal errors. ■ Syntax errors If the Compiler detects a syntax error, it outputs the error message to the XXX.ERR file. For details about the file, refer to Subsection 2.4.9, "Output from the BHT-BASIC 3.5 Compiler.
2.4.7 Options To specify compiling options and linking options, select the check-box options you want in the Set Options dialog box. Each of available options is explained below. [ 1 ] Compiling options Compiling Options Debug information file Description Outputs debug information files (XXX.ADR, XXX.LBL, and XXX.SYM files). If this option is not selected, no debug information file will be outputted. (default) (For details, refer to [ 3 ].
Chapter 2. Development Environment and Procedures [ 2 ] Linking options Linking Options Description Outputs map information to the file XXX.MAP. Mapfile If this option is not selected, no map information will be outputted. (default) (For details, refer to [ 5 ] in this subsection.) [ 3 ] Outputting debug information files If you select the "Debug information file" check box in the Set Options dialog box and run the Compiler, then the Compiler will output three types of debug information files.
[ 4 ] Outputting list files The Compiler may output three types of list files as listed below depending upon the options specified at the start of compiling, in order to help you program and debug efficiently. List File Option Filename Extension Address-source list Symbol table Cross reference Select the Address-source List check box. Select the Symbol table check box. Select the X (Cross) reference check box. .
Chapter 2. Development Environment and Procedures • Address of object program in intermediate language Shows an intermediate language address corresponding to a source program line in four-digit hexadecimal notation. • Line number in source program Shows a line number for a source program statement in four-digit decimal notation. • Source program statement Shows the same content as a statement written in a source program.
• Symbol table for common variables Lists common variables arranged according to their types. An array variable has a suffix of parentheses ( ). • Symbol table for work variables Lists work variables and dummy arguments arranged according to their types. An array variable has a suffix of parentheses ( ). • Symbol table for register variables Lists register variables arranged according to their types. An array variable has a suffix of parentheses ( ).
Chapter 2. Development Environment and Procedures [ 5 ] Outputting a mapfile Select the Mapfile check box of the Linking Options in the Set Options dialog box and build a user program, and the mapfile as shown below will be outputted. The mapfile will be given the same name as the project file and annexed with an extension .MAP.
• Map for user-defined functions Shows the symbols of user-defined functions in the Interpreter which are arranged according to their types (i.e., integer, real, and string types). If no user-defined functions are used, this item will not be outputted. • Map for variables and object codes Shows the addresses of variables and object codes in a user program.
Chapter 2. Development Environment and Procedures 2.4.8 Starting the BHT-BASIC Compiler from the Command Line You may start the BHT-BASIC Compiler from the command line in the MS-DOS Prompt of Windows95/98 or WindowsNT4.0/Windows2000. [ 1 ] Syntax At the MS-DOS command prompt, type in the following format: BHTC35W [options] [[directorypath]filename…][options] directorypath You may specify either an absolute path or relative path.
[ 2 ] Options The BHT-BASIC 3.5 Compiler supports three types of options—compiler processing options, compiling options, and linking option. ■ Compiler processing options Processing options Description +C Compiles one or more designated file(s) into object file(s). +B programname Builds a user program with the specified program name. If no programname is specified, the filename specified first will apply. +BL libraryname Builds a library with the specified library name.
Chapter 2. Development Environment and Procedures ■ Compiling options Compiling options Description +D Outputs debug information files (XXX.ADR, XXX.LBL. and XXX.SYM files). (Same as you select the Debug information file check box in the Set Options dialog box. Refer to Subsection 2.4.7, [ 1 ].) +L Outputs an address-source list to the file XXX.LST. (Same as you select the Address-source List check box in the Set Options dialog box. Refer to Subsection 2.4.7, [ 1 ].
[ 3 ] Error Level Indication by ERRORLEVEL If you specify a +E option at the command line and run the BHT-BASIC 3.5 Compiler, the ERRORLEVEL of MS-DOS allows the Compiler to set the compiling end status to the MS-DOS environmental variable ERRORLEVEL after completion of processing, as any of the error levels listed below. By referring to this ERRORLEVEL, you can learn the compiling end status. ERRORLEVEL 0 1 2 4 5 6 7 8 9 10 20 21 30 40 70 99 Description Normal end No designated file or path found.
Chapter 2. Development Environment and Procedures 2.4.9 Output from the BHT-BASIC 3.5 Compiler The BHT-BASIC 3.5 Compiler outputs the following information as well as object programs to the destination depending upon the conditions. Output Destination Conditions Object file File XXX.OBJ (in the directory where the source program is located) When the specified source program has been normally compiled without occurrence of a compiling error. User program File YYY.
Output Destination Address–Source list Symbol table Conditions If the Address-source List check box is selected in the Set Options dialog box. File XXX.LST (in the directory where the source program is located) Cross reference If the Symbol table check box is selected in the Set Options dialog box. If the X (Cross) reference check box is selected in the Set Options dialog box. Sizes of variables File XXX.ERR (in the directory where the source program is located) or File YYY.
Chapter 2. Development Environment and Procedures 2.4.10 Structure of User Programs and Libraries If you specify a user program to be produced in the Project Configuration Files dialog box, the BHT-BASIC 3.5 Compiler produces a user program provided that no compiling error or link error occurs. The user program file will be given the same name as the project file and annexed with an extension .PD3.
2.5 Downloading 2.5.1 Overview of Transfer Utility/Ir-Transfer Utility C/ Ir-Transfer Utility E Transfer Utility/Ir-Transfer Utility C/Ir-Transfer Utility E transfers user programs and data files (e.g., master files) between the BHT and the connected personal computer.
Chapter 2. Development Environment and Procedures 2.6 Executing a User Program 2.6.1 Starting To run a user program, start System Mode and select the desired program in the Program Execution menu. If you have selected a user program as an execution program in the Setting menu of System Mode, the BHT automatically runs the user program when powered on. For the operating procedure of System Mode, refer to the BHT User’s Manual. 2.6.
Chapter 3 Program Structure CONTENTS 3.1 Program Overview ......................................................................................... 47 3.1.1 Statement Blocks ............................................................................... 47 [ 1 ] Subroutines ............................................................................... [ 2 ] Error-/Event-handling Routines ................................................. [ 3 ] User-defined Functions ........................................
Chapter 3. Program Structure 3.1 Program Overview 3.1.1 Statement Blocks A statement block is a significant set of statements (which is also called "program routine"). The following types of statement blocks are available in programming for the BHT: Statement Blocks Description Subroutine A routine called by the GOSUB statement. Error-/event-handling routine An error-/event-handling routine to which control is passed when an error trap or event (of keystroke) trap occurs, respectively.
[ 3 ] User-defined Functions Before calling user-defined functions, it is necessary to define those functions with any of the following statements. Generally, those statements should be placed before the main routine starts. DEF FN (in single-line form) DEF FN...END DEF (in block form) SUB...END SUB FUNCTION...END FUNCTION When using SUB and FUNCTION functions written in other files, it is necessary to declare them with the DECLARE statement before calling them.
Chapter 3. Program Structure 3.1.2 Notes for Jumping into/out of Statement Blocks It is not recommended to jump control from a main routine or subroutines into the midst of significant statement blocks or to jump out from the midst of those statement blocks, using the GOTO statement. Statement Blocks Jump into Jump out Subroutine ✕ ✕ Error-/event-handling routine ✕ ✕ Block-format user-defined function ✕ ✕ Block-structured statement ✕ ▲ ✕ : To be avoided. A run-time error may occur.
3.2 Handling User Programs 3.2.1 User Programs in the Memory The user area of the memory (memories) in the BHT can store more than one user program. (For details about memories, refer to Appendix F, "Memory Area.") If you have selected one of those programs as an execution program in the Setting menu of System Mode, the BHT automatically runs the user program when powered on. For the operating procedure of System Mode, refer to the BHT User’s Manual. 3.2.
Chapter 3. Program Structure 3.2.3 Included Files "Included files" are separate source programs which may be called by the INCLUDE metacommand. Upon encounter with the INCLUDE metacommand in a source program, the Compiler fetches the designated included file and then compiles the main source program while integrating that included file to generate a user program. You should specify the name of an included file by using the REM $INCLUDE or ’$INCLUDE.
Chapter 4 Basic Program Elements CONTENTS 4.1 Structure of a Program Line........................................................................... 53 4.1.1 Format of a Program Line .................................................................. [ 1 ] Labels........................................................................................ [ 2 ] Statements ................................................................................ [ 3 ] Comments ...............................................
Chapter 4. Basic Program Elements 4.1 Structure of a Program Line 4.1.1 Format of a Program Line A program line consists of the following elements: [label] [statement] [:statement] ... [comment] • label A label is placed at the beginning of a program line to identify lines. • statement A statement is a combination of functions, variables, and operators according to the syntax. A group of the statements is a program. • comment You may describe comments in order to make programs easy to understand.
[ 2 ] Statements Statements can come in two types: executable and declarative statements. • Executable statements They make the Interpreter process programs by instructing the operation to be executed. • Declarative statements They manage the memory allocation for variables and handle comments. Declarative statements available in BHT-BASIC are listed below.
Chapter 4. Basic Program Elements 4.1.2 Program Line Length A program line is terminated with a CR code by pressing the carriage return key. The allowable line length is basically 512 characters excluding a CR code placed at the end of the line. In either of the following two description ways, however, you can write a program line of up to 8192 characters: In the samples below, symbol "↓" denotes a CR code entered by the carriage return key. • Extend a program line with an underline (_) and a CR code.
4.2 Usable Characters 4.2.1 Usable Characters Listed below are characters which can be used for writing programs. Note that a double quote (") cannot be used inside a character string. Symbols | and ~ inside a character string will appear as ↓ and → on the LCD of the BHT, respectively. If used outside of a character string, symbols and control codes below have special meaning described in Subsection 4.2.2. • Alphabet letters Including both the uppercase and lowercase letters (A to Z and a to z).
Chapter 4. Basic Program Elements 4.2.
Symbols and control codes : (Colon) ; (Semicolon) [] (Square brackets) {} (Braces) # (Pound sign) Typical use • Separates statements. • Separates time information in TIME$ function. Line feed control character in INPUT and other statements. • Define the length of a string variable. • Define the string length of the returned value of a string userdefined function. Define the initial value for an array element. • File number prefix in OPEN, CLFILE, FIELD, and other statements.
Chapter 4. Basic Program Elements 4.3 Labels A label can contain the following characters: • Alphabet characters • Numeral characters • Period (.) ■ Rules for naming labels • The label length should be limited to 10 characters including periods. • A program can contain up to 9999 labels. • Label names make no distinction between uppercase and lowercase letters. The following labels, for example, will be treated as the same label.
4.4 Identifiers Identifiers for the names of variables should comprise the same alphanumerics as the labels. ■ Rules for naming identifiers • The identifier length should be limited to 10 characters including periods and excluding $ (dollar sign) and % (percent sign) suffixes. • Every type of variables can contain up to 255 identifiers. • A reserved word cannot be used by itself for an identifier name, but can be included within an identifier name.
Chapter 4. Basic Program Elements 4.5 Reserved Words "Reserved words" are keywords to be used in statements, functions, and operators. For the reserved words, refer to Appendix B, "Reserved Words." ■ Rules for using reserved words • A reserved word cannot be used by itself for a label name, a variable name, or other identifiers, but can be included within them.
Chapter 5 Data Types CONTENTS 5.1 Constants....................................................................................................... 63 5.1.1 Types of Constants ............................................................................ 63 [ 1 ] String Constants........................................................................ 63 [ 2 ] Numeric Constants.................................................................... 63 5.2 Variables................................................
Chapter 5. Data Types 5.1 Constants 5.1.1 Types of Constants A constant is a data item whose value does not change during program execution. Constants are classified into two types: string constants and numeric constants. Constant Example String constants "ABC", "123" Numeric constants Integer constants In decimal notation In hexadecimal notation Real constants 123%, -4567 &HFFF, &h1A2B 123.45, -67.
■ Real Constants Real constants should be formatted as shown below. Syntax: sign mantissa Syntax: sign mantissa E sign exponent Where a lowercase letter "e" is also allowed instead of uppercase letter "E." mantissa is a numeric string composed of a maximum of 10 significant digits. It can include a decimal point. If included in a real constant as shown below, a comma (,) for marking every three digits will cause a syntax error.
Chapter 5. Data Types 5.2 Variables A variable is a symbolic name that refers to a unit of data storage. The contents of a variable can change during program execution. 5.2.1 Types of Variables according to Format Variables are classified into two types: string variables and numeric variables, each of which is subclassified into non-array and array types.
■ Memory Occupation A string variable occupies the memory space by (the number of characters + one) bytes, where the added one byte is used for the character count. That is, it may occupy 2 to 256 bytes. If a non-array string variable consisting of 20 characters is declared, for example, it will occupy 21-byte memory space. [ 2 ] Numeric Variables • Non-array integer variables A non-array integer variable should be formatted with an identifier followed by a percentage sign (%) as shown below.
Chapter 5. Data Types 5.2.2 Classification of Variables ■ Work Variables A work variable is intended for general use. You may use it either by declaring with the DIM statement as a non-array variable or without declaration as an array variable. The following examples show work variables: DIM a(10),b%(5),c$(1) d=100:e%=45 FOR count% = s1% TO s2% NEXT count% At the start of a user program, the Interpreter initializes all of the work variables to zero (0) or a null character string.
5.3 User-defined Functions Out of user-defined functions, the SUB and FUNCTION functions can be called from other files. The DEF FN function can be called only in the file where that function is defined and should start with an FN.
Chapter 5. Data Types 5.4 Type Conversion 5.4.1 Type Conversion BHT-BASIC has the type conversion facility which automatically converts a value of one data type into another data type during value assignment to numeric variables and operations; from a real number into an integer number by rounding off, and vice versa, depending upon the conditions.
5.4.2 Type Conversion Examples The following examples show the type conversion from real to integer. ■ Assignment of Real Expressions to Integer Variables When assigning the value of the real expression (right side) to the integer variable (left side), the Interpreter carries out the type conversion. Syntax: integervariable = realexpression Example: b% = 123.45 Where b% will become 123.
Chapter 5. Data Types 5.5 Scope of Variables You may scope work variables and register variables to be local or global with the PRIVATE or GLOBAL statement, respectively. (5) Global variables A global variable can be accessed by any routine in source files to share information between those routines. Before access to it, you need to declare it with the GLOBAL statement. (6) Local variables A local variable can only be accessed by any routine in a source file where it is defined.
If used inside the SUB or FUNCTION function in the same file where the global variable is defined, the variable will also have the same value. (Example 2) The variable aa% defined by the GLOBAL statement will have the same value as aa% within the FUNCTION.
Chapter 5. Data Types 5.5.2 Local Variables A local variable can be accessed only in a file where it is defined. Write PRIVATE preceding a desired variable name or DEFREG statement. (Example) PRIVATE PRIVATE PRIVATE PRIVATE PRIVATE aaa% bbb$[10] ccc$(5,3)[30] DEFREG ddd DEFREG eee%(5) Before access to a local variable, you should define it. If used inside more than one SUB or FUNCTION function in the same file where the local variable is defined, all of those variables will also have the same value.
5.5.3 Variables Not Declared to be Global or Local If not declared to be global or local, a variable is closed in each file where it is defined. A variable used inside the FUNCTION or SUB function without declaration is available only within a function where it is defined. (Example) FUNCTION addaa(x) addaa=aa%+x END FUNCTION SUB printaa(x) print aa%+x END SUB aa%=2 print addaa(2) printaa(2) In the above example, all variables aa% used in "addaa," "printaa," and others will be treated as different ones.
Chapter 5. Data Types 5.5.4 Common Variables A common variable should be declared in a main object beforehand. To share the common variable by files other than the main object, you need to declare it with the COMMON statement in each file where the common variable should be available. File 1 File 2 DECLARE SUB printaa(x) COMMON a% a%=2 printaa(5) COMMON a% SUB printaa(x) print a%+x SUB To use a% as a common variable in Files 1 and 2, define the variable with the COMMON statement in each file.
Chapter 6 Expressions and Operators CONTENTS 6.1 Overview........................................................................................................ 77 6.2 Operator Precedence .................................................................................... 78 6.3 Operators....................................................................................................... 80 6.3.1 Arithmetic Operators .......................................................................... 6.3.
Chapter 6. Expressions and Operators 6.1 Overview An expression is defined as a combination of constants, variables, and other expressions which are connected using operators. There are two types of expressions--numeric expressions and string expressions. BHT-BASIC has the following types of operators: Operators Description Arithmetic operator Performs arithmetic operations. Relational operator Compares two values.
6.2 Operator Precedence When an expression contains more than one operator, BHT-BASIC performs the operations in the standard precedence as shown below. Precedence 1. Parentheses ( ) The parentheses allow you to override operator precedence; that is, operations enclosed with parentheses are first carried out. For improving the readability of an expression, you can use parentheses to separate two operators placed in succession. 2. Function operations 3. Arithmetic operations Operations 4.
Chapter 6. Expressions and Operators When more than one operator occurs at the same level of precedence, the BHT-BASIC resolves the expression by proceeding from left to right. a=4+5.0/20*2-1 In the above example, the operation order is as follows; 5.0/20 0.25*2 4+0.5 4.5-1 (=0.25) (=0.5) (=4.5) (=3.
6.3 Operators 6.3.1 Arithmetic Operators Arithmetic operators include a negative sign (-) and operators for multiplication (*), division (/), addition (+), and subtraction (-). They also include modulo operator MOD.
Chapter 6. Expressions and Operators 6.3.2 Relational Operators A relational operator compares two values. Depending upon whether the comparison is true or false, the operator returns true (–1) or false (0). With the operation result, you can control the program flow.
6.3.3 Logical Operators A logical operator combines multiple tests and manipulates Boolean operands, then returns the results. It is used, for example, to control the program execution flow or test the value of an INP function bitwise, as shown in the sample below. IF d<200 AND f<4 THEN ... WHILE i>10 OR k<0 ... IF NOT p THEN ... barcod% = INP(0) AND &h02 Listed below are the four types of logical operators available.
Chapter 6. Expressions and Operators [ 2 ] The AND operator The AND operator ANDs the same order bits in two expressions on either side of the operator, then sets 1 to the resultant bit if both of these bits are 1.
6.3.4 Function Operators The following two types of functions are available in BHT-BASIC, both of which work as function operators: ■ Built-in Functions Already built in BHT-BASIC, e.g., ABS and INT. ■ User-defined Functions Defined by using DEF FN (in single-line form), DEF FN...END DEF (in block form), SUB...END SUB, or FUNCTION...END FUNCTION statement. 6.3.5 String Operators A character string operator may concatenate or compare character strings.
Chapter 6. Expressions and Operators ■ Comparison of Character Strings The string operators compare two character strings according to character codes assigned to individual characters. In the example below, the expression a1$
Chapter 7 I/O Facilities CONTENTS 7.1 Output to the LCD Screen ............................................................................. 88 7.1.1 Display Fonts...................................................................................... 88 [ 1 ] Screen mode, font size, and display angle................................ 88 [ 2 ] Character attributes (Reverse font attribute, enlargement attribute, tone attribute) ............................................................. 90 7.1.
Chapter 7. I/O Facilities [ 5 ] Keystroke trapping .................................................................. 7.5.3 User-Defined Touch Keys ................................................................ [ 1 ] Creating a user-defined touch key with "CONSOLE. FN3" ..... [ 2 ] Canceling the user-defined touch key with "CONSOLE. FN3" [ 3 ] Keystroke trapping .................................................................. 7.5.4 Software Keyboard......................................................
7.1 Output to the LCD Screen 7.1.1 Display Fonts [ 1 ] Screen mode, font size, and display angle Listed below are the fonts available on each BHT series.
Chapter 7. I/O Facilities ■ Screen mode The ANK mode displays ANK characters listed in Appendices C1 and C2. The Kanji mode displays the following characters: • Half-width: Katakana and alphanumerics • Full-width: JIS Levels 1 and 2 Kanji, alphabets and symbols NOTE ■ Half-width Kanji characters differ from ANK characters in size. Font size The standard- and small-size fonts may be displayed. To display Kanji characters, it is necessary to download Kanji font files listed below.
[ 2 ] Character attributes (Reverse font attribute, enlargement attribute, tone attribute) ■ Reverse font attribute Characters may be reversed (highlighted). ■ Enlargement attribute Characters may be displayed in regular-size, double-width, double-height, and quadruple-size, as listed in [ 1 ]. ■ Tone attribute Characters may be displayed in black, dark gray, light gray, and white.
Chapter 7. I/O Facilities 7.1.2 Coordinates on the LCD To locate characters on the coordinates of the LCD screen, use the LOCATE statement. To obtain the current cursor position, use the CSRLIN and POS functions. The coordinates will differ depending upon the screen mode and font size.
Two-byte Kanji Mode • Standard-size font Be careful about the specification of line numbers in figures below. A single column shown below represents an area for a half-width character; Double columns represent an area for a full-width character.
Chapter 7. I/O Facilities • Small-size font Be careful about the specification of line numbers in figures below. A single column shown below represents an area for a half-width character; Double columns represent an area for a full-width character.
7.1.3 Dot Patterns of Fonts ■ Character fonts In the figures below, " " shows a display area for characters. Any character is displayed within a set of the display areas. " " shows a delimiter area that separates characters from each other and contains no display data. The corresponding dots are always off.
Chapter 7.
• Small-size font Half-width Kanji 6 x 12 dots (Regular) Half-width Kanji 12 x 12 dots (Double-width) Half-width Kanji 6 x 24 dots (Double-height) Half-width Kanji 12 x 24 dots (Quadruple) Full-width Kanji 12 x 12 dots (Regular) Full-width Kanji 24 x 12 dots (Double-width) Full-width Kanji 12 x 24 dots (Double-height) Full-width Kanji 24 x 24 dots (Quadruple) 96
Chapter 7. I/O Facilities ■ Cursor shape The LOCATE statement specifies the cursor shape--Underline cursor, full block cursor, or invisible. You may define and load the desired cursor shape with the APLOAD or KPLOAD statement and then specify the user-defined cursor with the LOCATE statement. If the double-width character size is specified, the cursor will be displayed in double width.
Two-byte Kanji Mode • Standard-size font ( 8 x 16 dots) In regular size Underline cursor Full block cursor Invisible Full block cursor Invisible Full block cursor Invisible Full block cursor Invisible In double-width Underline cursor In double-height Underline cursor In quadruple size Underline cursor 98
Chapter 7.
7.1.4 Mixed Display of Different Screen Modes, Font Sizes, and/or Character Enlargement Sizes [ 1 ] ANK Mode and Kanji Mode Together in One Line ANK characters and Kanji characters may display together in the same line on the LCD screen as shown below. CLS SCREEN LOCATE SCREEN LOCATE 0 1,1 : PRINT "ABCDEFGHabcdefgh" 1 1,1 : PRINT " " If the display data is outputted to the same location more than one time as shown in the above program, the BHT overwrites the old data with new data.
Chapter 7. I/O Facilities [ 3 ] Regular-Size and Double-Width Characters Together on the Same Screen The regular-size and double-width characters may display together on the same screen as shown below.
[ 5 ] Regular-Size and Quadruple-Size Characters Together on the Same Screen The regular-size and quadruple-size characters may display together on the same screen as shown below.
Chapter 7. I/O Facilities ■ Switching the character size from the regular-size to double-height or quadruple-size With the same screen font being in use, if the character size is switched from the regular-size to double-height or quadruple-size, then the cursor will not change its current position. Assuming the upper left corner of the current cursor position as an origin, the subsequent character will be displayed.
7.1.5 Displaying User-defined Characters ■ Loading a user-defined font The APLOAD or KPLOAD statement loads a user-defined font. The APLOAD statement is capable of loading up to 32 single-byte ANK fonts to be displayed in the single-byte ANK mode. The KPLOAD statement is capable of loading up to 128 two-byte Kanji fonts in full width to be displayed in the two-byte Kanji mode.
Chapter 7. I/O Facilities 7.1.6 VRAM The INP function may read the VRAM data. The OUT statement writes data into the VRAM so that graphics may be displayed on the LCD dotwise. ■ Specifying an address bytewise An address on the LCD may be specified bytewise by giving a port number in the OUT statement and INP function.
■ Setting an 8-bit binary pattern The data of an 8-bit binary pattern should be designated by bit 7 (LSB) to bit 0 (MSB) in the OUT statement or INP function. If the bit is 1, the corresponding dot on the LCD will come ON.
Chapter 7. I/O Facilities 7.1.7 Other Facilities for the LCD ■ Setting national characters Using the COUNTRY$ function displays currency symbols and special characters for countries. Refer to Appendix C2, "National Character Sets." ■ Specifying the cursor shape The LOCATE statement specifies the cursor shape.
7.2 Input from the Keyboard 7.2.1 Alphabet Entry In addition to the numeric entry from the keypad, the BHT-100 supports software keyboard entry. ■ Switching between the Numeric Entry System and Alphanumeric Entry System To switch between the numeric entry system and alphanumeric entry system, use the OUT statement in a user program as shown below. OUT &h60B0,0 OUT &h60B0,1 ’Switch to the numeric entry system* ’Switch to the alphanumeric entry system *Selected when the BHT-100 is cold-started.
Chapter 7. I/O Facilities ■ Alphabet Entry Procedure (1) Switch to the alphanumeric entry system as follows: Issue "OUT &h60B0,1". (2) Switch to the alphabet entry mode as follows: Press the SF key or issue "OUT &h60B1,1". The ALP icon appears.
When no key is ready to be established, pressing any of the function keys, BS, C, ENT, and magic keys will return the key data of the pressed key. (Example: If you press the 1, 1, 2, and 3 keys) The key data of "T" and "V" will be returned. The "Y" is not established yet. (Example: If you press the C, 1, 1, 1, and ENT keys) The 18H and "U" will be returned. 7.2.2 Other Facilities for the Keyboard [ 1 ] Auto-repeat The keys on the BHT series are not auto-repeat.
Chapter 7. I/O Facilities 7.3 Timer and Beeper 7.3.1 Timer Functions The timer functions (TIMEA, TIMEB, and TIMEC) are available in BHT-BASIC for accurate time measurement. Use these timer functions for monitoring the keyboard waiting time, communications timeout errors, etc. TIMEA = 100 WAIT 0,&H10 BEEP PRINT "10sec." ’10 sec TIMEC = 20 ’2 sec WAIT 0,&H41 BEEP PRINT "2sec. or Keyboard" 7.3.2 BEEP Statement The BEEP statement sounds a beeper and specifies the frequency of the beeper.
7.4 Controlling and Monitoring the I/Os 7.4.1 Controlling by the OUT Statement The OUT statement can control the input and output devices (I/Os) listed in Appendix D, I/O Ports." The table below lists some examples. I/O Devices OUT Statement OUT 1,&h02 OUT 1,&h01 OUT 1,&h00 Turns on the indicator LED in green. Turns on the indicator LED in red. Turns off the indicator LED. OUT 3,&hXX (XX: 00 to 07) Sets the LCD contrast. OUT 4,&h00 OUT 4,&h01 Sets the Japanese message version.
Chapter 7. I/O Facilities 7.4.3 Monitoring by the WAIT Statement The WAIT statement monitors the input and output devices (I/Os) listed in Appendix D, "I/O Ports." Unlike the INP function, the WAIT statement makes the I/O devices idle while no entry occurs, thus saving power consumption. The table below lists some examples.
7.5 Entry from the Touch Screen (Only for models equipped with a touch screen) 7.5.1 Outline The touch screen supports the following functions: (1) Function touch keys The System provides 8 function touch keys that may be used in the same way as function keys on the keyboard. (2) User-defined touch keys You may define touch keys in arbitrary areas on the touch screen. Those keys may be used in the same way as keys on the keyboard.
Chapter 7. I/O Facilities 7.5.2 Function Touch Keys Eight function touch keys are defined by the System. You may enable four or eight of those system-defined function touch keys. You may operate those keys by: - Pressing them or - Pressing them while holding down the SF key [ 1 ] Enabling or disabling the function touch keys To enable or disable the function touch keys, set the number of function touch keys to be enabled--4 or 8, in System Mode or in a user program.
[ 3 ] Assigning data to a function touch key You may assign a desired character string (up to two characters) or a single control code to a function touch key by using the KEY statement as shown below. Example for characters KEY 1,"AB" Example for a control code KEY 2,CHR$(8) ’Backspace Where a backspace code is assigned to the function touch key numbered 2. - Data is assigned to function touch keys as shown below by default.
Chapter 7. I/O Facilities [ 4 ] Displaying a character string on a function touch key You may display a desired character string on a function touch key by using the extended function "CONSOLE.FN3". In the sample below, the character string "ABC" will display on the function touch key numbered 1 in ANK standard-size font in regular character size. KEYNO% = 1 DSPDATA$ = "ABC" FONT% = .cnANK ATTRIB%=.cnW1H1 CALL "CONSOLE.FN3" .
The sample below may display only "ABC" on a function touch key. KEYNO% = 3 DSPDATA$ = "ABCDE" FONT% = .cnANK ’Standard-size font in ANK mode ATTRIB%=.cnW1H1 CALL "CONSOLE.FN3" .fcFKeyDsp KEYNO%,DSPDATA$,FONT%,ATTRIB% - If you assign a character string to the same function touch key more than one time, the last specification will take effect. [ 5 ] Keystroke trapping You may trap the pressing of a particular function touch key, by programming with the KEY ON, KEY OFF, and ON KEY...GOSUB statements.
Chapter 7. I/O Facilities 7.5.3 User-Defined Touch Keys You may define touch keys in arbitrary areas on the touch screen. You may operate those touch keys by: - Pressing them [ 1 ] Creating a user-defined touch key with "CONSOLE. FN3" To create a user-defined touch key, specify the area of a touch key and a character(s) to be displayed on the touch key, by using the extended function "CONSOLE.FN3.
- If the specified character string length exceeds the specified touch key area, the excess will be discarded. In the sample below, only "ABC" may display. DIM RECT%(3) KEYNO%=501 ’User-defined touch key numbered 501 KEYDATA$="U1" ’Key data="U1" RECT%(0)=0:RECT%(1)=0 ’Initial coordinates (0,0) RECT%(2)=40:RECT%(3)=20 ’Final coordinates (40,20) DSPDATA$="ABCDE" ’Display "ABCDE" FONT%=.cnANK ’Use standard-size font in ANK mode ATTRIB%=.cnW1H1 ’In regular size CALL "CONSOLE.FN3".
Chapter 7. I/O Facilities 7.5.4 Software Keyboard [ 1 ] Enabling/disabling software keyboard Enable the software keyboard function by using the OUT statement and then press the software keyboard display key* to show the software keyboard on the screen. On the keyboard you may press letter keys to enter ASCII characters. * The software keyboard display key is assigned to the combination of the SF and M3 keys by default.
Taking a shortcut through the above flow If you issue the OUT statement (e.g., OUT 5,3), the software keyboard will automatically appear the moment the software keyboard function becomes enabled. Software keyboard function enabled or disabled. Display the software keyboard with OUT statement (e.g., OUT 5,3). Disable the software keyboard function with OUT statement (OUT 5,0). Software keyboard displayed. (Pressing letter keys on this keyboard may enter ASCII characters.
Chapter 7. I/O Facilities [ 2 ] Displaying the software keyboard The software keyboard may display on the upper or lower area on the screen. If function touch keys are displayed, the software keyboard will appear keeping out of the function touch keys. The software keyboard may be switched between keyboards 1 and 2 shown below by pressing the FNCx key. To hide the software keyboard, press the EXIT key.
7.5.5 Getting the Touch Screen Status The system may get the current touch screen status of whether the touch screen is pressed or not and the coordinates that is pressed last. [ 1 ] Enabling the touch screen The touch screen is disabled by default. Enabling any of function touch keys, user-defined touch keys, and software keyboard will automatically enable the touch screen. To enable the touch screen without using any of them, use the OUT statement as shown below.
Chapter 8 Files CONTENTS 8.1 File Overview ............................................................................................... 125 8.1.1 Data Files and Device I/O Files........................................................ 125 8.1.2 Access Methods ............................................................................... 125 8.2 Data Files..................................................................................................... 126 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.
8.1 File Overview 8.1.1 Data Files and Device I/O Files BHT-BASIC treats not only data files but also bar code device I/Os and communications device I/Os as files, by assigning the specified names to them. File Type Data File File Name Remarks filename.extension drivename:filename.extension Device I/O File BAR: Bar code device Device I/O File COM: Communications device TIP Data files and user program files are stored in the user area of the memory. 8.1.
Chapter 8. Files 8.2 Data Files 8.2.1 Overview Like user programs, data files will be stored in the user area of the memory. The location of the user area differs depending upon the BHT series as shown below. BHT series Location of user area BHT-100 Drive A and drive B* * Drive B is provided for ensuring the compatibility with conventional BHT series. The memory space available for data files is (Memory space on drive A - Memory space occupied by user programs).
8.2.3 Structure of Data Files ■ Record A data file is made up of a maximum of 32767 records. A record is a set of data in a data file and its format is defined by the FIELD statement. The maximum length of a record is 255 bytes including the number of the character count bytes* (= the number of the fields). * When transferring data files, the BHT-protocol/BHT-Ir protocol automatically prefixes a character count byte in binary format to each data field. ■ Field A record is made up of 1 to 16 fields.
Chapter 8. Files 8.2.4 Data File Management by Directory Information The Interpreter manages data files using the directory information stored in the system area of the memory. The directory information, for example, contains the following: filename.extension Information of Each Field (Field length) Number of Written Records Maximum Number of Registrable Records • Number of Written Records Means the number of records already written in a data file, which the LOF function can return.
8.2.5 Programming for Data Files ■ Input/Output for Numeric Data - To write numeric data into a data file: It is necessary to use the STR$ function for converting the value of a numeric expression into a string. To write -12.56 into a data file, for example, the field length of at least 6 bytes is required. When using the FIELD statement, designate the sufficient field length; otherwise, the data will be lost from the lowest digit when written to the field.
Chapter 8. Files ■ Restrictions on Input/Output of Data Files No INPUT#, LINE INPUT#, or PRINT# statement or INPUT$ function can access data files. To access data files, use a PUT or GET statement. ■ Drive Defragmentation During downloading, a delay of a few seconds (response delay from the BHT) may occur according to the user area condition. To eliminate the delay, defragment the drive for the size required for downloading beforehand. Doing so will also reduce the device open time in communications.
8.2.6 About Drives The BHT-100 has logical drives. Drive B is provided for ensuring compatibility with other BHT series. If you specify drive name "B:" preceding a filename.extension and open an existing file, then the BHT will open the file as a read-only file. Executing the PUT statement to the read-only file will result in a run-time error (43h). If you specify drive name "A:" or omit a drive name, the BHT will open the file as a read/write file.
Chapter 8. Files 8.3 Bar Code Device 8.3.1 Overview ■ Opening the Bar Code Device by OPEN "BAR:" Statement BHT-100Q The OPEN "BAR:" statement opens the bar code device. In this statement, you may specify the following code types available in the BHT. The BHT can handle one of them or their combination. Available Code Types Default Settings 2D codes QR Code All of Model 1, Model 2, and MicroQR supported. No code version specified. No split code scanning mode. PDF417 No option required.
BHT-100B The OPEN "BAR:" statement opens the bar code device. In this statement, you may specify the following bar code types available in the BHT. The BHT can handle one of them or their combination. Available Bar Code Types Universal product codes Default Settings EAN-13*1 EAN-8 UPC-A*1 UPC-E No national flag specified. Interleaved 2of5 (ITF) No length of read data specified. No check digit. Standard 2of5 (STF) No length of read data specified. No check digit.
Chapter 8. Files ■ Specifying Options in the OPEN "BAR:" Statement BHT-100Q You may also specify several options as listed below for each of the code types in the OPEN "BAR:" statement.
You can check whether the barcode buffer stores code data, by using any of the EOF, INP, and LOC functions, and the WAIT statement. Any of the INPUT# and LINE INPUT# statements, and the INPUT$ function reads bar code data stored in the buffer into a string variable.
Chapter 8. Files 8.3.2 Programming for Bar Code Device ■ Code Mark The MARK$ function allows you to check the code mark (denoting the code type) and the length of the inputted bar code data. This function returns a total of three bytes: one byte for the code mark and two bytes for the data length. BHT-100Q If the data length of a read 2D code exceeds 99 digits, the two bytes of the returned value for the data length will indicate 00.
■ Read Mode of the Trigger Switch The trigger switch function is assigned to the magic keys M3 and M4 by default. You may assign the trigger switch function to other keys by using the KEY statement. You may select the read mode of the trigger switch by using the OPEN "BAR:" statement as listed below. Read Mode OPEN "BAR:" Statement Auto-off Mode (Default) OPEN "BAR:F"... Momentary Switching Mode OPEN "BAR:M"... Alternate Switching Mode OPEN "BAR:A"... Continuous Reading Mode OPEN "BAR:C"...
Chapter 8. Files This way, you can control the indicator LED, enabling that: • a user program can check the value of a scanned bar code and turn on the green LED when the bar code has been read successfully. (For example, you can make the user program interpret bar code data valued from 0 to 100 as correct data.) • a user program can turn on the red LED the moment the bar code has been read.
■ Reading Split QR Codes (for the BHT-100Q) The "QR Code" system supports a split QR code feature ("Structured Append") which can divide data into a maximum of 16 blocks and encode each of them into a split QR code. When those split codes are scanned, the system restores them into the original data string. For reading split QR codes, you may choose either the edit mode or non-edit mode, by using the OPEN "BAR:" statement as shown below.
Chapter 8. Files 8.4 Communications Device 8.4.1 Hardware Required for Data Communications The following hardware is required for communications between the BHT and the host computer: • Optical communications unit (CU) and its interface cable or • Direct-connect interface cable For the communications specifications, refer to the BHT User's Manual. Using Ir-Transfer Utility E allows the BHT to directly communicate with the IR port-integrated host computer or an external IR transceiver.
8.4.3 Overview of Communications Protocols The BHT supports two communications protocols—BHT-protocol and BHT-Ir protocol for file transmission. Using the XFILE statement, the BHT may upload or download a file according to either of these protocols. [ 1 ] BHT-protocol This protocol may be used also in System Mode. For the communications specifications of the BHT-protocol, refer to the BHT User's Manual.
Chapter 8. Files [ 2 ] BHT-Ir protocol In addition to the BHT-protocol, the BHT supports the BHT-Ir protocol. If you select the BHT-Ir protocol by using the OUT statement (Port &h6060) or in System Mode, you can upload or download a data file with the XFILE statement. The BHT-Ir protocol may be used also in System Mode. For the communications specifications of the BHT-Ir protocol, refer to the BHT User’s Manual.
8.4.4 File Transfer Tools [ 1 ] Transfer Utility Transfer Utility is optionally available in two versions: MS-DOS–based and Windows-based. It supports the BHT-protocol and allows you to upload or download user program files and data files between the host and the BHT, when invoked by the XFILE statement. This utility can also transfer user program files and data files to/from System Mode.
Chapter 9 Event Polling and Error/Event Trapping CONTENTS 9.1 Overview...................................................................................................... 146 9.2 Event Polling................................................................................................ 147 [ 1 ] Programming sample .............................................................. 147 [ 2 ] I/O devices capable of being monitored by the event polling ........................................................
9.1 Overview BHT-BASIC supports event polling and two types of trapping: error trapping and event trapping. – Event polling – Trapping Error trapping Event (of keystroke) trapping ■ Event Polling Makes programs monitor the input devices for occurrence of events. ■ Error Trapping Traps a run-time error and handles it by interrupt to transfer control to the error-handling routine.
Chapter 9. Event Polling and Error/Event Trapping 9.2 Event Polling [ 1 ] Programming sample The program below shows the event polling example which monitors the bar code reader and the keyboard for occurrence of events. This example uses the EOF and INKEY$ functions to check the data input for the bar code reader and the keyboard, respectively.
[ 2 ] I/O devices capable of being monitored by the event polling Listed below are the I/O devices which the event polling can monitor.
Chapter 9. Event Polling and Error/Event Trapping 9.3 Error Trapping [ 1 ] Overview If a run-time error occurs during program running, error trapping makes the program cause an interrupt upon completion of the machine instruction so as to transfer control from the current program to the error-handling routine which has been specified by a label.
[ 2 ] Programming for trapping errors To trap errors, use the ON ERROR GOTO statement in which you should designate the errorhandling routine (to which control is to be transferred if a run-time error occurs) by the label. ON ERROR GOTO err01 . . . (Main routine) . . .
Chapter 9. Event Polling and Error/Event Trapping 9.4 Event (of Keystroke) Trapping [ 1 ] Overview If any of the function keys previously specified for keystroke trapping is pressed, event trapping makes the program cause an interrupt so as to transfer control from the current program to the specified event-handling routine. This trapping facility checks whether any of the function keys is pressed or not between every execution of the statements.
If function keys specified for keystroke trapping are pressed during execution of the following statements or functions relating keyboard input, this trapping facility operates as described below. Statements or Functions Keystroke Trapping INPUT statement Ignores the entry of the pressed key and causes no interrupt. LINE INPUT statement Same as above. INPUT$ function Same as above. INKEY$ function Ignores the entry of the pressed key, but causes an interrupt.
Chapter 10 Sleep Function CONTENTS 10.1 Sleep Function.............................................................................................
10.1 Sleep Function The BHT supports the sleep function that automatically interrupts program execution if no event takes place within the specified length of time in the BHT, thereby minimizing its power consumption. Upon detection of any event, the BHT in the sleep state immediately starts the interrupted user program. By using the OUT statement, you may set the desired length of time to the sleep timer within the range from 0 to 25.5 seconds in increment of 100 ms. The default is 1 second.
Chapter 11 Resume Function CONTENTS 11.1 Resume Function.........................................................................................
11.1 Resume Function The resume function automatically preserves the current status of a running application program (user program) when the BHT is turned off, and then resumes it when the BHT is turned on. That is, even if you unintentionally turn off the BHT or the automatic powering-off function turns off the BHT, turning on the BHT once again resumes the previous status of the program to allow you to continue the program execution.
Chapter 12 Power-related Functions CONTENTS 12.1 Low Battery Warning ................................................................................... 158 12.2 Prohibited Simultaneous Operation of the Beeper and Illumination LED .... 158 12.3 Wakeup Function......................................................................................... 159 12.4 Remote Wakeup Function ........................................................................... [ 1 ] Outline ........................................
12.1 Low Battery Warning If the output voltage of the battery cartridge drops below a specified lower level limit when the BHT is in operation, then the BHT displays the Level-1 message "Battery voltage has lowered." on the LCD and beeps three times. After that, it will resume previous regular operation.
Chapter 12. Power-related Functions 12.3 Wakeup Function The wakeup function allows you to turn the BHT on at the wakeup time (of the system clock) specified in user programs. To set the wakeup time, use the TIME$ function as follows: (1) Set 1 to bit 2 on port 8. Switches the TIME$ function to the setting of the wakeup time. (2) Set the wakeup time by using the TIME$ function. (3) Set 1 to bit 0 on port 8. Activates the wakeup function.
12.4 Remote Wakeup Function [ 1 ] Outline The remote wakeup function allows you to turn the BHT on and run the specified user program (hereafter referred to "remote wakeup program") from a remote location by sending the specified message from the host computer to the BHT via the CU. Developing user programs utilizing the remote wakeup at both the host computer and BHT enables you to automatically maintain the master system or update user programs.
Chapter 12. Power-related Functions At the BHT (1) Turn the BHT off and put it on the CU. The BHT will enter into the charge state* (i.e., into sleep). (For details about charging, refer to the BHT User’s Manual.) *Charge state: Charging or charged-up state (2) Upon receipt of any data via the IR port, the BHT wakes up. After the specified time length (approx. 10 ms), the BHT becomes ready to receive data. If no data comes in within the specified timeout period*1, then the BHT will go back to step (1).
[ 3 ] Remote wakeup program ■ File name The BHT may handle the file named "BHTRMT.PD3" as a remote wakeup program. Upon receipt of data containing a “WAKE” character string, the BHT checks whether the BHTRMT.PD3 file exists. If the file exists, the BHT will start the remote wakeup operation described in [ 2 ].
Chapter 12. Power-related Functions Once made in a user program, the above settings will be retained even after the termination of the user program. The remote wakeup activation/deactivation and the transmission speed for remote wakeup may be set in System Mode. For details, refer to the BHT User’s Manual.
■ Checking the execution record of remote wakeup When starting, a user program (including a remote wakeup program) may check via the I/O ports whether the BHT remotely woke up at the last powering on and its operation was normally ended. (Refer to Appendix D, "I/O Ports.”) Making use of the execution record, you may display an alarm message. Port No. Bit 0 Bit 1 Specifications 60F2h 0 0 0 1 At the last powering on, the BHT did not remotely wake up.
Chapter 13 Backlight Function CONTENTS 13.1 Backlight Function .......................................................................................
13.1 Backlight Function The BHT has a backlight function (LCD backlight and key backlight). Pressing the right-hand trigger switch (M4 key) while holding down the Shift key activates or deactivates the backlight function. The default length of backlight ON-time (ON-duration) is 3 seconds. By using an OUT statement, you can enable/disable either or both the LCD backlight and key backlight. (Refer to Appendix D, "I/O Ports.
Chapter 13. Backlight Function Setting 0 to port 6020h deactivates the backlight function and turns off the backlight if lit. When the backlight function is activated with the OUT statement, the backlight function on/off key and ON-duration specified by the KEY statement will be ignored. The backlight function is deactivated when the BHT is turned on. Backlight OFF With the OUT statement, set 1 to port 6020h. Backlight ON With the OUT statement, set 0 to port 6020h.
Chapter 14 Statement Reference CONTENTS APLOAD .............................................. 169 BEEP ................................................... 174 CALL ................................................... 177 CHAIN ................................................. 181 CLFILE ................................................ 183 CLOSE ................................................ 185 CLS ..................................................... 186 COMMON ...........................................
ANK Pattern LOAD I/O statement APLOAD Loads a user-defined font in the single-byte ANK* mode *ANK: Alphanumeric and Katakana Syntax: Syntax 1 (Loading a user-defined font): APLOAD characode,fontarrayname Syntax 2 (Loading a user-defined cursor.): APLOAD characode,cursorarrayname Parameter: characode • For user-defined font A numeric expression which returns a value from 128 (80h) to 159 (9Fh). • For user-defined cursor A numeric expression which returns a value 0.
Chapter 14. Statement Reference • If you issue more than one APLOAD statement specifying a same character code, the last statement takes effect. • Only when the Interpreter executes the APLOAD statement, it refers to the array data defined by fontarrayname. So, once a user program has finished loading the user font, changing the data in the array or deleting the array itself (by the ERASE statement) will not affect the already loaded user font.
• The cursor size will be as shown below. Display font Size (W x H) No. of elements Standard-size 12 x 12 dots 12 0 1 2 3 4 5 6 7 8 9 10 11 LSB MSB • An array integer variable--a work array, register array, or common array--for cursorarrayname should be declared by the DIM, DEFREG, or COMMON statement, respectively. DIM cp0%(11) DEFREG cp1%(11) COMMON cp2%(11) The array variable should be one-dimensional and have at least 12 elements.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 71: Syntax error • No fontarrayname or cursorarrayname is defined. • fontarrayname or cursorarrayname has an array string variable. • fontarrayname or cursorarrayname includes parentheses ( ). • fontarrayname or cursorarrayname includes subscripts. Run-time errors: Error code Meaning 05h Parameter out of the range (• characode is out of the specified range.) (• The array structure is not correct.
Array Elements Bit in each cp%(0) cp%(1) cp%(2) cp%(3) cp%(4) cp%(5) cp%(6) cp%(7) cp%(8) cp%(9) cp%(10)cp%(11) array element 0 (LSB) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (MSB) Reference: Statements: COMMON, DEFREG, DIM, KPLOAD, PRINT, and SCREEN 173
Chapter 14. Statement Reference I/O statement BEEP Drives the beeper or vibrator. Syntax: BEEP[onduration[,offduration[,repetitioncount [,frequency]]]] Parameter: onduration, offduration, and repetitioncount Numeric expressions, each of which returns a value from 0 to 255. frequency A numeric expression which returns a value from 0 to 32767.
You may change the beeper volume with the OUT statement. (For details, refer to Appendix D, "I/O Ports.") If you set a value other than 0, 1, and 2 to frequency, the beeper volume is automatically set to the maximum and not adjustable. • Specification of any of 3 through 39 to frequency deactivates the beeper or vibrator. • Specification of zero to onduration deactivates the beeper. • Specification of a value except for zero to onduration and specification of zero to offduration keep beeping.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 71: Syntax error The number of parameters or commas (,) exceeds the limit.
Flow control statement CALL Calls an FN3 or SUB function. Syntax: Syntax 1 (Calling an FN3): CALL "[drivename:]filename" functionnumber [data [,data]...] Syntax 2 (Calling a SUB): CALL functionname [(realparameter[,realparameter…])] Parameter: [drivename:]filename A string expression. functionnumber An integer constant. data A string variable or a numeric variable. functionname Real function name. realparameter A numeric expression or a string expression.
Chapter 14. Statement Reference • filename is the name of an FN3 function. The extension of the file names is fixed to .FN3. (For the FN3 functions, refer to Chapter 16, "Extended Functions" or the "BHT-BASIC Extension Library Manual.") • functionnumber is the function number of an FN3 specified by filename. • data is a variable for the function number of the FN3 (that is, it is used as an argument to the FN3 function).
■ Calling a user-defined function (SUB function) This statement calls a user-defined function specified by functionname. You may omit CALL when calling a SUB function. • functionname should be a user-defined function defined by SUB...END SUB statement. • The number of realparameters should be equal to that of dummyparameters, and the types of the corresponding variables used in those parameters should be identical.
Chapter 14. Statement Reference Run-time errors: Error code Meaning 02h Syntax error ("[drivename:]filename" is in incorrect syntax or the extension is not .FN3.) 05h Parameter value out of range (In calling an FN3 function, the number of parameters exceeds 16.) 07h Insufficient memory space (You nested calling statements of a user-defined function to more than 10 levels.
Flow control statement CHAIN Transfers control to another program. Syntax: CHAIN "[drivename:]programfilename" Parameter: "[drivename:]programfilename" A string expression. Description: CHAIN transfers control to a program specified by "[drivename:]programfilename". That is, it terminates the current running program (1st program) and closes all of the files being opened.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 3: ’"’ missing No double quote precedes or follows [drivename:]programfilename. error 71: Syntax error [drivename:]programfilename is not enclosed in double quotes. Run-time errors: Error code Meaning 02h Syntax error ("[drivename:]programfilename" is in incorrect syntax or the extension is not .PD3.) 07h Insufficient memory space (The 1st program uses too many variables.
CLear FILE File I/O statement CLFILE Erases the data stored in a data file. Syntax: CLFILE [#]filenumber Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: CLFILE erases data in the data file specified by filenumber and resets the number of written records in the directory to zero. • The memory area freed by CLFILE can be used for other data files or user program files. • User programs can no longer refer to the erased data.
Chapter 14. Statement Reference Example: OPEN "master.
File I/O statement CLOSE Closes file(s). Syntax: CLOSE [[#]filenumber[,[#]filenumber...]] Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: CLOSE closes file(s) specified by filenumber(s). • The file number(s) closed by the CLOSE statement becomes available for a subsequent OPEN statement. • If no file number is specified, the CLOSE statement closes all of the opened data files and device I/O files.
Chapter 14. Statement Reference Clear Screen I/O statement CLS Clears the LCD screen. Syntax: CLS Description: CLS clears the liquid crystal display (LCD) screen and returns the cursor to the upper left corner of the screen. • The CLS statement does not affect settings made by displaymode or charaattribute in the SCREEN statement. (For details about displaymode and charaattribute, refer to the SCREEN statement.) • This statement turns off the cursor.
Declarative statement COMMON Declares common variables for sharing between user programs. Syntax: COMMON commonvariable[,commonvariable...] Parameter: commonvariable A non-array integer variable, a non-array real variable, a non-array string variable, an array integer variable, an array real variable, or an array string variable. Description: COMMON defines common variables for sharing them when one program chains to another.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 5: Variable name redefinition A same variable name is double declared in a program. error 73: Improper string length The length of a string variable is out of the range from 1 to 255. Run-time errors: Error code Meaning 07h Insufficient memory space (The COMMON statement defines too much data.
Declarative statement CONST Defines symbolic constants to be replaced with labels. Syntax: CONST constname = expr Parameter: constname A label, identifier, or string expression of a maximum of 10 characters consisting of alphanumerics and period (.). expr A string constant Description: CONST replaces a label, identifier or a character string specified by constname with a string constant defined by expr before compiling. • expr may contain labels defined by other CONST declarations.
Chapter 14. Statement Reference I/O statement CURSOR Turns the cursor on or off. Syntax: CURSOR {ON|OFF} Description: When a user program is initiated, the cursor is set to OFF. CURSOR ON turns on the cursor for keyboard entry operation by the INKEY$ function. CURSOR OFF turns off the cursor.
Declarative statement DATA Stores numeric and string literals for READ statements. Syntax: DATA literal[,literal...] Parameter: literal A numeric or string constant. Description: DATA stores numeric and string literals so that READ statements can assign them to variables. • A DATA statement can appear anywhere in a source program. • A string data should be enclosed with a pair of double quotation marks ("). • You may have any number of DATA statements in a program.
Chapter 14. Statement Reference User-defined function declarative statement DECLARE Declares user-defined function FUNCTION or SUB externally defined. Syntax: Syntax 1 (Defining a numeric FUNCTION): DECLARE FUNCTION funcname [(dummyparameter[,dummyparameter...])] Syntax 2 (Defining a string FUNCTION): DECLARE FUNCTION funcname [(dummyparameter [,dummyparameter...])][[stringlength]] Syntax 3 (Defining a SUB): DECLARE SUB subname[(dummyparameter [,dummyparameter...
Description: DECLARE defines a user-defined function defined in other source program files. • Declaration of a user-defined function should appear preceding a calling statement of the user-defined function in your source program. • funcname, subname, and dummyparameter should be declared in the same way as the function names and real parameters defined in the original functions (defined in other source program files). • You cannot make double definition to a same function name.
Chapter 14. Statement Reference DEFine FuNction User-defined function definition statement DEF FN (Single-line form) Names and defines a user-defined function. Syntax: Syntax 1 (Defining a numeric function): DEF FNfunctionname[(dummyparameter[,dummyparameter ...])]=expression Syntax 2 (Defining a string function): DEF FNfunctionname[(dummyparameter [,dummyparameter...])] [[stringlength]]=expression Syntax 3 (Calling the function): FNfunctionname[(realparameter[,realparameter ...
Description: ■ Creating a user-defined function DEF FN creates a user-defined function. • Definition of a user-defined function should appear preceding a calling statement of the user-defined function in a source program. • You cannot make double definition to a same function name. • The DEF FN statement should not be defined in the block-structured statements (DEF FN...END DEF, FOR...NEXT, FUNCTION...END FUNCTION, IF...THEN ...ELSE...END IF, SELECT...CASE...END SELECT, SUB...END SUB and WHILE...
Chapter 14. Statement Reference Syntax errors: ■ When defining a user-defined function Error code and message Meaning error 61: Cannot use DEF FN in control structure The DEF FN statement is defined in block-structured statements such as FOR and IF statements. error 64: Function redefinition You made double definition to a same function name.
Run-time errors: Error code Meaning 07h Insufficient memory space (You nested DEF FN statements to more than 10 levels.) 0Fh String length out of the range (The returned value of the stringlength exceeds the allowable range.
Chapter 14. Statement Reference DEFine FuNction...END DEFine User-defined function definition statement DEF FN...END DEF (Block form) Names and defines a user-defined function. Syntax: Syntax 1 (Defining a numeric function): DEF FNfunctionname[(dummyparameter[,dummyparameter ...])] Syntax 2 (Defining a string function): DEF FNfunctionname[(dummyparameter [,dummyparameter...
Description: ■ Creating a user-defined function DEF FN...END DEF creates a user-defined function. The function definition block between DEF FN and END DEF is a set of some statements and functions. • Definition of a user-defined function should appear preceding a calling statement of the user-defined function in a source program. • You cannot make double definition to a same function name. • This statement block should not be defined in the block-structured statements (DEF FN...END DEF, FOR...
Chapter 14. Statement Reference ■ Calling a user-defined function FNfunctionname calls a user-defined function. • The number of realparameters should be equal to that of dummyparameters, and the types of the corresponding variables used in those parameters should be identical. • If you specify a global variable in realparameter when calling a user-defined function, the user-defined function cannot update the value of the global variable.
■ When calling a user-defined function Error code and message Meaning error 68: Mismatch argument type or number • The number of the real parameters is not equal to that of the dummy parameters. • dummyparameter was an integer variable in defining a function, but realparameter is a real type in calling the function. (If dummyparameter was a real variable in defining a function and realparameter is an integer type, then no error occurs.
Chapter 14. Statement Reference DEFine REGister Declarative statement DEFREG Defines register variables. Syntax: DEFREG registerdefinition[,registerdefinition ...] Parameter: registerdefinition non-arraynumericvariable [=numericconstant] DEFREG n1%=10 DEFREG n2=12.
numericinitialvaluedefinition For one-dimensional: {numericconstant[,numericconstant...]} DEFREG n6%(3)={9,8,7,6} For two-dimensional: {{numericconstant[,numericconstant...]}, {numericconstant[,numericconstant...]} ...} DEFREG n7(1,2)={{10,11,12},{13,14,15}} stringinitialvaluedefinition For one-dimensional: {stringconstant[,stringconstant...]} DEFREG s3$(3)={"a","bc","123","45"} For two-dimensional: {{stringconstant[,stringconstant...]}, constant[,stringconstant...]} ...
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 6: Variable name redefinition A same register variable name is double declared in a program. error 71: Syntax error • stringlength is not an integer constant. • The number of the specified initial values is greater than that of the array elements. • The list of initial values is terminated with a comma. • The type of the specified variable does not match that of its initial value.
Example: Example 1: Valid DEFREG statements DEFREG DEFREG DEFREG DEFREG DEFREG DEFREG DEFREG DEFREG DEFREG a,e$ b=100,c(10),d$(2,4)[10] bps$="19200" a%(2)={1,2} a%(2)={1,,3} a%(2)={,,3} b%(1,1)={{},{1,2}} b%(1,1)={,{1,2}} b%(1,1)={{1,2}} Example 2: Position of elements in an array DEFREG a%(1,1)={{1},{,3}} The elements of the above array have the following initial values: a%(0,0):1 a%(0,1):0 a%(1,0):0 a%(1,1):3 DEFREG b$(1,1)[3]={,{"123"}} The elements of the above array have the following initial valu
Chapter 14. Statement Reference DIMension Memory control statement DIM Declares and dimensions arrays; also declares the string length for a string variable. Syntax: DIM arraydeclaration[,arraydeclaration...
• In declaring an array string variable, you can specify the string length. If its specification is omitted, the default value of 20 characters takes effect. • If no subscript is specified for a string variable, the Compiler automatically regards the string variable as a non-array string variable so that the default for a non-array string variable, 40 characters, takes effect.
Chapter 14. Statement Reference Flow control statement END Terminates program execution. Syntax: END Description: END terminates program execution and sounds the beeper for a second. • An END can appear anywhere in a source program.
Memory control statement ERASE Erases array variables. Syntax: ERASE arrayvariablename[,arrayvariablename...] Parameter: arrayvariablename An array numeric or array string variable. Description: ERASE erases an array variable(s) specified by arrayvariablename and frees the memory used by the array. • arrayvariablename is the name of an array variable already declared by the DIM statement. If it has not been declared by DIM, the ERASE statement will be ignored.
Chapter 14. Statement Reference File I/O statement FIELD Allocates string variables as field variables. Syntax: FIELD [#]filenumber,fieldwidth AS fieldvariable [,fieldwidth AS fieldvariable...] Parameter: filenumber A numeric expression which returns a value from 1 to 16. fieldwidth A numeric expression which returns a value from 1 to 254. fieldvariable A non-array string variable. Description: FIELD declares the length and field variable of each field of a record in a data file.
Syntax errors: Error code and message Meaning error 71: Syntax error filenumber is missing. Run-time errors: Error code Meaning 05h Parameter out of the range (fieldwidth out of the range) 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than data files.) 3Ah File number out of the range 3Ch FIELD overflow (A FIELD statement specifies the record length exceeding 255 bytes.
Chapter 14. Statement Reference Flow control statement FOR...NEXT Defines a loop containing statements to be executed a specified number of times. Syntax: FOR controlvariable = initialvalue TO finalvalue [STEP increment] . . . NEXT [controlvariable] Parameter: controlvariable A non-array numeric variable. initialvalue, finalvalue, and increment Numeric expressions.
• The default value of increment is 1. • You can nest FOR...NEXT statements to a maximum of 10 levels. • When using the FOR...NEXT statement together with block-structured statements (DEF FN...END DEF, FOR...NEXT, FUNCTION...END FUNCTION, IF...THEN ...ELSE...END IF, SELECT...CASE...END SELECT, SUB...END SUB and WHILE...WEND), you can nest them to a maximum of 30 levels. • A same controlvariable should not be reused in a nested loop.
Chapter 14. Statement Reference User-defined function statement FUNCTION…END FUNCTION Names and creates user-defined function FUNCTION. Syntax: Syntax 1 (Defining a numeric function): FUNCTION funcname [(dummyparameter [,dummyparameter...])] Syntax 2 (Defining a string function): FUNCTION funcname [(dummyparameter [,dummyparameter...
Description: ■ Creating a user-defined function FUNCTION...END FUNCTION creates a user-defined function. The function definition block between FUNCTION and END FUNCTION is a set of some statements and functions. • You cannot make double definition to a same function name. • This statement block should not be defined in the block-structured statements (DEF FN...END DEF, FOR...NEXT, FUNCTION...END FUNCTION, IF...THEN ...ELSE...END IF, SELECT...CASE...END SELECT, SUB...END SUB and WHILE...
Chapter 14. Statement Reference • If you specify a global variable in realparameter when calling a user-defined function, the user-defined function cannot update the value of the global variable. This is because all realparameters are passed not by address but by value. (So called "Call-by-value") NOTE Before any call to a FUNCTION...END FUNCTION, you need to place definition of the FUNCTION function or declaration of the FUNCTION by the DECLARE statement in your source program.
Error code and message Meaning error 96: Incomplete control structure (FUNCTION...END FUNCTION) END FUNCTION is missing. error 97: Cannot use FUNCTION in control structure The FUNCTION…END FUNCTION statement is defined in other blockstructured statements such as FOR and IF statement blocks. ■ When calling a user-defined function Error code and message Meaning error 68: Mismatch argument type or number • The number of the real parameters is not equal to that of the dummy parameters.
Chapter 14. Statement Reference Example: File 1 File 2 DECLARE FUNCTION add(x,y) A=1:B=2 PRINT "TEST" C=add(A,B) PRINT C . . .
File I/O statement GET Reads a record from a data file. Syntax: GET [#]filenumber[,recordnumber] Parameter: filenumber A numeric expression which returns a value from 1 to 16. recordnumber A numeric expression which returns a value from 1 to 32767. Description: GET reads the record specified by recordnumber from the data file specified by filenumber and assigns the data to the field variable(s) specified by the FIELD statement.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 71: Syntax error filenumber is missing. Run-time errors: Error code Meaning 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than data files.) 3Ah File number out of the range 3Eh A PUT or GET statement executed without a FIELD statement. 3Fh Bad record number (No record to be read in a data file.
Declarative statement GLOBAL Declares one or more work variables or register variables defined in a file, to be global. Syntax: GLOBAL varname [,varname...] Parameter: varname numericvar [(subscript)] stringvar [(subscript)[[stringlength]]] subscript For one-dimensional: integerconstant For two-dimensional: integerconstant, integerconstant Where integerconstant is a numeric expression which returns a value from 0 to 254.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 7: Variable name redefinition The variable declared with GLOBAL statement had been already declared with DEFREG statement. error 71: Syntax error • stringlength range. is out of the • stringlength is not an integer constant. error 72: Variable name redefinition • A same variable name is double declared inside a same GLOBAL statement. • A same variable name is used for a non-array variable and array variable.
Flow control statement GOSUB Branches to a subroutine. Syntax: GOSUB label Description: GOSUB calls a subroutine specified by label. • Within the subroutine itself, you use a RETURN statement which indicates the logical end of the subroutine and returns control to the statement just after the GOSUB that called the subroutine. • You may call a subroutine any number of times as long as the Interpreter allows the nest level and other conditions. • Subroutines can appear anywhere in a source program.
Chapter 14.
Flow control statement GOTO Branches to a specified label. Syntax: GOTO label Description: GOTO unconditionally transfers control to a label specified by label. • In an IF statement block, you can omit GOTO immediately following THEN or ELSE, as shown below. IF a=0 THEN Lbl1 ELSE Lbl2 END IF • GOTO allows you to branch anywhere in your program. However, you should branch only to another line in a program module or subroutine at the same program level.
Chapter 14. Statement Reference Flow control statement IF...THEN...ELSE...END IF Conditionally executes specified statement blocks depending upon the evaluation of a conditional expression. Syntax: Syntax 1: IF conditionalexpression THEN statementblock1 [ELSE statementblock2] END IF Syntax 2: IF conditionalexpression ELSE statementblock END IF Parameter: conditionalexpression A numeric expression which evaluates to true or false.
• A block-structured IF statement block has the following advantages over a single-line IF statement (which is not supported in BHT-BASIC): - More complex conditions can be tested since an IF statement block can contain more than one line for describing conditions. - You can describe as many statements or statement blocks as you want.
Chapter 14. Statement Reference I/O statement INPUT Reads input from the keyboard into a variable. Syntax: INPUT [;]["prompt"{,|;}]variable Parameter: "prompt" A string constant. variable A numeric or string variable. Description: When execution reaches an INPUT statement, the program pauses and waits for the user to enter data from the keyboard while showing a prompting message specified by "prompt". After typing data, the user must press the ENT key.
• The cursor shape specified by the most recently executed LOCATE statement takes effect. • Even after execution of the CURSOR OFF statement, the INPUT statement displays the cursor. • Data inputted by the user will echo back to the LCD. To assign it to variable, it is necessary to press the ENT key. Pressing the ENT key causes also a line feed. If INPUT is followed by a semicolon (;) in an INPUT statement, however, line feed is suppressed.
Chapter 14. Statement Reference Run-time errors: Error code Meaning 06h The operation result is out of the allowable range. (Numeric variable is out of the range.
File I/O statement INPUT # Reads data from a device I/O file into specified variables. Syntax: INPUT #filenumber,variable[,variable...] Parameter: filenumber A numeric expression which returns a value from 1 to 16. variable A numeric or string variable. Description: INPUT # reads data from a device I/O file (a communications device file or bar code device file) specified by filenumber and assigns it to variable. • filenumber is a number assigned to the device I/O file when it was opened.
Chapter 14. Statement Reference • Notes for entering numeric data: Valid characters include 0 to 9, a minus sign (-), and a period (.). They should be in correct numeric data form. If not, INPUT # statement accepts only numeric data from the first character up to correctly formed character, as valid data. If no valid data is found, the INPUT # statement automatically assigns a zero (0) to variable.
I/O statement KEY Assigns a string or a control code to a function key; also defines a function key as a backlight function on/off key. This statement also defines a magic key as a trigger switch, shift key, or software keyboard display key.
Chapter 14. Statement Reference Description: ■ Assigning a string or a control code to a function key KEY in syntax 1 assigns a string or a control code specified by stringdata to a function key specified by keynumber. Pressing the specified function key generates the assigned string data or control code and then passes it to the user program as if each character is keyed in directly from the keyboard. • keynumber is a key number assigned to a particular function key.
• Pressing the M4 key (key number 38) while holding down the shift key functions as a backlight on/off control key by default. • If pressed together with the shift key, any numerical key can operate as a function key. • onduration is the length of time in seconds from when the backlight is turned on to automatic turning-off.
Chapter 14. Statement Reference NOTE If you issue KEY statements specifying a same function key, only the last KEY statement takes effect. The description below, for example, makes the function key numbered 3 operate as a backlight function on/off key and the length of backlight ONtime is 100 seconds. KEY 3,"a" KEY 3,"BL100" The description below assigns string data "a" to the function key numbered 3. The default backlight function on/off key (combination of M4 key and shift key) will be restored.
Example: Syntax 1: KEY 1,"a" KEY 2,"F"+CHR$(13) KEY 3,"" Syntax 2: KEY 1,"BL60" Reference: Statements: KEY OFF, KEY ON, and ON KEY...
Chapter 14. Statement Reference I/O statement KEY ON and KEY OFF Enables or disables keystroke trapping for a specified function key. Syntax: KEY (keynumber){ON|OFF} Parameter: keynumber A numeric expression which returns a value from 1 to 31, 33 to 38, and 501 to 550. Description: ■ KEY ON KEY ON enables keystroke trapping for a function key specified by keynumber. (Refer to Appendix E, "Key Number Assignment on the Keyboard.
Syntax errors: Error code and message Meaning error 71: Syntax error • keynumber is not enclosed in parentheses ( ). • Neither ON or OFF follows (keynumber). Run-time errors: Error code Meaning 05h Parameter out of the range (keynumber is out of the range.) Reference: Statements: KEY and ON KEY...
Chapter 14. Statement Reference File I/O statement KILL Deletes a specified file from the memory. Syntax: KILL "[drivename:]filename" Parameter: "[drivename:]filename" A string expression. Description: KILL deletes a data file or a user program file specified by "[drivename:]filename". • [drivename:] is used in conventional BHT series. In the BHT-100 series, it is merely for the compatibility with their specifications. The drivename may be A: or B:, but it will be ignored.
Example: CLOSE IF kyIn$="Y" THEN KILL "Master.
Chapter 14. Statement Reference Kanji Pattern LOAD I/O statement KPLOAD Loads a user-defined Kanji font in the two-byte Kanji mode. This statement also loads a user-defined cursor. Syntax: Syntax 1 (Loading a user-defined Kanji font): KPLOAD kanjicode, fontarrayname Syntax 2 (Loading a user-defined cursor): KPLOAD kanjicode, cursorarrayname Parameter: kanjicode • For a user-defined Kanji font A numeric expression which returns a value from EBC0h to EBDFh, EC40h to EC7Eh, and EC80h to EC83h.
• The loaded user-defined fonts are effective during execution of the user program which loaded those fonts and during execution of the successive user programs chained by the CHAIN statement. • If you load a font to the same kanjicode more than one time, the most recently specified font takes effect. • Only when the Interpreter executes the KPLOAD statement, it refers to the array data defined by fontarrayname.
Chapter 14. Statement Reference • An array integer variable--a work array, register array, or common array--for cursorarrayname should be declared by the DIM, DEFREG, or COMMON statement, respectively. DIM kp0%(5) DEFREG kp1%(5) COMMON kp2%(5) The array variable should be one-dimensional and have at least 6 elements. Each element data should be an integer and stored in the area from the 1st to 6th elements of the array.
• If the double-width, double-height, or quadruple-size is specified, then userdefined cursors loaded by the KPLOAD will display in double-width, doubleheight, or quadruple-size, respectively. For details, refer to Chapter 7, Subsection 7.1.3 "Dot Patterns of Fonts." Syntax errors: Error code and message Meaning error 71: Syntax error • No fontarrayname or cursorarrayname is defined. • fontarrayname or cursorarrayname has an array string variable.
Chapter 14. Statement Reference Example: DIM kp%(15) kp%(0)=&H0000 kp%(1)=&H8011 kp%(2)=&H6022 kp%(3)=&H1844 kp%(4)=&H0600 kp%(5)=&H8802 kp%(6)=&H8AF2 kp%(7)=&H4A92 kp%(8)=&H4A97 kp%(9)=&H2A92 kp%(10)=&H1FF2 kp%(11)=&H2A92 kp%(12)=&H4A97 kp%(13)=&H4A92 kp%(14)=&H8AF2 kp%(15)=&H8802 . . .
Assignment statement LET Assigns a value to a given variable. Syntax: Syntax 1: [LET] stringvariable = stringexpression Syntax 2: [LET] numericvariable = numericexpression Description: LET assigns a value of expression on the right-hand side to a variable on the lefthand side. • In a numeric data assignment, the assignment statement automatically converts an integer value to a real value. In the type conversion from a real value to an integer value, it rounds off the fractional part.
Chapter 14. Statement Reference I/O statement LINE INPUT Reads input from the keyboard into a string variable. Syntax: LINE INPUT ["prompt"{,|;}]stringvariable Parameter: "prompt" A string constant. stringvariable A string variable. Description: When execution reaches a LINE INPUT statement, the program pauses and waits for the user to enter data from the keyboard while showing a prompting message specified by "prompt". After typing data, the user must press the ENT key.
If "prompt" is followed by a comma, the statement displays the prompting message but no question mark or space is appended to the prompting message. LINE INPUT "data= ",a$ data= • The cursor shape specified by the most recently executed LOCATE statement takes effect. • Even after execution of the CURSOR OFF statement, the LINE INPUT statement displays the cursor. • Data inputted by the user will echo back to the LCD. To assign it to string- variable, it is necessary to press the ENT key.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 71: Syntax error • INPUT is missing. • Neither a comma (,) or semicolon (;) follows "prompt". • "prompt" is not a string constant. • stringvariable has a numeric variable. • A semicolon (;) immediately follows LINE INPUT.
File I/O statement LINE INPUT # Reads data from a device I/O file into a string variable. Syntax: LINE INPUT #filenumber,stringvariable Parameter: filenumber A numeric expression which returns a value from 1 to 16. stringvariable A string variable. Description: LINE INPUT # reads data from a device I/O file (a communications device file or bar code device file) specified by filenumber and assigns it to stringvariable. • filenumber is a number assigned to the device I/O file when it was opened.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 71: Syntax error • INPUT is missing. • filenumber is missing. • "prompt" is not a string constant. • stringvariable has a numeric variable. Run-time errors: Error code Meaning 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than device I/O files.
I/O statement LOCATE Moves the cursor to a specified position and changes the cursor shape. Syntax: Syntax 1: LOCATE [column][,row[,cursorswitch]] Syntax 2: LOCATE,,cursorswitch Parameter: A numeric expression which returns a value given below.
Chapter 14. Statement Reference • The entry ranges of the column and row are the same in the regular-size, doublewidth, double-height, and quadruple-size. • Any parameter value outside its range will result in a run-time error. • Specification of the maximum value to column moves the cursor off the screen and out of sight.
• If the double-height or quadruple-size is specified, specification of the maximum value to row moves the cursor off the screen and out of sight. Example: SCREEN 0,4 ’Double-height in ANK mode LOCATE ,25 This cursor is invisible If you display data on the screen under the above condition, the screen scrolls and the data appears. PRINT “A”; A This cursor is visible Switching to the regular-size will make the cursor visible as shown below.
Chapter 14.
Error control statement ON ERROR GOTO Enables error trapping. Syntax: ON ERROR GOTO label Description: ON ERROR GOTO enables error trapping so as to pass control to the first line of an error-handling routine specified by label if an error occurs during program execution. • To return control from an error-handling routine to a specified program location, you use a RESUME statement in the error-handling routine. • Specification of zero (0) to label disables error trapping.
Chapter 14. Statement Reference Flow control statement ON...GOSUB and ON...GOTO Branches to one of specified labels according to the value of an expression. Syntax: Syntax 1: ON expression GOSUB label [,label...] Syntax 2: ON expression GOTO label [,label...] Parameter: expression A numeric expression which returns a value from 1 to 255. Description: ON...GOSUB or ON...GOTO block branches to a label in the label list according to the value of expression.
Syntax errors: Error code and message Meaning error 71: Syntax error • label has not been defined. • label is missing. Run-time errors: Error code Meaning 05h Parameter out of the range (expression is negative or greater than 255.) 07h Insufficient memory space (The program nesting by GOSUB statements only is too deep.) Reference: Statements: GOSUB, GOTO, and SELECT...CASE...
Chapter 14. Statement Reference I/O statement ON KEY...GOSUB Specifies an event-handling routine for keystroke interrupt. Syntax: ON KEY (keynumber) GOSUB label Parameter: keynumber A numeric expression which returns a value from 1 to 31, 33 to 38, and 501 to 550. Description: According to label, ON KEY...GOSUB specifies the first line of an event-handling routine to be invoked if a function key specified by keynumber is pressed. (Refer to Appendix E, "Key Number Assignment on the Keyboard.") • ON KEY.
• When using the ON KEY...GOSUB statement together with block-structured statements (DEF FN...END DEF, FOR...NEXT, FUNCTION...END FUNCTION, IF...THEN...ELSE...END IF, SELECT...CASE...END SELECT, SUB...END SUB and WHILE...WEND), you can nest them to a maximum of 30 levels. • Specifying 32 to keynumber will be ignored. Syntax errors: Error code and message Meaning error 71: Syntax error • label has not been defined. • label is missing. • keynumber is not enclosed in parentheses ( ).
Chapter 14. Statement Reference File I/O statement OPEN Opens a data file for I/O activities. Syntax: OPEN "[drivename:]filename" AS [#] filenumber [RECORD filelength] Parameter: filenumber A numeric expression which returns a value from 1 to 16. "[drivename:]filename" A string expression. filelength An integer constant which has the value from 1 to 32767.
• filelength is the maximum number of registrable records in a file. It can be set only when a new data file is created by an OPEN statement. If you specify filelength when opening any of existing data files (including downloaded data files), then the filelength will be ignored. • Specifying only filelength does not allocate memory. Whether or not a PUT statement can write records up to the specified filelength depends on the memory occupation state.
Chapter 14. Statement Reference File I/O statement OPEN "BAR:" Opens the bar code device file. This statement also activates or deactivates the indicator LED and the beeper (vibrator) individually. Syntax: OPEN "BAR:[readmode][beepercontrol][LEDcontrol]" AS [#]filenumber CODE readcode[,readcode...] Parameter: readmode A string expression. beepercontrol A string expression. Specification of B activates the beeper (vibrator). (Default: Deactivated) LEDcontrol A string expression.
• Only a single bar code device file can be opened at a time. The total number of files which can be opened at a time is 16 including data files and communications device files. • The BHT cannot open the bar code device file and the IrDA interface of the communications device file concurrently. If you attempt to open them concurrently, a run-time error will occur. The BHT can open the bar code device file and the direct-connect interface concurrently.
Chapter 14. Statement Reference Auto-off mode (F) OPEN "BAR:F" AS #7 CODE "A" If you press the trigger switch*1, the illumination LED*2 comes on. When you release the switch or when the BHT completes bar code reading, then the illumination LED will go off. Holding down the trigger switch*1 lights the illumination LED for a maximum of 5 seconds. While the illumination LED is on, the BHT can read a bar code until a bar code is read successfully or the bar code devices file becomes closed.
• If readmode is omitted, the BHT defaults to the auto-off mode. • In the momentary switching mode, alternate switching mode, or continuous reading mode, after you read a low-quality bar code which needs more than one second to be read, keeping applying the barcode reading window to that bar code may re-read the same bar code in succession at intervals of one second or more.
Chapter 14. Statement Reference ■ readcode BHT-100Q The BHT supports a total of nine types of codes--four types of 2D codes (QR Code, PDF417, MaxiCode, and Data Matrix) and five types of bar codes (universal product codes, interleaved 2 of 5 (ITF), Codabar (NW7), Code 39, and Code 128). The BHT can read also EAN128 if Code 128 is specified. (For readable code types, refer to the BHT User’s Manual.) QR Code (Q) Syntax: Q[:[symbolindex][mini.code.version][-max.code.
The split code scanning mode ("Structured Append") of the QR Code system can divide a data string into a maximum of 16 blocks. splitmode allows the BHT to read those split codes in the edit mode or non-edit mode. splitmode is E or C specifying the following: Split code scanning allowed in the mode below splitmode E Edit mode C Non-edit mode Specifying both of E and C to splitmode will result in a run-time error. If splitmode is omitted, no split codes can be read.
Chapter 14. Statement Reference In any of the following cases, the BHT ends the split code scanning sequence even in midway. If it happens in the edit mode, all read data will be discarded. • The BHT reads a non-split code. The non-split code data will be stored in the barcode buffer. • The BHT reads a split code of any other QR Code. The current sequence ends and a new sequence starts.
Universal product codes (A) Syntax : A[:[code][1stchara[2ndchara]] [,[code][1stchara[2ndchara]]] [,[code][1stchara[2ndchara]]]] where code is A, B, or C specifying the following: code Bar code type A EAN-13 or UPC-A B EAN-8 C UPC-E If code is omitted, the default is all of the universal product codes. 1stchara and 2ndchara are flag characters representing a country code and should be numerals from 0 to 9. If a question mark (?) is specified to 1stchara or 2ndchara, it acts as a wild card.
Chapter 14. Statement Reference Interleaved 2 of 5 (ITF) (I) Syntax : I[:[mini.no.digits[-max.no.digits]][CD][;[1stchara[2ndchara]]] [,[mini.no.digits[-max.no.digits]][CD][;[1stchara[2ndchara]]]] [,[mini.no.digits[-max.no.digits]][CD][;[1stchara[2ndchara]]]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively. They should be a numeral from 2 to 99 and should satisfy the following condition: mini.no.digits ≤ max.no.
Codabar (NW-7) (N) Syntax: N[:[mini.no.digits[-max.no.digits]][startstop][CD] [,[mini.no.digits[-max.no.digits]][startstop][CD]] [,[mini.no.digits[-max.no.digits]][startstop][CD]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively. They should be a numeral from 3 to 99 and satisfy the following condition: mini.no.digits ≤ max.no.digits If both of mini.no.digits and max.no.
Chapter 14. Statement Reference Code 39 (M) Syntax: M[:[mini.no.digits[-max.no.digits]][CD][;[1stchara[2ndchara]]] [,[mini.no.digits[-max.no.digits]][CD][;[1stchara[2ndchara]]]] [,[mini.no.digits[-max.no.digits]][CD][;[1stchara[2ndchara]]]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively. They should be a numeral from 1 to 99, excluding start/stop characters. They should satisfy the following condition: mini.no.
Code 128 (K) Syntax : K[:[mini.no.digits[-max.no.digits]][;[1stchara[2ndchara]]] [,[mini.no.digits[-max.no.digits]][;[1stchara[2ndchara]]]] [,[mini.no.digits[-max.no.digits]][;[1stchara[2ndchara]]]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively. They should be a numeral from 1 to 99, excluding start/stop characters and check digit. They should satisfy the following condition: mini.no.digits ≤ max.no.
Chapter 14. Statement Reference If the BHT reads any bar code consisting of special characters only (such as FNC, CODEA, CODEB, CODEC and SHIFT characters), it will not transfer the data to the barcode buffer. The beeper sounds only if it is activated. FNC characters will be handled as follows: (1) FNC1 The BHT will not transfer an FNC1 character placed at the first or second character position immediately following the start character, to the barcode buffer.
Multi-line code scanning To scan multi-line codes, specify an ampersand (&) followed by up to three lines of codes to be scanned. Syntax 1: "&","[1stline]","[2ndline]"[,"[3rdline]"] Syntax 2: "&","[1stline],[2ndline][,[3rdline]]" Syntax 3: "&","[1stline],[2ndline]"[,"[3rdline]"] As a multi-line code, you may specify five types of bar codes—universal product codes, Interleaved 2 of 5 (ITF), Codabar (NW-7), Code 39, and Code 128.
Chapter 14. Statement Reference A single heading character may also be designated. Example: To scan EAN and ITF (specified with a heading character) in the following order--"EAN starting with 49" and "6- to 10-digit ITF starting with 2," write as follows: OPEN "BAR:" AS #1 CODE "&","A:49", "I:6-10;2" (4) Scanned codes will be outputted in the order specified to 1stline, 2ndline, or 3rdline.
(6) If the same type of code, same number of digits, and same conditions are specified to both a single-line scanning and multi-line scanning, then the specified single-line code cannot be read.
Chapter 14. Statement Reference ■ readcode BHT-100B The BHT supports seven types of bar codes--the universal product codes, Interleaved 2 of 5 (ITF), Standard 2 of 5 (STF), Codabar (NW-7), Code 39, Code 93, and Code 128. The BHT can read also EAN-128 if Code 128 is specified. (For readable bar code types, refer to the BHT User’s Manual.
Interleaved 2 of 5 (ITF) (I) Syntax : I[:[mini.no.digits[-max.no.digits]][CD] [,[mini.no.digits[-max.no.digits]][CD]] [,[mini.no.digits[-max.no.digits]][CD]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively. They should be a numeral from 2 to 99 and satisfy the following conditions: mini.no.digits ≤ max.no.digits If both of mini.no.digits and max.no.
Chapter 14. Statement Reference CD is a check digit. Specifying a C to CD makes the Interpreter check bar codes with MOD-16. The check digit is included in the number of digits. OPEN "BAR:" AS #1 CODE "N:8AAC" Code 39 (M) Syntax: M[:[mini.no.digits[-max.no.digits]][CD] [,[mini.no.digits[-max.no.digits]][CD]] [,[mini.no.digits[-max.no.digits]][CD]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively.
Code 128 (K) Syntax : K[:[mini.no.digits[-max.no.digits]] [,[mini.no.digits[-max.no.digits]]] [,[mini.no.digits[-max.no.digits]]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively. They should be a numeral from 1 to 99, excluding start/stop characters and check digit. They should satisfy the following condition: mini.no.digits ≤ max.no.digits If both of mini.no.digits and max.no.
Chapter 14. Statement Reference (4) FNC4 An FNC4 converts data encoded by the code set A or B into a set of extended ASCII-encoded data (128 added to each official ASCII code value). A single FN4 character converts only the subsequent data character into the extended ASCII-encoded data. A pair of FNC4 characters placed in successive positions converts all of the subsequent data characters preceding the next pair of FNC4 characters or the stop character, into the extended ASCII-encoded data.
Syntax errors: Error code and message Meaning error 71: Syntax error The number of the specified read codes exceeds eight. Run-time errors: Error code Meaning 02h Syntax error (readcode is missing.) 05h Parameter out of the range (readcode is not correct.) 37h File already open 3Ah File number out of the range 45h Device files prohibited from opening concurrently (You attempted to open the bar code device file and IrDA interface of the communications device file concurrently.
Chapter 14. Statement Reference File I/O statement OPEN "COM:" Opens a communications device file.
Description: OPEN "COM:" opens a communications device file and associates it with filenumber for allowing input/output activities using the communications interface. • If optional parameters enclosed with brackets are omitted, the most recently specified values or the defaults become active.
Chapter 14. Statement Reference ■ charalength charalength is a character length or the number of data bits. It should be 8 (default) or 7 bits. ■ stopbit stopbit is the number of stop bits. It should be 1 (default) or 2 bits. NOTE The IrDA interface is compliant with the IrDA physical layer (IrDASIR1.0), so the vertical parity, character length, and stop bit length are fixed to none, 8 bits, and 1 bit, respectively. If selected, those parameters will be ignored.
Syntax errors: Error code and message Meaning error 71: Syntax error filenumber is missing. Run-time errors: Error code Meaning 02h Syntax error (The x in "COM:x" contains an invalid parameter.) 37h File already open 3Ah File number out of the range 45h File already open (You attempted to open the bar code device file and the IrDA interface of the communications device file concurrently.
Chapter 14. Statement Reference I/O statement OUT Sends a data byte to an output port. Syntax: OUT portnumber,data Parameter: portnumber A numeric expression. data A numeric expression which returns a value from 0 to 255. Description: OUT sends a data byte designated by data to a port specified by portnumber. • portnumber is not an actual hardware port number on the BHT but a logical one which the Interpreter assigns. (Refer to Appendix D, "I/O Ports.
Run-time errors: Error code Meaning 05h Parameter out of the range (portnumber or data is out of the range.) Example: OUT 3,7 The above example sets the LCD contrast to the maximum.
Chapter 14. Statement Reference I/O statement POWER Controls the automatic power-off facility. Syntax: Syntax 1 (Turning off the power according to the power-off counter): POWER counter Syntax 2 (Turning off the power immediately): POWER {OFF|0} Syntax 3 (Disabling the automatic power-off facility): POWER CONT Parameter: counter A numeric expression which returns a value from 0 to 32767.
■ Turning off the power immediately Execution of POWER OFF or POWER 0 immediately turns off the power. • The execution of POWER OFF or POWER 0 deactivates the resume function if preset. ■ Disabling the automatic power-off facility POWER CONT disables the automatic power-off facility. Run-time errors: Error code Meaning 05h Parameter out of the range (counter is out of the range.
Chapter 14. Statement Reference I/O statement PRINT Displays data on the LCD screen. Syntax: PRINT [data[CR/LFcontrol...]] Parameter: data A numeric or string expression. CR/LFcontrol A comma (,) or a semicolon (;). Description: PRINT displays a number or a character string specified by data at the current cursor position on the LCD screen (To position the cursor, use a LOCATE statement.) and then repositions the cursor according to CR/LFcontrol.
■ CR/LFcontrol CR/LFcontrol determines where the cursor is to be positioned after the PRINT statement executes. • If CR/LFcontrol is a comma (,), the cursor moves to the column position of a least multiple of 8 plus one following the last character output. Statement example: PRINT 123, Output: 123 _ ( is a space.) • If CR/LFcontrol is a semicolon (;), the cursor moves to the column position immediately following the last character output.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 71: Syntax error data contains a comma (,) or semicolon (;).
File I/O statement PRINT # Outputs data to a communications device file. Syntax: PRINT #filenumber[,data[CR/LFcontrol...]] Parameter: filenumber A numeric expression which returns a value from 1 to 16. data A numeric or string expression. CR/LFcontrol A comma (,) or a semicolon (;). Description: PRINT # outputs a numeric value or a character string specified by data to a communications device file specified by filenumber.
Chapter 14. Statement Reference • If CR/LFcontrol is a semicolon (;), the PRINT # statement outputs data without adding spaces or control codes. Statement example: PRINT #1,"ABC";"123"; Output: ABC123 • If neither a comma (,) nor semicolon (;) is specified to CR/LFcontrol, the PRINT # statement adds a CR and LF codes.
I/O statement PRINT USING Displays data on the LCD screen under formatting control. Syntax: Syntax 1 (Displaying numbers): PRINT USING "numericformat";expression [CR/LFcontrol [expression]...] Syntax 2 (Displaying strings): PRINT USING "stringformat";stringexpression [CR/LFcontrol[stringexpression]...] Parameter: numericformat #, a decimal point (.), and/or +. stringformat !, @, and/or & CR/LFcontrol A comma (,) or a semicolon (;).
Chapter 14. Statement Reference ■ numericformat numericformat is a formatting string consisting of #, decimal point (.), and/or +, each of which causes a special printing effect as described below. # Represents a digit position. If the number specified by expression has fewer digits than the number of digit positions specified by #, then it is padded with spaces and right-justified. Statement example: PRINT USING "#####";123 Output: 123 ( is a space.
■ stringformat stringformat is a formatting string consisting of !, @, and/or &&, each of which causes a special printing effect as described below. ! Displays the first character of the stringexpression. Statement example: PRINT USING "!";"ABC" Output: A @ Displays the entire stringexpression. Statement example: PRINT USING "@";"ABC" Output: ABC && Displays the first n+2 characters of the stringexpression, where n is the number of spaces between the ampersands (&&).
Chapter 14. Statement Reference ■ CR/LFcontrol CR/LFcontrol determines where the cursor is to be positioned after the PRINT USING statement executes. For details, refer to the CR/LFcontrol in the PRINT statement. Syntax errors: Error code and message Meaning error 71: Syntax error • numericformat is not correct. • expression or stringexpression contains a comma (,) or semicolon (;). No semicolon (;) follows "numericformat" or "stringformat".
Declarative statement PRIVATE Declares one or more work variables or register variables defined in a file, to be private (as local variables). Syntax: Syntax 1: PRIVATE varname [,varname...] Syntax 2: PRIVATE DEFREG registerdefinition [,registerdefinition...
Chapter 14. Statement Reference subscript For one-dimensional: integerconstant For two-dimensional: integerconstant,integerconstant Where integerconstant is a numeric expression which returns a value from 0 to 254. stringlength An integer constant from 1 to 255 which indicates the number of characters. Description: PRIVATE defines variables declared by varname or registerdefinition as local variables which can be referred to or updated in that file.
Run-time errors: Error code Meaning 05h Parameter out of the range 07h Insufficient memory space (The variable area has run out.) 0Ah Duplicate definition (An array is double declared.
Chapter 14. Statement Reference File I/O statement PUT Writes a record from a field variable to a data file. Syntax: PUT [#]filenumber[,recordnumber] Parameter: filenumber A numeric expression which returns a value from 1 to 16. recordnumber A numeric expression which returns a value from 1 to 32767. Description: PUT writes a record from a field variable(s) declared by the FIELD statement to a data file specified by filenumber. • filenumber is the number of a data file opened by the OPEN statement.
Syntax errors: Error code and message Meaning error 71: Syntax error filenumber is missing. Run-time errors: Error code Meaning 05h Parameter out of the range (• filenumber is out of the range.) (• recordnumber is out of the range.) 07h Insufficient memory space 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than data files.
Chapter 14. Statement Reference I/O statement READ Reads data defined by DATA statement(s) and assigns them to variables. Syntax: READ variable[,variable...] Parameter: variable A numeric or string variable. Description: READ reads as many data values as necessary in turn from data stored by DATA statement and assigns them, one by one, to each variable in the READ statement.
If the string data is invalid as numeric data, the READ statement assigns the value 0 to the numeric variable. Statement example: DATA "ABC" READ c PRINT c Output: 0 • The number of data values stored by the DATA statement must be equal to or greater than that of variables specified by the READ statement. If not, a run-time error occurs. • To specify the desired DATA statement location where the READ statement should start reading data, you use the RESTORE statement.
Chapter 14. Statement Reference Declarative statement REM Declares the rest of a program line to be remarks or comments. Syntax: Syntax 1: REM comment Syntax 2: ’ comment Description: REM causes the rest of a program line to be treated as a programmer’s remark or comment for the sake of the program readability and future program maintenance. The remark statements are non-executable.
I/O statement RESTORE Specifies a DATA statement location where the READ statement should start reading data. Syntax: RESTORE [label] Description: RESTORE specifies a DATA statement location where the READ statement should start reading data, according to label designating the DATA statement. • You can specify DATA statements in included files. • If label option is omitted, the default label is a DATA statement appearing first in the user program.
Chapter 14. Statement Reference Error control statement RESUME Causes program execution to resume at a specified location after control is transferred to an error-handling routine. Syntax: Syntax 1: RESUME [0] Syntax 2: RESUME NEXT Syntax 3: RESUME label Description: RESUME returns control from the error-handling routine to a specified location of the main program to resume program execution. • The RESUME statement has three forms as listed below. The form determines where execution resumes.
Run-time errors: Error code Meaning 14h RESUME without error (RESUME statement occurs outside of an error-handling routine.
Chapter 14. Statement Reference Flow control statement RETURN Returns control from a subroutine or an event-handling routine (for keystroke interrupt). Syntax: RETURN Description: RETURN statement in a subroutine returns control to the statement immediately following the GOSUB that called the subroutine. RETURN statement in an event-handling routine for keystroke interrupt returns control to the program location immediately following the one where the keystroke trap occurred.
I/O statement SCREEN Sets the display mode (display angle, screen mode, and font size) and character attributes (tone, character enlargement, and font reverse attributes). Syntax: Syntax 1: SCREEN displaymode[,charaattribute] Syntax 2: SCREEN ,charaattribute Parameter: displaymode and charaattribute A numeric expression which returns a value from 0 to 65535. Description: displaymode in the SCREEN statement sets the display angle, screen mode, and font size as listed below.
Chapter 14. Statement Reference charaattribute sets the tone, character enlargement, and font reverse attributes as listed below.
charaattribute is expressed with a bit array as shown below.
Chapter 14. Statement Reference Example: mode% = .scMB+.scSmall attrib% = .scW2H1+.
Flow control statement SELECT...CASE...END SELECT Conditionally executes one of statement blocks depending upon the value of an expression. Syntax: SELECT conditionalexpression CASE test1 [statementblock] [CASE test2 [statementblock]]... [CASE ELSE [statementblock]] END SELECT Parameter: conditionalexpression, test1, and test2 A numeric or string expression. Description: This statement executes one of statementblocks depending upon the value of conditionalexpression according to the steps below.
Chapter 14. Statement Reference • You can nest the SELECT…CASE…END SELECT statements to a maximum of 10 levels. SELECT a CASE 1 SELECT b CASE 3 PRINT "a=1,b=3" END SELECT CASE 2 PRINT "a=2" END SELECT • When using the SELECT statement block together with block-structured statements (DEF FN...END DEF, FOR...NEXT, FUNCTION...END FUNCTION, IF...THEN...ELSE...END IF, SELECT...CASE...END SELECT, SUB...END SUB and WHILE...WEND), you can nest them to a maximum of 30 levels.
User-defined function statement SUB...END SUB Names and defines user-defined function SUB. Syntax: Syntax 1 (Defining a numeric function): SUB subname [(dummyparameter[,dummyparameter]...)] Syntax 2 (Exiting from the function block prematurely): EXIT SUB Syntax 3 (Ending the function block): END SUB Syntax 4 (Calling a function): [CALL] subname[(realparameter[,realparameter]...
Chapter 14. Statement Reference Description: ■ Creating a user-defined function SUB...END SUB creates a user-defined function. The function definition block between SUB and END SUB is a set of some statements and functions. • You cannot make double definition to a same function name. • This statement block should not be defined in the block-structured statements (DEF FN...END DEF, FOR...NEXT, FUNCTION...END FUNCTION, IF...THEN ...ELSE...END IF, SELECT...CASE...END SELECT, SUB...END SUB, and WHILE...
Syntax errors: ■ When defining a user function Error code and message Meaning error 64: Function redefinition You made double definition to a same function name. error 71: Syntax error • The string length is out of the range. • The string length is not an integer constant. error 92: Incorrect use of SUB, EXIT SUB or END SUB • The EXIT SUB statement is specified outside the function definition block. • The END SUB statement is specified outside the function definition block.
Chapter 14. Statement Reference Run-time errors: Error code Meaning 07h Insufficient memory space (You nested SUB statements to more than 10 levels.) 0Fh String length out of the range (The returned value of the string length exceeds the allowable range.) Reference: Statements: DECLARE Example: File 1 File 2 DECLARE SUB add(x,y) A=1:B=2 PRINT "TEST" CALL add(A,B) . . .
I/O statement WAIT Pauses program execution until a designated input port presents a given bit pattern. Syntax: WAIT portnumber,ANDbyte[,XORbyte] Parameter: portnumber A numeric expression. ANDbyte and XORbyte A numeric expression which returns a value from 0 to 255. Description: WAIT suspends a user program while monitoring the input port designated by portnumber until the port presents the bit pattern given by ANDbyte and XORbyte. (Refer to Appendix D, "I/O Ports.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 71: Syntax error • portnumber is missing. • ANDbyte is missing. Run-time errors: Error code Meaning 05h Parameter out of the range Example: WAIT 0,&H03 The above statement suspends a user program until any data is inputted from the keyboard or the bar code reader.
Flow control statement WHILE...WEND Continues to execute a statement block as long as the conditional expression is true. Syntax: WHILE conditionalexpression [statementblock] WEND Description: A WHILE...WEND continues to execute statementblock as long as the conditionalexpression is true (not zero) according to the steps below. (1) The conditionalexpression in the WHILE statement is evaluated.
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning error 26: Too deep nesting. error 57: Incorrect use of WHILE...WEND WEND appears outside of the WHILE error 58: Incomplete control structure No WEND corresponds to WHILE. Reference: Statements: FOR…NEXT 328 statement block.
I/O statement XFILE Transmits a designated file according to the specified communications protocol. Syntax: XFILE "[drivename:]filename"[,"protocolspec"] Parameter: "[drivename:]filename" and "protocolspec" String expressions. Description: XFILE transmits a data file designated by "[drivename:]filename" between the BHT and host computer or between BHTs according to the communications protocol specified by "protocolspec." (For the BHT-protocol and BHT-Ir protocol, refer to the BHT User’s Manual.
Chapter 14. Statement Reference - Transmission direction Parameter omitted (default) Transmits a file from the BHT. R or r Receives a file from the host computer or any other BHT. Example: XFILE "d2.dat","R" "filename" cannot be omitted even in file reception. - Serial number Parameter omitted (default) No serial number setting. S or s Adds a serial number to every transmission block. Example: XFILE "d2.
- Timeout length when a link will be established Specify the timeout length by 1 to 9. Uploading Set value Downloading BHT-protocol BHT-Ir protocol 1 30 sec. Retries of ENQ, 10 times Retries of ENQ, 60 times 2 60 sec. Retries of ENQ, 20 times Retries of ENQ, 120 times 3 90 sec. Retries of ENQ, 30 times Retries of ENQ, 180 times 4 120 sec. Retries of ENQ, 40 times Retries of ENQ, 240 times 5 150 sec. Retries of ENQ, 50 times Retries of ENQ, 300 times 6 180 sec.
Chapter 14. Statement Reference • A communications device file should be opened before execution of the XFILE statement. (For the file opening, refer to the OPEN "COM:" statement.) • The XFILE statement uses the interface specified by the OPEN "COM:" statement. • A data file to be transmitted should be closed beforehand. • To transfer a file by using the BHT-Ir protocol or multilink protocol, set the BHT's ID to any of 1 to FFFFh. Specifying zero (0) to the ID will result in a run-time error.
Run-time errors: Error code Meaning 02h Syntax error ([drivename:]filename is not correct.) 07h Insufficient memory space (During file reception, the memory runs out.) 32h File type mismatch (The received file is not a data file.) 33h Received text format not correct 34h Bad file name or number (You specified filename of an unopened file.) 35h File not found 37h File already open 38h The file name is different from that in the receive header.
Chapter 14. Statement Reference File I/O statement $INCLUDE Specifies an included file. Syntax: Syntax 1: REM $INCLUDE:’filename’ Syntax 2: ’$INCLUDE:’filename’ Description: $INCLUDE reads a source program specified by ’filename’ into the program line immediately following the $INCLUDE line in compilation. Storing definitions of variables, subroutines, user-defined functions, and other data to be shared by source programs into the included files will promote application of valuable program resources.
Fatal Error: Error code and message Meaning fatal error 30: Cannot find include file "XXX" No included file is found. fatal error 31: Cannot nest include file Included files are nested.
Chapter 14. Statement Reference Additional Explanation for Statements ■ Effective range of labels Labels are effective only in a file. ■ Definition of common variables (by COMMON statement) In an object to be executed first (that is, in a main object), you should define all common variables to be accessed. In any other objects, declare common variables required only in each object.
Chapter 15 Function Reference CONTENTS ABS ..................................................... 338 ASC ..................................................... 339 BCC$ ................................................... 340 CHKDGT$ ........................................... 342 CHR$ .................................................. 346 COUNTRY$ ........................................ 348 CSRLIN ............................................... 350 DATE$ .................................................
Chapter 15. Function Reference ABSolute Numeric function ABS Returns the absolute value of a numeric expression. Syntax: ABS(numericexpression) Description: ABS returns the absolute value of numericexpression. The absolute value is the magnitude of numericexpression without regard to sign. For example, both ABS (-12.34) and ABS (12.34) are equal to 12.34. • If you give a real number, this function returns a real number; if an integer number, this function returns an integer number.
ASCii code String function ASC Returns the ASCII code value of a given character. Syntax: ASC(stringexpression) Description: ASC returns the ASCII code value of the first character of stringexpression, which is an integer from 0 to 255. (For the ASCII character codes, refer to Appendix C, "Character Sets.") • If stringexpression is a null string, this function returns the value 0. • If given a two-byte Kanji character, this function cannot return the two-byte Kanji code.
Chapter 15. Function Reference Block Check Character String function BCC$ Returns a block check character (BCC) of a data block. Syntax: BCC$(datablock,checktype) Parameter: datablock A string expression. checktype A numeric expression which returns a value from 0 to 2. Description: BCC$ calculates a block check character (BCC) of datablock according to the block checking method specified by checktype, and returns the BCC.
Run-time errors: Error code Meaning 05h Parameter out of the range (checktype is out of the range.
Chapter 15. Function Reference CHecK DiGiT String function CHKDGT$ Returns a check digit of bar code data. Syntax: CHKDGT$(barcodedata,CDtype) Parameter: barcodedata and CDtype String expressions. Description: CHKDGT$ calculates a check digit (CD) of barcodedata according to the calculation method specified by CDtype, and then returns it as one-character string. • CDtype is A, H, I, M or N, which specifies the bar code type and the corresponding calculation method as listed below.
Sample coding 4: CD.Data$=CHKDGT$("a123Qa","N") "Q" is a CD position character, so CHKDGT$ calculates the correct CD and CD.Data$ will become "-." ■ When CDtype is A (EAN or UPC), CHKDGT$ identifies the EAN or UPC of barcodedata depending upon the data length (number of digits) as listed below. Data length of barcodedata 13 digits Universal Product Codes EAN-13 or UPC-A 8 digits EAN-8 7 digits UPC-E If the data length is a value other than 13, 8, and 7, this function returns a null string.
Chapter 15. Function Reference ■ When CDtype is I (ITF), the length of barcodedata must be an even number of two or more digits. If not, CHKDGT$ returns a null string. - To check that the CD is correct: Pass a CD-suffixed barcodedata to a CHKDGT$ as shown below. If the returned value is equal to the CD, the CD data is suitable for the barcodedata. Sample coding: IF CHKDGT$("123457","I")="7" THEN... - To add a CD to barcode data: Pass barcodedata followed by a dummy character to a CHKDGT$ as shown below.
■ When CDtype is N (Codabar), the length of barcodedata must be three digits or more including start and stop characters. If not, CHKDGT$ returns a null string. - To check that the CD is correct: Pass a CD-suffixed barcodedata to a CHKDGT$ as shown below. If the returned value is equal to the CD, the CD data is suitable for the barcodedata. Sample coding: IF CHKDGT$("a0123-a","N")="-" THEN...
Chapter 15. Function Reference CHaRacter code String function CHR$ Returns the character corresponding to a given ASCII code. Syntax: CHR$(characode) Parameter: characode A numeric expression which returns a value from 0 to 255. Description: CHR$ converts a numerical ASCII code specified by characode into the equivalent single-byte character. This function is used to send control codes (e.g.
• To display a Kanji code, use a shift JIS code as shown below. The shift JIS code for is 8ABFh.
Chapter 15. Function Reference COUNTRY I/O function COUNTRY$ Sets a national character set or returns a current country code. Syntax: Syntax 1 (Setting a national character set): COUNTRY$="countrycode" Syntax 2 (Returning a country code): COUNTRY$ Parameter: countrycode A string expression which returns any of A, D, E, F, G, I, J, N, S, and W. Description: ■ Syntax 1 COUNTRY$ sets a national character set specified by "countrycode".
• After setting a national character set, you may display national characters assigned to 32 (20h) to 127 (7Fh), on the LCD. • "countrycode" set by this function remains effective in the programs chained by CHAIN statements. • If "countrycode" has more than one character, only the first one takes effect. • If "countrycode" is an invalid letter other than those listed above, the function is ignored. • "countrycode" may be in lowercase.
Chapter 15. Function Reference CurSoR LINe I/O function CSRLIN Returns the current row number of the cursor. Syntax: CSRLIN Description: CSRLIN returns the current row number of the cursor as an integer in the current display mode specified by a SCREEN statement. Screen mode Font size Row number Single-byte ANK mode Standard-size 1 to 25 Two-byte Kanji mode Standard-size 1 to 37 Small-size 1 to 49 • Even if the cursor is invisible (by a LOCATE statement), the CSRLIN function operates.
DATE I/O function DATE$ Returns the current system date or sets a specified system date. Syntax: Syntax 1 (Retrieving the current system date): DATE$ Syntax 2 (Setting the current system date): DATE$="date" Parameter: date A string expression. Description: ■ Syntax 1 DATE$ returns the current system date as an 8-byte string. The string has the format below. yy/mm/dd where yy is the lower two digits of the year from 00 to 99, mm is the month from 01 to 12, and dd is the day from 01 to 31.
Chapter 15. Function Reference Run-time errors: Error code Meaning 05h Parameter out of the range (date is out of the range.
End Of File File I/O function EOF Tests whether the end of a device I/O file has been reached. Syntax: EOF([#]filenumber) Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: EOF tests for an end of a device I/O file designated by filenumber. Then it returns -1 (true) if no data remains; it returns 0 (false) if any data remains, as listed below.
Chapter 15. Function Reference Run-time errors: Error code Meaning 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a data file.
ERror Line Error-handling function ERL Returns the current statement location of the program where a run-time error occurred. Syntax: ERL Description: ERL returns the current statement location of the program where a run-time error occurred most recently. • The ERL function works only with line numbers and not with labels. • The returned value is in decimals, so it may be necessary to use the HEX$ function for decimal-to-hexadecimal conversion when using the ERL function in errorhandling routines.
Chapter 15. Function Reference ERRor code Error-handling function ERR Returns the error code of the most recent run-time error. Syntax: ERR Description: ERR returns the code of a run-time error that invoked the error-handling routine. • The returned value is in decimals, so it may be necessary to use the HEX$ function for decimal-to-hexadecimal conversion when using the ERR function in errorhandling routines.
End of TeXt I/O function ETX$ Modifies the value of a terminator (ETX) for the BHT-protocol; also returns the current value of a terminator. Syntax: Syntax 1 (Changing the value of a terminator): ETX$=stringexpression Syntax 2 (Returning the current value of a terminator): ETX$ Parameter: stringexpression A string expression which returns a single-byte character.
Chapter 15. Function Reference FREe area Memory management function FRE Returns the number of bytes available in a specified area of the memory. Syntax: FRE(areaspec) Parameter: areaspec A numeric expression which returns a value from 0 to 3. Description: FRE returns the number of bytes left unused in a memory area specified by areaspec listed below.
HEXadecimal String function HEX$ Converts a decimal number into the equivalent hexadecimal string. Syntax: HEX$(numericexpression) Parameter: numericexpression A numeric expression which returns a value from -32768 to 32767. Description: HEX$ function converts a decimal number from -32768 to 32767 into the equivalent hexadecimal string which is expressed with 0 to 9 and A to F. Listed below are conversion examples.
Chapter 15. Function Reference INput KEYboard I/O function INKEY$ Returns a character read from the keyboard. Syntax: INKEY$ Description: INKEY$ reads from the keyboard to see whether a key has been pressed, and returns one character read. If no key has been pressed, INKEY$ returns a null string. (For the character codes, refer to Appendix C. For the key number assignment, refer to Appendix E.) • INKEY$ does not echo back a read character on the LCD screen.
INPort data I/O function INP Returns a byte read from a specified input port. Syntax: INP(portnumber) Parameter: portnumber A numeric expression which returns a value from 0 to 32767. Description: INP reads one-byte data from an input port specified by portnumber and returns the value. (For the input port numbers, refer to Appendix D, "I/O Ports.") • If you specify an invalid value to portnumber, INP returns an indeterminate value.
Chapter 15. Function Reference INPUT File I/O function INPUT$ Returns a specified number of characters read from the keyboard or from a device file. Syntax: Syntax 1 (Reading from the keyboard): INPUT$(numcharas) Syntax 2 (Reading from a device file): INPUT$(numcharas,[#]filenumber) Parameter: numcharas A numeric expression which returns a value from 1 to 255. filenumber A numeric expression which returns a value from 1 to 16.
Run-time errors: Error code Meaning 05h Parameter out of the range (numcharas is out of the range.) 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a data file.
Chapter 15. Function Reference : IN STRing String function INSTR Searches a specified target string for a specified search string, and then returns the position where the search string is found. Syntax: INSTR([startposition,]targetstring,searchstring) Parameter: startposition A numeric expression which returns a value from 1 to 32767. targetstring and searchstring A string expression.
• A returned value of INSTR is a decimal number from 0 to 255, depending upon the conditions as listed below. Conditions Returned value If searchstring is found within targetstring: First character position of the search string first found. If startposition is greater than the length of targetstring or 255: 0 If targetstring is a null string: 0 If searchstring is not found: 0 If searchstring is a null string: Value of startposition. 1 if startposition option is omitted.
Chapter 15. Function Reference INTeger Numeric operation function INT Returns the largest whole number less than or equal to the value of a given numeric expression Syntax: INT(numericexpression) Parameter: numericexpression A real expression. Description: INT returns the largest whole number less than or equal to the value of numericexpression by stripping off the fractional part. • You use INT as shown below to round off the fractional part of a real number. INT(realnumber+0.5) Example: dat=1.
LEFT String function LEFT$ Returns the specified number of leftmost characters from a given string expression. Syntax: LEFT$(stringexpression,stringlength) Parameter: stringlength A numeric expression which returns a value from 0 to 255. Description: LEFT$ extracts a portion of a string specified by stringexpression by the number of characters specified by stringlength, starting at the left side of the string. • If stringlength is zero, LEFT$ returns a null string.
Chapter 15. Function Reference LENgth String function LEN Returns the length (number of bytes) of a given string. Syntax: LEN(stringexpression) Description: LEN returns the length of stringexpression, that is, the number of bytes in the range from 0 to 255. • If stringexpression is a null string, LEN returns the value 0. • LEN counts a full-width Kanji (in the two-byte code mode) as two characters.
LOcation Counter of file File I/O function LOC Returns the current position within a specified file. Syntax: LOC([#]filenumber) Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: LOC returns the current position within a file (a data file, communications device file, or bar code device file) specified by filenumber. • Depending upon the file type, the content of the returned value differs as listed below.
Chapter 15. Function Reference Run-time errors: Error code Meaning 34h Bad file name or number (You specified filenumber of an unopened file.) 3Ah File number out of the range 3Eh A PUT or GET statement executed without a FIELD statement. (No FIELD statement is found.
Location Of File File I/O function LOF Returns the length of a specified file. Syntax: LOF([#]filenumber) Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: LOF returns the length of a data file or communications device file specified by filenumber. • Depending upon the file type, the content of the returned value differs as listed below.
Chapter 15. Function Reference code MARK I/O function MARK$ Returns the bar code type and the number of digits of a read bar code. In the BHT-100Q, this function returns also the 2D code type and the number of digits of a read 2D code. Syntax: MARK$ Description: BHT-100Q MARK$ returns a maximum of 9 bytes of string in the format below. The first one byte represents the code type and the remaining two bytes indicate the number of digits of a read 2D code or bar code.
• The first one byte of a returned value contains one of the following letters representing code types: Code type First one byte of a returned value QR Code Q Split QR Code (in non-edit mode) S PDF417 Y MaxiCode X Data Matrix Z EAN-13 or UPC-A A EAN-8 B (Supported by the BHT-100Q only) UPC-E C ITF (Interleaved 2 of 5) I STF (Standard 2 of 5) H (Supported by the BHT-100B only) Codabar (NW-7) N Code 39 M Code 93 L (Supported by the BHT-100B only) Code 128 K EAN-128 W • The rem
Chapter 15. Function Reference MIDdle String function MID$ Returns a portion of a given string expression from anywhere in the string. Syntax: MID$(stringexpression,startposition[,stringlength]) Parameter: startposition A numeric expression which returns a value from 1 to 255. stringlength A numeric expression which returns a value from 0 to 255.
Run-time errors: Error code Meaning 05h Parameter out of the range Functions: LEFT$, LEN, and RIGHT$ Reference: 375
Chapter 15. Function Reference POSition I/O function POS Returns the current column number of the cursor. Syntax: POS(0) Description: POS returns the current column number of the cursor in the current display mode selected by a SCREEN statement, as an integer. Screen mode Font size Column number Single-byte ANK mode Standard-size 1 to 17 Two-byte Kanji mode Standard-size 1 to 26 Small-size 1 to 34 • Even if the cursor is invisible (by a LOCATE statement), the POS function operates.
RIGHT String function RIGHT$ Returns the specified number of rightmost characters from a given string expression. Syntax: RIGHT$(stringexpression,stringlength) Parameter: stringlength A numeric expression which returns a value from 0 to 255. Description: Starting at the right side of the string, RIGHT$ extracts a portion of a string specified by stringexpression by the number of characters specified by stringlength. • If stringlength is zero, RIGHT$ returns a null string.
Chapter 15. Function Reference SEARCH File I/O function SEARCH Searches a specified data file for specified data, and then returns the record number where the search data is found. Syntax: SEARCH([#]filenumber,fieldvariable,searchdata [,startrecord]) Parameter: filenumber A numeric expression which returns a value from 1 to 16. fieldvariable A non-array string variable. searchdata A string expression. startrecord A numeric expression which returns a value from 1 to 32767.
Run-time errors: Error code Meaning 05h Parameter out of the range 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than data files.) 3Ah File number out of the range 3Eh A PUT or GET statement executed without a FIELD statement. (No FIELD statement is found.
Chapter 15. Function Reference Start Of Heading I/O function SOH$ Modifies the value of a header (SOH) for the BHT-protocol; also returns the current value of a header. Syntax: Syntax 1 (Changing the value of a header): SOH$=stringexpression Syntax 2 (Returning the current value of a header): SOH$ Parameter: stringexpression A string expression which returns a single-byte character.
STRing String function STR$ Converts the value of a numeric expression into a string. Syntax: STR$(numericexpression) Parameter: numericexpression A numeric expression. Description: STR$ converts the value of numericexpression into a string. • If numericexpression is 0 or positive, then STR$ automatically adds a leading space (meaning + sign) as shown below. PRINT STR$(123);LEN(STR$(123)) 123 4 To delete the leading space, you should use the MID$ function as shown below.
Chapter 15. Function Reference Start of TeXt I/O function STX$ Modifies the value of a header (STX) for the BHT-protocol; also returns the current value of a header. Syntax: Syntax 1 (Changing the value of a header): STX$=stringexpression Syntax 2 (Returning the current value of a header): STX$ Parameter: stringexpression A string expression which returns a single-byte character.
TIME I/O function TIME$ Returns the current system time or wakeup time, or sets a specified system time or wakeup time. Syntax: Syntax 1 (Retrieving the current system time or wakeup time): TIME$ Syntax 2 (Setting the current system time or wakeup time): TIME$="time" Parameter: time A string expression. Description: ■ Syntax 1 Retrieving the current system time TIME$ returns the current system time as an 8-byte string. The string has the format below.
Chapter 15. Function Reference ■ Syntax 2 Setting the system time TIME$ sets the system time specified by "time." The format of "time" is the same as that in syntax 1. Example: TIME$="13:35:45" Setting the wakeup time TIME$ sets the wakeup time specified by "time." The format of "time" is the same as that in syntax 1. • The calendar clock is backed up by the battery. (For the system date, refer to the DATE$ function.
TIMER-A/TIMER-B/TIMER-C I/O function TIMEA/TIMEB/TIMEC Returns the current value of a specified timer or sets a specified timer. Syntax: Syntax 1 (Retrieving the current value of a specified timer): TIMEA TIMEB TIMEC Syntax 2 (Setting a specified timer): TIMEA=count TIMEB=count TIMEC=count Parameter: count A numeric expression which returns a value from 0 to 32767. Description: ■ Syntax 1 TIMEA, TIMEB, or TIMEC returns the current value of timer-A, -B, or -C, respectively, as a 2-byte integer.
Chapter 15. Function Reference VALue String function VAL Converts a string into a numeric value. Syntax: VAL(stringexpression) Parameter: stringexpression A string expression which represents a decimal number. Description: VAL converts the string specified by stringexpression into a numeric value. • If stringexpression is nonnumeric, VAL returns the value 0.
Chapter 16 Extended Functions CONTENTS 16.1 Overview...................................................................................................... 388 16.2 Reading or writing system settings from/to the memory (SYSTEM.FN3).... 389 16.2.1 Function Number List of SYSTEM.FN3............................................ 389 16.2.2 Detailed Function Specifications ...................................................... 390 16.3 Controlling the LCD and Touch Screen (CONSOLE.FN3) ..........................
16.1 Overview In addition to the BHT-BASIC statements and functions, the BHT-100 series supports the following extended functions which can be invoked by the CALL statement. Extended functions Used to: Remarks SYSTEM.FN3 Read or write system settings from/ to the memory. CONSOLE.FN3 Draw a dot/line/rectangle or control the touch screen. SYSMDFY.FN3 Reconfigure BHT/CU systems or get/set system reconfig file information. CRC.FN3 Calculate a CRC. SS.
Chapter 16. Extended Functions 16.2 Reading or writing system settings from/to the memory (SYSTEM.FN3) 16.2.1 Function Number List of SYSTEM.FN3 The SYSTEM.FN3 may read or write system settings depending upon the function number specified, as listed below. Function number Used to: .fcSysIGet 1 Read numeric data from System Mode settings .fcSysISet 2 Write numeric data to System Mode settings .fcSysSGet 3 Read string data from System Mode settings .
16.2.2 Detailed Function Specifications .fcSysIGet Read numeric data from System Mode settings Syntax: CALL "SYSTEM.FN3" .fcSysIGet PARA%,DATA% Description: This function reads numeric data (DATA%) from the system menu item specified by PARA%. Parameter: PARA% Item number of the system menu Returned value: DATA% Numeric data read from the specified system menu item System menu items list: Item number (PARA%) .
Chapter 16. Extended Functions Item number (PARA%) .syCmifApl .syCmifSys .syTrSpdOp System menu item *1 12 Default interface to be used for user programs R/W .syCmifOpt 0 IrDA interface 13 Default interface to be used for System Mode R/W .syCmifOpt 0 IrDA interface 14 Transmission speed for IrDA interface R/W .syOp24 0 2400 bps .syOp96 1 9600 bps .syOp192 2 19200 bps .syOp384 3 38400 bps .syOp576 4 57600 bps .
Item number (PARA%) .syHPrtyOp .syLnkTmOp System menu item DATA%, numeric data of the system menu item Attribute *1 23 Horizontal parity for IrDA interface R/W .syHPtyOff 0 No parity (OFF) 24 Timeout for data link establishment for IrDA interface R/W .syLnkT0 .syHPtyOn Initial value 1 1 Add (ON) 0 No timeout .syLnkT30 1 30 sec .syLnkT60 2 60 sec .syLnkT90 3 90 sec 1 .syLnkT120 4 120 sec .syFldSpOp .sySNoCn .syHPrtyCn .
Chapter 16. Extended Functions Item number (PARA%) .syScnMark System menu item 38 Scanning range marker (BHT-100Q) Scanning range marker (BHT-100B) DATA%, numeric data of the system menu item Attribute *1 R/W R/W – 0 Normal mode (Driven by the trigger switch) – 1 Fixed to ON – 2 Fixed to OFF – 0 Normal mode (Driven by the trigger switch) – 1 Fixed to OFF 39 View finder (BHT-100Q only) R/W .syVFOff 40 Option data (BHT-100Q only) R/W .syODOff .
.fcSysISet Write numeric data to System Mode settings Syntax: CALL "SYSTEM.FN3" .fcSysISet PARA%,DATA% Description: This function writes numeric data (DATA%) to the system menu item specified by PARA%. Parameter: PARA% DATA% Returned value: (None) Item number of the system menu Numeric data to be specified (See the system menu items list given in Function #1.) System menu items list: .fcSysSGet Refer to the System menu items list given in Function #1.
Chapter 16. Extended Functions Note: Items #9 through #11 take effect only when the LAN communications software is installed to the BHT. Before using any of them, you need to open the IrDA communications device file with OPEN "COM:" statement. Run-time errors: In the case of item #7 Error code Meaning 35h File not found (System reconfig file not found.) In the case of items #9 to #11 Error code Meaning 34h Bad file name or number (The communications device file is not opened.
.fcFontInf Get font information Syntax: CALL "SYSTEM.FN3" .fcFontInf N.FONT%,VERSION$() Description: This function returns font information--the number of downloaded fonts, font name, font size, and font version. Parameter: (None) Returned value: N.
Chapter 16. Extended Functions .fcCLkGet Get link status between the BHT and the LAN-support CU Syntax: CALL "SYSTEM.FN3" .fcCLkGet STATE% Description: This function returns the link status (STATE%) of the latest communication between the BHT and the LAN-support CU. Parameter: (None) Returned value: STATE% : Link status .syNgLk Link not established - No link has been established between the BHT and LAN-support CU.
.fcCMdRqst Place the LAN-support CU in system reconfiguration mode Syntax: CALL "SYSTEM.FN3" .fcCMdRqst Description: This function places the LAN-support CU in system reconfiguration mode. Parameter: (None) Returned value: (None) Note: You need to open the IrDA communications device file with OPEN "COM:" statement beforehand. Run-time errors: Error code Meaning 34h Bad file name or number (The communications device file is not opened.
Chapter 16. Extended Functions 16.3 Controlling the LCD and Touch Screen (CONSOLE.FN3) 16.3.1 Function Number List of CONSOLE.FN3. Function number Used to: .fcDot 1 Draw a dot .fcLine 2 Draw a full line .fcDtLine 3 Draw a dotted line .fcRectFil 4 Draw a filled rectangle .fcRect 5 Draw a rectangle .fcDotGet 6 Get drawn dot state .fcFKey 11 Set the number of function touch keys to be enabled .fcFKeyDsp 12 Set a character string to be displayed on a function touch key .
16.3.2 Detailed Function Specifications Draw a dot .fcDot Syntax: CALL "CONSOLE.FN3" .fcDot POINT%(),ATTRIB%, COLOR% Description: This function draws a dot on the X/Y coordinates specified by POINT%() according to the attributes specified by ATTRIB% and COLOR% on the LCD. Parameter: POINT% ATTRIB% COLOR% Coordinates to locate a dot POINT%(0) X-coordinate (0≤POINT%(0)≤199) POINT%(1) Y-coordinate (0≤POINT%(1)≤303) Drawing attributes* .cnColor 0 Draw a dot in the color specified by COLOR% .
Chapter 16. Extended Functions Draw a full line .fcLine Syntax: CALL "CONSOLE.FN3" .fcLine RECT%(),ATTRIB%, COLOR% Description: This function draws a full line between two points specified by RECT%() according to the attributes specified by ATTRIB% and COLOR% on the LCD.
.fcDtLine Draw a dotted line Syntax: CALL "CONSOLE.FN3" .fcDtLine RECT%(),PTN%, ATTRIB%,COLOR% Description: This function draws a dotted line specified by PTN% between two points specified by RECT%() according to the attributes specified by ATTRIB% and COLOR% on the LCD.
Chapter 16. Extended Functions Run-time errors: Error code Meaning 05h Parameter out of the range F0h Mismatch parameter number F1h Mismatch parameter type F2h Insufficient number of array variable elements Example: Drawing a dotted line starting at the coordinates (10, 30) to (100, 60) in black DIM RECT%(3) RECT%(0)=10 : RECT%(1)=30 : RECT%(2)=100 : RECT%(3)=60 PTN%=&HAAAA : ATTRIB%=.cnColor : COLOR%=.cnBlack CALL"CONSOLE.FN3".fcDtLine RECT%(),PTN%,ATTRIB%,COLOR% .
Parameter: RECT%() ATTRIB% Coordinates to define a rectangle RECT%(0) Initial X-coordinate (0≤RECT%(0)≤199) RECT%(1) Initial Y-coordinate (0≤RECT%(1)≤303) RECT%(2) Final X-coordinate (0≤RECT%(2)≤199) RECT%(3) Final Y-coordinate (0≤RECT%(3)≤303) Drawing attributes* .cnColor 0 Draw a line in the color specified by COLOR% .cnInvert 1 Draw a line in reverse display in the current color *COLOR% is valid only when "0" is set to ATTRIB%.
Chapter 16. Extended Functions .fcRect Draw a rectangle Syntax: CALL "CONSOLE.FN3" .fcRect RECT%(),ATTRIB%, COLOR% Description: This function draws a rectangle defined by two diagonal points specified by RECT%() according to the attributes specified by ATTRIB% and COLOR% on the LCD.
Run-time errors: Error code Meaning 05h Parameter out of the range F0h Mismatch parameter number F1h Mismatch parameter type F2h Insufficient number of array variable elements Example: Drawing a rectangle defined by two diagonal points (3, 3) and (94, 40) DIM RECT%(3) RECT%(0)=3 : RECT%(1)=3 : RECT%(2)=94 : RECT%(3)=40 ATTRIB%=.cnColor : COLOR%=.cnBlack CALL"CONSOLE.FN3".fcRect RECT%(),ATTRIB%,COLOR% .fcDotGet Get drawn dot state Syntax: CALL "CONSOLE.FN3" .
Chapter 16. Extended Functions Set the number of function touch keys to be enabled .fcFKey Syntax: CALL "CONSOLE.FN3" .fcFKey DATA% Description: This function sets the number of function touch keys specified by DATA%, to be enabled. Parameter: DATA% Returned value: Number of function touch keys .cnFKey0 0 0 (Disable all function touch keys) .cnFKey4 1 Enable 4 function touch keys .
ATTRIB% Returned value: Character attributes .cnW1H1 0 Regular-size .cnW2H1 1 Double-width .cnW1H2 2 Double-height .cnW2H2 3 Quadruple-size (None) Run-time errors: Error code Meaning 05h Parameter out of the range F0h Mismatch parameter number F1h Mismatch parameter type .fcUKey Create a user-defined touch key and set a character(s) to be displayed on the touch key Syntax: CALL "CONSOLE.FN3" .
Chapter 16. Extended Functions ATTRIB% Returned value: Character attributes .cnW1H1 0 Regular-size .cnW2H1 1 Double-width .cnW1H2 2 Double-height .cnW2H2 3 Quadruple-size (None) Run-time errors: Error code Meaning 05h Parameter out of the range (The initial coordinates are greater than the final coordinates. The specified area has been used by any other touch key.) F0h Mismatch parameter number F1h Mismatch parameter type F2h Insufficient number of array variable elements .
.fcPnlGet Get coordinates on the touch screen that is pressed last Syntax: CALL "CONSOLE.FN3" .fcPnlGet POINT%() Description: This function returns the coordinates that is pressed last. Parameter: (None) Returned value: POINT%() Coordinates to locate a dot POINT%(0) X-coordinate (0≤POINT%(0)≤199) POINT%(1) Y-coordinate (0≤POINT%(1)≤303) Run-time errors: Error code Meaning F0h Mismatch parameter number F1h Mismatch parameter type F2h Insufficient number of array variable elements .
Chapter 16. Extended Functions 16.4 Controlling system files (SYSMDFY.FN3) 16.4.1 Function Number List of SYSMDFY.FN3 The SYSMDFY.FN3 may reconfigure the BHT system or LAN-support CU system, as well as getting/setting system reconfig file information, depending upon the function number specified, as listed below. Function number Used to: .fcMdBVGet 1 Get version of BHT system reconfig file .fcMdBDo 2 Reconfigure BHT system .fcMdBNGet 3 Get filename of BHT system reconfig file .
16.4.2 Detailed Function Specifications .fcMdBVGet Get version of BHT system reconfig file Syntax: CALL "SYSMDFY.FN3" .fcMdBVGet FILE$, VERSION$ Description: This function returns the version (VERSION$) of the BHT system reconfig file specified by FILE$. Parameter: FILE$ Returned value: VERSION$ Version, 4 characters fixed Filename Run-time errors: Error code Meaning 32h File type mismatch .fcMdBDo Reconfigure BHT system Syntax: CALL "SYSMDFY.FN3" .
Chapter 16. Extended Functions .fcMdBNGet Get filename of BHT system reconfig file Syntax: CALL "SYSMDFY.FN3" .fcMdBNGet FILE$ Description: This function returns the filename of the BHT system reconfig file to be used in System Mode, in FILE$. Parameter: FILE$ Returned value: (None) .fcMdBNSet Filename consisting of drive name and file name, max. 14 characters (No drive name might be returned.) Set filename of BHT system reconfig file Syntax: CALL "SYSMDFY.FN3" .
.fcMdCDo Reconfigure CU system Syntax: CALL "SYSMDFY.FN3" .fcMdCDo FILE$ Description: This function reconfigures the LAN-support CU system by using the LAN-support CU system reconfig file specified by FILE$. Parameter: FILE$ Returned value: (None) Note: Before using this function, you need to (1) open the IrDA communications device file with OPEN "COM:" statement and (2) place the LAN-support CU in system reconfiguration mode with the CALL "SYSTEM.FN3" .fcCMdRqst statement.
Chapter 16. Extended Functions 16.5 Calculating a CRC (CRC.FN3) 16.5.1 Function Number List of CRC.FN3 The CRC.FN3 may calculate a CRC depending upon the function number specified, as listed below. Function number Used to: .fcCcitt 2 Calculate a CRC-CCITT. .fcCrc16 3 Calculate a CRC-16. 16.5.2 Detailed Function Specifications .fcCcitt Calculate a CRC-CCITT Syntax: CALL "CRC.FN3" .fcCcitt STRING1$, [ STRING2$, [...
.fcCrc16 Calculate a CRC-16 Syntax: CALL "CRC.FN3" .fcCrc16 STRING1$, [ STRING2$, [...,]] CRC$ Description: This function calculates a CRC of character strings specified by STRING1$, STRING2$, ...STRING8$ and returns the calculation result in CRC$. Up to eight character strings may be specified by assigning them to non-array string variables. Parameter: STRING1$, STRING2$, ...
Chapter 17 Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) CONTENTS 17.1 Overview...................................................................................................... 418 17.2 Programming for Spread Spectrum Communication ................................... 420 17.3 Spread Spectrum Communications-related Statement ............................... 421 17.4 Spread Spectrum Communication Library (SS.FN3)................................... 422 17.4.
17.1 Overview ■ Spread spectrum communications device The BHT system consists of BHT main system and the spread spectrum communications device; the former executes user programs and the latter performs spread spectrum communications. User programs use the logical device file (named "COM3") to control the spread spectrum communications device.
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) The table below shows the communications status transition as the state of the spread spectrum communications device built in the BHT changes.
17.2 Programming for Spread Spectrum Communication When programming for spread spectrum communication, use the following statement and extension functions: (1) OPEN statement (OPEN "COM3:") Refer to Section 17.3, "Spread Spectrum Communications-related Statement." (2) Spread spectrum library (SS.FN3) for controlling the spread spectrum communications device Refer to Section 17.4, "Spread Spectrum Communication Library (SS.FN3)." (3) Socket library (SOCKET.
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) 17.3 Spread Spectrum Communications-related Statement OPEN "COM3:" Open a spread spectrum communications device file Syntax: OPEN "COM3:" AS [#]filenumber Description: This statement opens a spread spectrum communications device file. A spread spectrum communications device file cannot be opened with an IrDA interface device file concurrently.
17.4 Spread Spectrum Communication Library (SS.FN3) 17.4.1 Overview The spread spectrum communication library (SS.FN3) used in a BHT-BASIC CALL statement reads or writes parameter values from/to the spread spectrum wireless block. If spread spectrum communication is frequent, a run-time error may occur when you set or refer to spread spectrum-related parameters. In such a case, set or refer to them again. ■ Function Number List of SS.FN3 Function number Used to: .
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) 17.4.2 Detailed Function Specifications .fcParaIGet Read integer from the wireless block parameter Syntax: CALL "SS.FN3" .fcParaIGet PARA%,DATA% Description: This function reads integer (DATA%) from the wireless block setting specified by PARA%. Parameters: PARA% Item number Returned value: DATA% Integer read from the specified wireless block setting Correspondence table: Item number (PARA%) .
.fcParaSGet Read string from the wireless block parameter Syntax: CALL "SS.FN3" .fcParaSGet PARA%,DATA$ Description: This function reads string (DATA$) from the wireless block setting specified by PARA%. Parameters: PARA% Item number Returned value: DATA$ String read from the specified wireless block setting Correspondence table: Item number (PARA%) Wireless block parameter Parameter value (DATA$) .ssFWVerGet 1 Wireless block firmware version Character string, 4 bytes .
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) .fcParaISet Write integer to the wireless block parameter Syntax: CALL "SS.FN3" .fcParaISet PARA%,DATA% Description: This function writes integer (DATA%) to the wireless block setting specified by PARA%. Parameters: PARA% Item number Returned value: DATA% Integer to be written to the specified wireless block setting Correspondence table: Item number (PARA%) .
.fcParaSSet Write string to the wireless block parameter Syntax: CALL "SS.FN3" .fcParaSSet PARA%,DATA$ Description: This function writes string (DATA$) to the wireless block setting specified by PARA%. Parameters: PARA% Item number Returned value: DATA$ String to be written to the specified wireless block setting Correspondence table: Item number (PARA%) .
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) .fcSyncInf Check wireless block synchronization with master Syntax: CALL "SS.FN3" .fcSyncInf TIMEOUT%,ASSOC% Description: This function checks whether the wireless block is synchronized with the master.
Chapter 18 TCP/IP (BHTs with spread spectrum communications device or BHTs designed for LAN-support software) CONTENTS 18.1 Two Sides .................................................................................................... 430 18.1.1 BHT .................................................................................................. 430 18.1.2 Hosts ................................................................................................ 430 18.2 TCP/IP over Spread Spectrum System .....
Chapter 18. TCP/IP 18.5 FTP Client.................................................................................................... 459 18.5.1 Overview .......................................................................................... 18.5.2 File Formats ..................................................................................... [ 1 ] User Programs (*.PD3) ........................................................... [ 2 ] Extension Libraries (*.FN3 and *.EX3) ...........................
18.1 Two Sides 18.1.1 BHT The BHT equipped with a spread spectrum communications device or IrDA communications device includes two built-in libraries providing BHT-BASIC programs with access to a subset of the TCP/IP family of protocols over the spread spectrum communication system or IrDA communication system, respectively. SOCKET.FN3: This library implements a subset of the BSD4.4 socket application program interface (API). FTP.FN3: 18.1.
Chapter 18. TCP/IP 18.2 TCP/IP over Spread Spectrum System 18.2.1 General Procedure The following is the procedure for using TCP/IP over a spread spectrum communications device. [ 1 ] Configure Spread Spectrum Communications Device To connect to the spread spectrum communications pathway, specify the following system settings in System Mode or by using the extension library SS.FN3 in a user program: • Domain • Security ID For the procedure in System Mode, refer to the BHT User’s Manual.
[ 2 ] Configure TCP/IP System To connect to the TCP/IP pathway, specify the following system settings in System Mode or by using the extension library SOCKET.FN3 in a user program: • IP address • Subnet mask • Default gateway These settings will be used in [ 6 ]. For the procedure in System Mode, refer to the BHT User’s Manual. For the details of the SOCKET.FN3, refer to Section 18.6, "Socket Library (SOCKET.FN3)." Given below is a setting example with SOCKET.FN3: my.addr$ = "192.168.0.
Chapter 18. TCP/IP [ 3 ] Declare TCP/IP Communications Pathway Specify the following system settings by using the socket library (SOCKET.FN3): • Communications device: Spread spectrum communications device • Link layer: Ethernet For the setting procedure with the SOCKET.FN3, refer to Section 18.6, "Socket Library (SOCKET.FN3)." Given below is a setting example using SOCKET.FN3: iftype% = 2 layermode% = 2 ’Specify spread spectrum communications device ’Specify Ethernest as a link layer call "socket.
[ 5 ] Check Spread Spectrum Communications Device Synchronization with Master Using a spread spectrum communications device for TCP/IP communication requires synchronizing with the master (e.g., access point). To check the synchronization, use the extension library SS.FN3.
Chapter 18. TCP/IP [ 6 ] Connect to TCP/IP Communications Pathway Use the extension library SOCKET.FN3. Connecting to the TCP/IP communications pathway requires the following settings (specified in [ 2 ]): • IP address • Subnet mask • Default gateway There are two ways to specify these parameters. (a) Use the system settings with the extension library SOCKET.FN3. Refer to Section 18.6, "Socket Library (SOCKET.FN3)." Given below is an example using SOCKET.FN3. call "socket.fn3" .
[ 8 ] Disconnect TCP/IP Communications Pathway Use the extension library SOCKET.FN3. Refer to Section 18.6, "Socket Library (SOCKET.FN3)." Given below is an example using SOCKET.FN3. Call "socket.fn3" .fcTDiscnn interface% ’Disconnect TCP/IP communications ’pathway (SOCKET.FN3 function #43) ’Use the returned value of [3] in ’interface%. [ 9 ] Close Spread Spectrum Communications Device Use the CLOSE statement in BHT-BASIC. Closing the device will power off the wireless block.
Chapter 18. TCP/IP 18.2.2 Programming Notes for Socket API According to UDP The user datagram protocol (UDP) has no flow control, so send/receive data may go missing due to poor line conditions or difference of communications capabilities between wireless and Ethernet. To prevent data missing, be sure to incorporate some flow control process into user programs at both the BHT and host. Given below are message transmission examples that support retransmission controls at each of the BHT and host.
■ Host’s retransmission control for a transmission error Assume that the host uses the protocol of receiving transmission completion message from the BHT after sending a message. If the host times out for waiting a transmission completion message, it will transmit the unsent message again.
Chapter 18. TCP/IP 18.2.3 Programming Notes for TCP/IP Communication If TCP/IP communication becomes no longer possible during data transmission, any of the following run-time errors will be returned: Run-time errors: ■ Error code Meaning 105h Power-off detected. (The BHT has been turned off during data transmission and then turned on. The communications device remains off.) 106h An internal error has occurred in the TCP/IP module during data transmission.
■ Note for run-time error 105h Socket close processing (SOCKET.FN3, Function #28) following occurrence of run-time error 105h would not complete immediately. This is because a FIN packet will be transmitted repeatedly in the socket close processing until the communications device receives any response from the server independent of the power on/off state of the communications device.
Chapter 18. TCP/IP 18.2.4 Sample Program main: on error goto Err.TCP .. . open "COM3:" as #hCom3% .. . sock.stts% = 1 .. . call "socket.fn3" .fcTCnnSys interface% ’ Main program ’ Prepare for error interrupt (To Err.TCP ’ at the time of error occurrence) ’ Open a spread spectrum communications device ’ Use the OPEN "COM3:" statement ’ Set "1" to socket processing number ’ Connect TCP/IP communications pathway ’ (system settings) ’ Use SOCKET.FN3 function #41 .. . sock.
18.3 TCP/IP over IrDA Communication System 18.3.1 General Procedure The following is the procedure for using TCP/IP over an IrDA communications device. [ 1 ] Configure IrDA Communications Device for LAN-Support System To communicate with the LAN-support CU, specify the following system settings in System Mode or by using the extension library SYSTEM.
Chapter 18. TCP/IP [ 2 ] Configure TCP/IP System To connect to the TCP/IP pathway, specify the following system settings in System Mode or by using the extension library SOCKET.FN3 in a user program: • IP address • Subnet mask • Default gateway These settings will be used in [ 5 ]. For the procedure in System Mode, refer to the BHT User’s Manual. For the details of the SOCKET.FN3, refer to Section 18.6, "Socket Library (SOCKET.FN3)." Given below is a setting example with SOCKET.FN3: my.addr$ = "192.168.
[ 3 ] Declare TCP/IP Communications Pathway Specify the following system settings by using the socket library (SOCKET.FN3): • Communications device: IrDA communications device • Link layer: Ethernet For the setting procedure with the SOCKET.FN3, refer to Section 18.6, "Socket Library (SOCKET.FN3)." Given below is a setting example using SOCKET.FN3: iftype% = 2 layermode% = 2 ’Specify IrDA communications device ’Specify Ethernet as a link layer call "socket.fn3" .
Chapter 18. TCP/IP [ 5 ] Connect to TCP/IP Communications Pathway Use the extension library SOCKET.FN3. Connecting to the TCP/IP communications pathway requires the following settings (specified in [ 2 ]): • IP address • Subnet mask • Default gateway There are two ways to specify these parameters. (a) Use the system settings with the extension library SOCKET.FN3. Refer to Section 18.6, "Socket Library (SOCKET.FN3)." Given below is an example using SOCKET.FN3. call "socket.fn3" .
[ 7 ] Disconnect TCP/IP Communications Pathway Use the extension library SOCKET.FN3. Refer to Section 18.6, "Socket Library (SOCKET.FN3)." Given below is an example using SOCKET.FN3. Call "socket.fn3" .fcTDiscnn interface% ’Disconnect TCP/IP communications ’pathway (SOCKET.FN3 function #43) ’Use the returned value of [3] in ’interface%. [ 8 ] Close IrDA Communications Device Use the CLOSE statement in BHT-BASIC. Closing the device will power off the IrDA communications device.
Chapter 18. TCP/IP 18.3.2 Programming Notes for Socket API According to UDP Refer to Subsection 18.2.2. 18.3.3 Programming Notes for TCP/IP Communication When using an IrDA communications device, observe same programming notes as those given for a spread spectrum communications device. Refer to Subsection 18.2.3. For details, refer to Subsection 18.3.4, "Sample Program.
18.3.4 Sample Program Given below is a sample program that shows only the skeleton of communication program and requires modification in actual programming as necessary. ’**************************************** ’ Data Section * ’**************************************** DIM RECVBUFF$[255] ’Receive data buffer DIM SENDBUFF$[255] ’Send data buffer DIM IPADDRESS$[15] ’IP address DIM R.SOCKSET$[41] ’Read socket ID set DIM W.SOCKSET$[41] ’Write socket ID set DIM E.
Chapter 18. TCP/IP TCP.STTS% = 3 ’Convert IP address <----- Equivalent to BSD4.4 socket API inet_addr() function IPADDRESS$ = "192.100.100.001" ’Specify server IP address CALL "SOCKET.FN3" .fcINetAdr IPADDRESS$, ADDRESS ’Connect socket to server <----- Equivalent to BSD4.4 socket API connect() function PORT% = 1201 ’Specify server port CALL "SOCKET.FN3" .fcConnect SOCKFD%, FAMILY%, PORT%, ADDRESS ’Transmit data <----- Equivalent to BSD4.
TCP.STTS% = 2 ’Disconnect TCP/IP communications pathway CALL "SOCKET.FN3" .fcTDiscnn INTERFACE% TCP.STTS% = 1 ’Close IrDA communications device CLOSE #1 TCP.STTS% = 0 ON ERROR GOTO 0 RETURN ’************************************************ ’ Error-handling routine * ’************************************************ TCP.ERR: WERR = ERR RESUME ERRSUB ERRSUB: ON ERROR GOTO 0 ON ERROR GOTO ERRSUB2 IF TCP.STTS% > 2 THEN CALL "SOCKET.FN3" .fcClose SOCKFD% END IF ’Close socket IF TCP.STTS% > 1 THEN CALL "SOCKET.
Chapter 18. TCP/IP 18.4 Socket API 18.4.1 Overview The SOCKET.FN3 library implements a subset of the BSD4.4 socket application program interface (API). The following flowcharts show the BSD4.4 socket API calls for the two communications protocols required for the TCP/IP transport layer: transmission control protocol (TCP) for streams and user datagram protocol (UDP) for datagrams.
■ User Datagram Protocol (UDP) Client Server socket() socket() bind() bind() (listen ()) sendto() select() select() recvfrom() recvfrom() sendto() close() close() 452
Chapter 18. TCP/IP 18.4.2 Client Program Samples for Socket API According to TCP and UDP This section gives TCP and UDP client program samples. With ON ERROR GOTO statement, you may trap errors if happened during execution of functions used in these samples. These samples show only the skeleton of communication programs and require modification in actual programming as necessary.
’Initialize socket identifier set ’<----- Equivalent to BSD4.4 socket API FD_ZERO macro CALL "SOCKET.FN3" .fcFDZERO R.SOCKSET$ ’Initialize CALL "SOCKET.FN3" .fcFDZERO W.SOCKSET$ ’Initialize ’set CALL "SOCKET.FN3" .fcFDZERO E.SOCKSET$ ’Initialize ’identifier read socket identifier set write socket identifier exception socket set ’Add socket identifier to read socket identifier set ’<----- Equivalent to BSD4.4 socket API FD_SET macro CALL "SOCKET.FN3" .fcFDSET SOCKFD%, R.
Chapter 18. TCP/IP ■ UDP client program (non-connection type) (Example) ’**************************************** ’ Data Section * ’**************************************** DIM RECVBUFF$[255] ’Receive data buffer DIM SENDBUFF$[255] ’Send data buffer DIM IPADDRESS$[15] ’IP address DIM R.SOCKSET$[41] ’Read socket ID set DIM W.SOCKSET$[41] ’Write socket ID set DIM E.
’Add socket identifier to the read socket identifier set ’<----- Equivalent to BSD4.4 socket API FD_SET macro CALL "SOCKET.FN3" .fcFDSET SOCKFD%, R.SOCKSET$ ’Wait for changes in socket identifier set (read condition) ’< ----- Equivalent to BSD4.4 socket API select () function MAXFD% = SOCKFD% +1 ’Specify number of socket identifiers TIMEOUT = 360 ’Specify 6-minute (360-second) timeout CALL "SOCKET.FN3" .fcSelect MAXFD%, R.SOCKSET$, W.SOCKSET$, E.
Chapter 18. TCP/IP 18.4.3 Programming Notes for Socket API Socket API according to the TCP/IP is restricted by the following specifications. For the extended function SOCKET.FN3 given below, refer to Section 18.6, "Socket Library (SOCKET.FN3)." (1) After closed, the TCP socket will retain data for 60 seconds to keep the current status. For the 60 seconds, therefore, the socket cannot be used again. (2) SOCKET.FN3 function #26 may create a maximum of 64 sockets.
sendlen%=255 sendmode%=0 call "socket.fn3" .fcSend sockfd%, sendbuff$, sendlen%, sendmode%, sendsize% ’Transmit data ’Use SOCKET.FN3 function #22 recvlen%=255 recvmode%=0 call "socket.fn3" .fcRecv sockfd%, recvbuff$, recvlen%, recvmode%, recvsize% ’Receive data ’Use SOCKET.FN3 function #14 call "socket.fn3" .fcClose sockfd% ’Close socket ’Use SOCKET.FN3 function #28 call "socket.fn3" .fcTDiscnn interface% ’Disconnect TCP/IP communications ’pathway ’Use SOCKET.
Chapter 18. TCP/IP 18.5 FTP Client 18.5.1 Overview The FTP.FN3 library implements FTP client services for file transfers to and from FTP servers. Note that there are no server capabilities. This FTP client transfers files between operating systems in image (binary) format. The only translation support is for line delimiter conversion. Note that this FTP client does not convert between such double-byte character encodings as Shift JIS and EUC.
The FTP client automatically pads the last record of a downloaded program file with null codes (00h) to maintain the fixed-length format. (The number required is 128 less the number of bytes in the last record). Record length (128 bytes) CR LF CR LF CR LF Download Record length (128 bytes) Zeros Aside: To conserve memory and boost performance, the BHT packs a pair of ASCII bytes into a single byte by converting each byte into a 4-bit hexadecimal number.
Chapter 18. TCP/IP [ 2 ] Extension Libraries (*.FN3 and *.EX3) The FTP client treats files with extensions .FN3 and .EX3 as extension libraries. Extension libraries use a fixed record length of 130 bytes for all records except the last. These records are separated with line delimiters. Record length (130 bytes) Record CR LF CR LF Program code CR LF CR LF CR LF CR LF The FTP client automatically pads the last record of a downloaded program file with null codes (00h) to maintain the fixed-length format.
[ 3 ] Data Files The FTP client treats files with extensions other than .PD3, .FN3, and .EX3 as data files. Data file records consist of fields separated with line delimiters. An EOF (1Ah) at the end of the data file is optional. Data files are not limited to ASCII characters. They can use all bytes codes from 00h to FFh. Record length Record Field 1 Field 2 Field n CR LF CR LF CR LF CR LF CR LF EOF (optional) There can be 1 to 16 fields, each 1 to 254 bytes long.
Chapter 18. TCP/IP The treatment of short records is under application control. The default is to delete any trailing spaces (20h). Specified record length Record 1 Record 2 Record 3 CR LF ← Specified length ← Short CR LF Spaces CR LF ← Short, with trailing spaces Specified record length Record 1 ← As is Record 2 ← As is ← Truncated further Record 3 Alternatively, the FTP client can pad such short records to the specified record length with spaces (20h).
Line delimiters inside data records The FTP client can send and receive all codes from 00h to FFh as described above. The treatment of line delimiters (CR-LF, CR, or LF) inside downloaded data records is under application control. The default is to split the incoming stream into short records.
Chapter 18. TCP/IP 18.5.3 Using FTP Client [ 1 ] Basic Procedure First, set up for using the FTP client, as necessary, with the following steps. All three are optional, but the last two are highly recommended for downloads. (1) Configure the FTP client with the extension library FTP.FN3. (2) Use the FRE function to check whether there is sufficient free memory available to hold the downloaded file. (3) Use a BHT-BASIC OUT statement to optimize the drive.
[ 3 ] Calculating Memory Requirements The FTP protocol specifications do not provide for checking the amount of BHT memory available during downloads. If the BHT runs out of memory during a download, the FTP client cancels the transfer and deletes the partially downloaded file. The user application program must, therefore, check availability with the FRE function or equivalent method and compare the result with the BHT file size (BFS) before using the download function.
Chapter 18. TCP/IP ■ Data Files Determine MEM from the field lengths and number of records. BPR = bytes per record = (number of fields) + (sum of field lengths) RPB = records per block = ROUND_DOWN (4096 ÷ BPR) MEM = ROUND_UP (records ÷ RPB) × 4096 Example: File with 1000 records with four fields of lengths 13, 12, 6, and 1 BPR = 4 + (13 + 12 + 6 + 1) = 36 RPB = ROUND_DOWN (4096 ÷ 36) = ROUND_DOWN (113.778) = 113 MEM = ROUND_UP (1000 ÷ 113) × 4096 = ROUND_UP (8.
18.6 Socket Library (SOCKET.FN3) 18.6.1 ■ Overview String Variables The following are the string variables used by this library together with their memory requirements. Description ■ Variable name Size in bytes Internet address IPADDRESS$ min. 15 Subnet mask SUBNETMASK$ min. 15 Default gateway GATEWAY$ min. 15 Receive buffer RECVBUFF$ 1 to 255 Transmit buffer SENDBUFF$ 1 to 255 Socket identifier set SOCKFDSET$ READFDSET$ WRITEFDSET$ EXCEPTFDSET$ min. 41 min. 41 min. 41 min.
Chapter 18. TCP/IP ■ Function Number List Number Used to: Corresponding Socket API Function .fcAccept 1* –– accept() .fcBind 2 Assign address to socket bind() .fcConnect 3 Connect socket connect() .fcGPName 4* –– getpeername() .fcGSName 5* –– getsockname() .fcGSckOpt 6 Get socket option getsockopt() .fcHToNL 7 Convert host long (4 bytes) to network byte order htonl() .fcHToNS 8 Convert host short (2 bytes) to network byte order htons() .
Number Used to: Corresponding Socket API Function .fcSocket 26 Create socket socket() .fcWritev 27* –– writev() .fcClose 28 Close socket close() .fcTSetup 40 Specify TCP/IP communications pathway Unique to BHT .fcTCnnSys 41 Connect TCP/IP communications pathway with system settings Unique to BHT .fcTCnnUsr 42 Connect TCP/IP communications pathway with user settings Unique to BHT .fcTDiscnn 43 Disconnect TCP/IP communications pathway Unique to BHT .
Chapter 18. TCP/IP 18.6.2 Detailed Function Specifications Assign address to socket .fcBind Syntax: CALL "SOCKET.FN3" .fcBind SOCKFD%, FAMILY%, PORT%, address where address is ADDRESS or IPADDRESS$ Description: This function assigns an address to the specified socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API bind() function.
Connect socket .fcConnect Syntax: CALL "SOCKET.FN3" .fcConnect SOCKFD%, FAMILY%, PORT%, address where address is ADDRESS or IPADDRESS$ Description: This function connects the specified socket identifier to another socket. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API connect() function.
Chapter 18. TCP/IP Get socket option .fcGSckOpt Syntax: CALL "SOCKET.FN3" .fcGSckOpt SOCKFD%, OPTNAME%, option where option is OPTION% or OPTION Description: This function gets the specified option setting for the specified socket. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API getsockopt() function.
.fcHToNL Convert host long (4 bytes) to network byte order Syntax: CALL "SOCKET.FN3" .fcHToNL HOSTLONG, NETLONG Description: This function converts a (4-byte) long from host byte order to network byte order. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API htonl() function. Parameters: HOSTLONG Long in host byte order Return value: NETLONG Long in network byte order .fcHToNS Convert host short (2 bytes) to network byte order Syntax: CALL "SOCKET.FN3" .
Chapter 18. TCP/IP .fcNToHS Convert network short (2 bytes) to host byte order Syntax: CALL "SOCKET.FN3" .fcNToHS NETSHORT%, HOSTSHORT% Description: This function converts a (2-byte) short from network byte order to host byte order. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API ntohs() function. Parameters: NETSHORT% Short in network byte order Return value: HOSTSHORT% Short in host byte order .
Run-time errors: Error code Example: Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 209h Socket identifier is invalid. 216h A parameter is invalid. 228h The maximum number of bytes to receive is too small. 236h An RST from the opposite end has forced disconnection.
Chapter 18.
Example: Overwrite operation Incoming data: 1024 bytes ("0123456789..........
Chapter 18. TCP/IP .fcRcvfrom Syntax: Receive data sent to the specified UDP socket CALL "SOCKET.FN3" .fcRcvfrom SOCKFD%, RECVBUFF$[()], RECVLEN%, RECVMODE%, FAMILY%, PORT%, address, RECVSIZE% [,RECVFLAG%] where address is ADDRESS or IPADDRESS$ Description: This function receives data sent to the UDP socket specified by the socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API recvfrom() function.
Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 209h Socket identifier is invalid. 216h A parameter is invalid. 228h The maximum number of bytes to receive is too small. 229h TCP is the wrong protocol here. 237h There is insufficient system area memory.
Chapter 18. TCP/IP Monitor socket requests .fcSelect Syntax: CALL "SOCKET.FN3" .fcSelect MAXFD%, READFDSET$, WRITEFDSET$, EXCEPTFDSET$, TIMEOUT, RESULT% Description: This function waits for changes in the socket identifier sets (read, write, and exception conditions) for the specified socket identifiers. The only exception condition is out of band data. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API select() function.
.fcFDZERO Initialize socket identifier set Syntax: CALL "SOCKET.FN3" .fcFDZERO SOCKFDSET$ Description: This function initializes the specified socket identifier set. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API FD_ZERO macro. Parameters: SOCKFDSET$ Return value: (None) .fcFDSET Socket identifier set Add socket identifier to socket identifier set Syntax: CALL "SOCKET.FN3" .
Chapter 18. TCP/IP .fcFDISSET Get socket identifier status from socket identifier set Syntax: CALL "SOCKET.FN3" .fcFDISSET SOCKFD%, SOCKFDSET$, FDISSET% Description: This function gets the status of the specified socket identifier in the specified socket identifier set. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API FD_ISSET macro.
Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 209h Socket identifier is invalid. 216h A parameter is invalid. 228h The maximum number of bytes to receive is too small. 237h There is insufficient system area memory. 239h The specified socket is not connected.
Chapter 18. TCP/IP Send message to another UDP socket .fcSendto Syntax: CALL "SOCKET.FN3" .fcSendto SOCKFD%, SENDBUFF$[()], SENDLEN%, SENDMODE%, FAMILY%, PORT%, address, SENDSIZE% where address is ADDRESS or IPADDRESS$ Description: This function transmits data from the specified buffer to the IP address and port number connected to the specified socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API sendto() function.
Set socket options .fcSSckOpt Syntax: CALL "SOCKET.FN3" .fcSSckOpt SOCKFD%, OPTNAME%, option where option is OPTION% or OPTION Description: This function sets the specified option for the specified socket to the new value. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API setsockopt() function.
Chapter 18. TCP/IP Shut down socket .fcShutdwn Syntax: CALL "SOCKET.FN3" .fcShutdwn SOCKFD%, HOWTO% Description: This function shuts down socket transfers in the specified direction. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API shutdown() function. Parameters: SOCKFD% HOWTO% Socket identifier Direction specification The direction specification (HOWTO%) must be one of the following values: Return value: .soSdRecv 0 Receive .soSdSend 1 Transmit .
Create socket .fcSocket Syntax: CALL "SOCKET.FN3" .fcSocket FAMILY%, TYPE%, PROTOCOL%, SOCKFD% Description: This function creates a socket from the specified protocol family, socket type, and protocol layer and assigns it to a socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API socket() function.
Chapter 18. TCP/IP Close socket .fcClose Syntax: CALL "SOCKET.FN3" .fcClose SOCKFD% Description: This function closes the specified socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API close() function. Parameters: SOCKFD% Return value: (None) Socket identifier Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission.
Specify TCP/IP communications pathway .fcTSetup Syntax: CALL "SOCKET.FN3" .fcTSetup IFTYPE%, LAYERMODE%, INTERFACE% Description: This function specifies the TCP/IP communications pathway from the specified communications device and link layer. Parameters: IFTYPE% LAYERMODE% Communications device Link layer The communications device (IFTYPE%) must be one of the following values: .soDvCOM1 0 COM1 (IrDA communications device) For IrDA communication via the LANsupport CU .
Chapter 18. TCP/IP Connect TCP/IP communications pathway with system settings .fcTCnnSys Syntax: CALL "SOCKET.FN3" .fcTCnnSys INTERFACE% Description: This function connects the TCP/IP communications pathway based on the system settings.
Connect TCP/IP communications pathway with user settings .fcTCnnUsr Syntax: CALL "SOCKET.FN3" .fcTCnnUsr INTERFACE%, IPADDRESS$, SUBNETMASK$, GATEWAY$ Description: This function connects the TCP/IP communications pathway based on the supplied user settings.
Chapter 18. TCP/IP Disconnect TCP/IP communications pathway .fcTDiscnn Syntax: CALL "SOCKET.FN3" .fcTDiscnn INTERFACE% Description: This function disconnects the specified TCP/IP communications pathway. Parameters: INTERFACE% Return value: (None) Communications pathway Run-time errors: Error code Meaning 104h Communications pathway already disconnected 105h Power-off detected 216h A parameter is invalid. 503h The CU has been linked with any other BHT.
Set TCP/IP system settings .fcTSysSet Syntax: CALL "SOCKET.FN3" .fcTSysSet PARA%, data where data is DATA% or DATA$ Description: This function sets the specified TCP/IP system settings to the new value. Parameters: PARA% data Return value: (None) Item number New setting for TCP/IP system settings (DATA%/DATA$) Correspondence tables: See Table under function #44. Get TCP socket status .fcTStsGet Syntax: CALL "SOCKET.FN3" .
Chapter 18. TCP/IP 18.7 FTP Library (FTP.FN3) 18.7.1 ■ Overview String Variables The following are the string variables used by this library together with their memory requirements. Description Variable name Size in bytes Server IP address SERV.IP 15 Login user name USERNAME$ 0 to 16 Login password PASSWORD$ 0 to 16 Directory names CURDIR$ NEWDIR$ 0 to 255 0 to 255 File names SERV.FNAME$ CLNT.FNAME$ OLD.FNAME$ NEW.
■ Reply Codes The messages that FTP servers send during and after FTP operations vary, but servers all use the same reply codes. (See Table.) All function numbers therefore supply these as their return value (REPLY%). Reply Codes Description 110 Restart marker replay. 120 Service ready in nnn minutes. 125 Data connection already open; transfer starting. 150 File status okay; about to open data connection. 200 Command okay. 202 Command not implemented, superfluous at this site.
Chapter 18. TCP/IP Reply Codes Description 426 Connection closed; transfer aborted. 450 Requested file action not taken. File unavailable (e.g., file busy). 451 Requested action aborted: local error in processing. 452 Requested action not taken. Insufficient storage space in system. 500 Syntax error, command unrecognized. This may include errors such as command line too long. 501 Syntax error in parameters or arguments. 502 Command not implemented. 503 Bad sequence of commands.
18.7.2 Detailed Function Specifications Open FTP client session with system settings .fcFTPOpnS Syntax: CALL "FTP.FN3" .fcFTPOpnS FTPHANDLE%, REPLY% Description: This function opens an FTP client session using the system settings.
Chapter 18. TCP/IP Open FTP client session with user settings .fcFTPOpnU Syntax: CALL "FTP.FN3" .fcFTPOpnU FTPHANDLE%, SERV.IP$, USERNAME$, PASSWORD$, REPLY% Description: This function opens an FTP client session based on the supplied user settings. Parameters: SERV.
Close FTP client session .fcFTPClos Syntax: CALL "FTP.FN3" .fcFTPClos FTPHANDLE%, REPLY% Description: This function closes the specified FTP client session. Parameters: FTPHANDLE% FTP client handle Return value: REPLY% Server response to FTP command Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated.
Chapter 18. TCP/IP Get current directory on FTP server .fcPWD Syntax: CALL "FTP.FN3" .fcPWD FTPHANDLE%, CURDIR$, REPLY% Description: This function gets the current directory on the FTP server. Parameters: FTPHANDLE% FTP client handle Return value: CURDIR$ REPLY% FTP server current directory Server response to FTP command Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission.
Change current directory on FTP server .fcCWD Syntax: CALL "FTP.FN3" .fcCWD FTPHANDLE%, NEWDIR$, REPLY% Description: This function changes the current directory on the FTP server. Parameters: FTPHANDLE% NEWDIR$ FTP client handle New directory Return value: REPLY% Server response to FTP command Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated.
Chapter 18. TCP/IP .fcRETR Download file from FTP server Syntax: CALL "FTP.FN3" .fcRETR FTPHANDLE%, SERV.FNAME$, CLNT.FNAME$, CRLF.TYPE%, CRLF.MODE%, REPLY% [,FLD$] [,DISP.MODE%] Description: This function downloads, from the current directory on the FTP server to the BHT, the specified file using the specified parameters. Parameters: FTPHANDLE% SERV.FNAME$ CLNT.FNAME$ FTP client handle Name of file to download from FTP server Name for file on handy terminal.
FLD$ Field lengths in bytes. Delimit the field length specifications with commas (,) or semicolons (;). (This parameter applies only to downloaded data files.) " [,,... ]" (n=1 to 16, field length = 1 to 254) DISP.MODE% Flag controlling a progress display consisting of an 8digit number giving the number of bytes transferred .ftNotDisp 0 Disable .
Chapter 18. TCP/IP Run-time errors: Error code Meaning 02h Syntax error (Incorrect file name) 05h Number of field items or number of digits in a field out of the range 07h Insufficient memory space 32h Wrong file type 33h Invalid text received 37h File already open 39h Too many files 3Ch Record exceeds 255 bytes. 3Dh Field mismatch error 41h File damaged 47h User break with cancel (C) key 49h Invalid program file received (Invalid program size.
.fcSTOR Upload file to FTP server Syntax: CALL "FTP.FN3" .fcSTOR FTPHANDLE%, SERV.FNAME$, CLNT.FNAME$, CRLF.TYPE%, UP.MODE%, REPLY% [,DISP.MODE%] Description: This function uploads, from the BHT to the current directory on the FTP server, the specified file using the specified parameters. Parameters: FTPHANDLE% SERV.FNAME$ CLNT.FNAME$ CRLF.TYPE% UP.MODE% FTP client handle Name for file on FTP server. Leaving this unspecified ("") uses the name in CLNT.FNAME$ instead.
Chapter 18. TCP/IP Run-time errors: Error code Meaning 35h File not found 37h File already open 47h User break with cancel (C) key 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 110h Response other than 2XX received 111h File not closed 216h The FTP client handle is invalid.
Get FTP system settings .fcFSysGet Syntax: CALL "FTP.FN3" .fcFSysGet PARA%, ftp.para where ftp.para is FTP.PARA% or FTP.PARA$ Description: This function gets the current setting for the specified FTP system settings. Parameters: PARA% Item number Return value: ftp.para Current setting for FTP system settings of type integer/ string (FTP.PARA%/FTP.PARA$) Correspondence tables: Item number (PARA%) Description Values for Setting (FTP.PARA%) .ftCRLFTyp 5 Line delimiter 0 (CR-LF), 2 (CR), .
Chapter 18. TCP/IP Change FTP system settings .fcFSysSet Syntax: CALL "FTP.FN3" .fcFSysSet PARA%, ftp.para where ftp.para is FTP.PARA% or FTP.PARA$ Description: This function changes the specified FTP system settings to the new value. Parameters: PARA% ftp.para Return value: (None) Item number New setting for FTP system settings of type integer/ string (FTP.PARA%/FTP.PARA$) Correspondence tables: See Table under .fcFSysGet. Change file name on FTP server .fcRNFR Syntax: CALL "FTP.FN3" .
Set port number for file transfer .fcPORT Syntax: CALL "FTP.FN3" .fcPORT FTPHANDLE%, PORT% Description: This function sets a port number specified by PORT% for file transfer. Parameters: FTPHANDLE% PORT% Return value: (None) FTP client handle Port number Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated.
Chapter 18. TCP/IP Delete file from FTP server .fcDELE Syntax: CALL "FTP.FN3" .fcDELE FTPHANDLE%, SERV.FNAME$, REPLY% Description: This function deletes a file specified by SERV.FNAME$ server. Parameters: FTPHANDLE% SERV.FNAME$ FTP client handle File name to be deleted Return value: REPLY% Server response to FTP command from the FTP Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission.
Appendices CONTENTS Appendix A Error Codes and Error Messages .................................................. 513 A1. Run-time Errors .............................................................................. 513 A2. Compilation Errors ......................................................................... 517 Appendix B Reserved Words ............................................................................ 526 Appendix C Character Sets .................................................
Appendices Appendix A Error Codes and Error Messages A1. Run-time Errors Error code Meaning 00h Internal system error 01h NEXT without FOR 02h Syntax error 03h RETURN without GOSUB 04h Out of DATA (No DATA values remain to be read by the READ statement.) 05h Parameter out of the range 06h The operation result is out of the allowable range. 07h Insufficient memory space (Too deep nesting, etc.) 08h Array not defined 09h Subscript out of range (An array subscript is out of the array.
Error code Meaning 36h Improper file type (The statement attempts an operation that conflicts with the file type-data file, communications device file, or bar code device file.) 37h File already open (An OPEN statement executed for the already opened file.) 38h The file name is different from that in the receive header. 39h Too many files 3Ah File number out of the range 3Bh The number of the records is greater than the defined maximum value.
Appendices Error code Meaning 103h Communications pathway already connected 104h Communications pathway already disconnected 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 110h Response other than 2XX received 111h File not closed 201h Cannot connect to socket 209h Socket identifier is invalid.
Error code Meaning 295h There is no user for login request. 400h Failed to get the setting value (Failed to set the value) 401h Failed to open a spread spectrum communications device file 503h The CU has been linked with any other BHT. 504h LAN-support CU setting being made.
Appendices A2.
Error code & Message fatal error 29: Out of memory for cross reference fatal error 30: Cannot find include file fatal error 31: Cannot nest include file fatal error 32: Internal memory allocation error (tag list buffer) [function name] fatal error 33: (Preprocess) Source file I/O error fatal error 34: (Preprocess) Internal memory overflow fatal error 35: (Preprocess) Macro work file I/O error fatal error 36: (Preprocess) Macro double defined [Macro name] fatal error 37: (Preprocess) Intern
Appendices ■ Syntax Errors Error code & Message error 1: Improper label format error 2: Improper label name (redefinition, variable name, or reserved word used) error 3: ’"’missing error 4: Improper expression error 5: Variable name redefinition (common variable already defined as label name or variable name) error 6: Variable name redefinition (register variable already defined as label name or variable name) error 7: Variable name redefinition (variable already defined as label name, non-ar
Error code & Message error 21: Too many variables (register float array) error 22: Too many variables (register string array) error 23: Too many variables (common integer array) error 24: Too many variables (common float array) error 25: Too many variables (common string array) error 26: Too many variables (work integer array, two-dimensional) error 27: Too many variables (work float array, two-dimensional) error 28: Too many variables (work string array, two-dimensional) error 29: Too man
Appendices Error code & Message error 46: error 47: error 48: error 49: error 50: Incorrect use of IF...THEN...ELSE...ENDIF error 51: Incomplete control structure (IF...THEN...ELSE...ENDIF) error 52: Incorrect use of FOR...NEXT error 53: Incomplete control structure (FOR...NEXT) error 54: Incorrect FOR index variable error 55: Incorrect use of SELECT...CASE...END SELECT error 56: Incomplete control structure (SELECT...CASE...END SELECT) error 57: Incorrect use of WHILE...
Error code & Message error 77: Initial string too long error 78: Array symbols exceed 30 for one DIM, GLOBAL, or PRIVATE statement error 79: Record number out of range (1 to 32767) error 80: Label undefined error 81: Must be DATA statement label (in RESTORE statement) error 82: ’(’ missing error 83: ’)’ missing error 84: ’]’ missing error 85: ’,’ missing error 86: ’;’ missing error 87: ’DEF’ missing error 88: ’TO’ missing error 89: ’INPUT’ missing error 90: ’{’ missing error 91:
Appendices ■ Linking Errors Error Message PRC area size different Out of space in RFG area Out of space in PRD area Cannot open project file Cannot open object file [object name] Cannot open MAP file Cannot open PD3 file [PD3 filename] Cannot close PD3 file [PD3 filename] Write error to PD3 file [PD3 filename] Seek error: Cannot move to the filename position Seek error: Cannot move to the head of the block Filename area too large Symbolname area too large Too many records in symbol table Too many modules
Error Message Non-array integer register variable area overflow Non-array float register variable area overflow Register memory pool area overflow Failed to set up initial setting of register data * To the [Variable type], any of the following character strings applies: • Non-array integer common variable • Non-array float common variable • Non-array string common variable • Non-array integer work variable • Non-array float work variable • Non-array string work variable • Non-array integer register variabl
Appendices ■ Library Errors Error Message Cannot find object to be deleted [objectname] Designated object already existing [objectname] Cannot find object to be updated [objectname] Module already defined [modulename] Filename area too large Too many block information pieces Cannot open library file Seek error: Cannot move to the filename position Seek error: Cannot move to the head of the block NOTE No error code precedes any linking error or library error.
Appendix B Reserved Words The following list shows reserved words (keywords) of BHT-BASIC. Any of these words must not be used as a variable name or label name.
Appendices Appendix C Character Sets C1. Character Set The table below lists the character set which the BHT can display on the LCD screen. It is based on the ASCII codes. NOTE 1: You can assign user-defined fonts to codes from 80h to 9Fh with APLOAD statement. (Refer to APLOAD statement in Chapter 14.) NOTE 2: Characters assigned to codes 20h to 7Fh are default national characters when the English message version is selected on the menu screen* in System Mode.
C2. National Character Sets You may switch characters assigned to codes 20h to 7Fh of the character set table listed in Appendix C1 to one of the national character sets by using the COUNTRY$ function. The default national character set is America (code A) or Japan (code J) depending upon the English or Japanese message version selected on the menu screen in System Mode, respectively. Listed below are national characters which are different from the defaults. * Refer to COUNTRY$ function in Chapter 15.
Appendices Appendix D I/O Ports ■ Input Ports A user program can monitor the hardware status through the input ports by using the WAIT statement or INP function. BHT-BASIC defines each of these ports as a byte. The table below lists the input ports and their monitoring function in the BHT. Bit assignment Port No. .pnEvent 0 0 1 2 3 4 5 6 7 .pnLCDCnt 3 2-0 .pnMgLng 4 0 Monitors the following: Keyboard buffer and touch key buffer - 0 No data .pvEvKeyOn 1 Data stored 0 No data .
Bit assignment Port No. .pnAlpCtrl 5 0 1 2 3 .pnWupCtrl 8 0 1 2 3 .pnBarRrd - 0 Disabled 1 Enabled Software keyboard display .pvAlpDisp 0 Hidden 1 Displayed Software keyboard .pvAlpBotm display position on .pvAlpTop the screen 0 Lower area 1 Upper area Software keyboard movement .pvAlpMove 0 Not allowed 1 Allowed Wakeup function - 0 Deactivated .pvWupOn 1 Activated - 0 Initiated by the power key .
Appendices Bit assignment Port No. .pnMKey 6040h 0 1 2 3 .pnCmPrtcl 6060h 7-0 Monitors the following: Magic key 1 Magic key 2 Magic key 3 Magic key 4 Communications protocol*10 - 0 Released .pvM1kyOn 1 Held down - 0 Released .pvM2kyOn 1 Held down - 0 Released .pvM3kyOn 1 Held down - 0 Released .pvM4kyOn 1 Held down .pvCPBHT 0 BHT-protocol .pvCPBHTIr 2 BHT-Ir protocol .pnBHTIDL 6061h 7-0 ID (lower byte)*11 0-255 .
Bit assignment Port No. .pnRwuHost 60F2h Monitors the following: 0 Execution record of .pvRwuRgst remote wakeup*17 1 Woken up remotely 1 Termination of remote wakeup*18 1 Terminated normally .pnRwuWtT 60F3h 7-0 Timeout for remote wakeup*19 .pnScrnMdL 6110h 1-0 Screen mode*20 3-2 5-4 .pnScrnMdH .pnScrnAtL 6111h 6112h .pnTPBeep .pnTPSts .pnVwFindr 6120h 6121h 6122h 6310h 00 ANK mode .pvScMB 01 Kanji mode - 00 Standard-size .
Appendices Bit assignment Port No. .pnScnMark 6320h 0 Monitors the following: Scanning range marker (BHT-100Q/BHT100QF only) - 0 Normal mode (Driven by the trigger switch) - 1 Fixed to ON - 2 Fixed to OFF *1 Only when the trigger switch function is assigned to either of the magic keys, a user program returns the ON/OFF state of the switch.
*9 If the BHT is placed on the CU and is ready to be charged (or being charged), then "1" will be returned. In this condition, the indicator LED on the BHT is lit in red or green showing the charging state. In either of the following cases, "0" will be returned even if the BHT is placed on the CU: - No power is supplied to the CU. - The BHT cannot be recognized as being placed on the CU due to contact failure of charging terminals.
Appendices ■ Output Ports A user program can control the hardware through the output ports by using the OUT statement. BHT-BASIC defines each of these ports as a byte. The table below lists the output ports and their controlling function in the BHT. Bit assignment Port No. .pnLEDCtrl 1 0 1 .pnLCDCnt 3 2-0 .pnMgLng 4 0 .pnAlpCtrl 5 0 1 2 3 .pnSlpTime .pnWupCtrl 6 8 7-0 0 2 .pnBarRrd - .pnSysMd .pnBLCtrl .
Bit assignment Port No. .pnBLight 6022h 0 1 Controls the following: LCD backlight *10 Key backlight *10 - 0 Deactivate .pvBLLcd 1 Activate - 0 Deactivate .pvBLKey 1 Activate .pnTmPOff 6030h 7-0 Effective helddown time of power key*11 - 1-255 .pnCmPrtcl 6060h 1-0 Communications protocol*12 .pvCPBHT 0 BHT-protocol .pvCPBHTIr 2 BHT-Ir protocol .pnBHTIDL .pnBHTIDH .pnBprVib .pnKeyEnt .
Appendices Bit assignment Port No. .pnRwuSpd .pnRwuHost 60F1h 60F2h 2-0 Controls the following: Transmission speed for remote wakeup*19 011 38400 bps .pvRwu576 100 57600 bps .pvRwu1152 101 115200 bps Termination of remote wakeup .pvRwuEdOk 1 Terminated normally 0 Touch screen function *1 .pvRwu384 1 6120h 6320h 19200 bps Woken remotely .pnTPanel .pnScnMark 010 1 Timeout for remote wakeup*20 6310h .pvRwu192 .pvRwuRgst 7-0 .
*5 To make the TIME$ function return or set the system time, set 0 to this bit; to make the TIME$ function return or set the wakeup time, set 1. Execution of the TIME$ function after selection of the wakeup time will automatically reset this bit to zero. *6 This byte sets the re-read prevention enabled time length in units of 100 ms. Specification of zero (0) permanently enables the re-read prevention so that the BHT does not read same bar codes in succession. The default is 10 (1 second).
Appendices *17 To defragment the drive, set "0," "1," or "2." Setting "1" or "2" will display an absolute bar graph or relative bar graph indicating the defragmentation progress during drive defragmentation, respectively. The bar graph will disappear after completion of defragmentation and the previous screen will come back.
Appendix E Key Number Assignment on the Keyboard ■ Key Number Assignment The keys on the BHT keyboard are assigned numbers as shown below. Non-shift mode Shift mode 35 37 36 30 38 31 33 34 17 18 19 21 22 23 25 26 27 28 29 24 20 ■ Default Data Assignment The default data assignment is shown below. Non-shift mode Shift mode TRG TRG TRG TRG 7 8 9 Q R S 4 5 6 U V W 1 2 3 Y Z + 0 .
Appendices Appendix F Memory Area ■ Memory Map The memory maps are shown below. BHT-100Q/BHT-100QF System work area (1024KB) System program area (3264KB) Font area JIS Level 1 font, 16-dot (120 KB) JIS Level 2 font, 16-dot (112 KB) JIS Level 1 font, 12-dot (88 KB) JIS Level 2 font, 12-dot (84 KB) This area may be used as a user area if you delete these fonts.
The size and area allocation of the memory incorporated in the BHT differ depending upon the models as listed below. BHT series BHT-100 Models User area BHT-102B BHT-102BF 1900*1 BHT-103Q BHT-103QF 4524*1 *21Plus a maximum of 404 KB if you delete fonts ■ Memory Management The BHT manages the user area of the memory for user programs and data files by a unit of segment called "cluster." The cluster size is usually 4 kilobytes.
Appendices Appendix G Handling Space Characters in Downloading ■ Space characters used as padding characters A data file can be downloaded with System Mode or an XFILE statement according to the communications protocol which is designed to eliminate trailing spaces padded in the tail of each data field. The BHT has a new feature which can handle trailing spaces in a data field as data. The figure below shows the process in which the spaces used as padding characters are eliminated.
■ To handle space characters as data To handle trailing spaces in a data field as data (not as padding characters), you must take special considerations in programming. If you want to search for a field data containing spaces in its tail by using a SEARCH function, for instance, use any of the following methods: Example 1 After downloading a data file, fill the unused spaces in each field with spaces and then search for the target field data.
Appendices Example 3 When specifying a field data to be searched, do not include trailing spaces in a data field. A B C Send data A B C Receive data A B C Data to be searched A B C Search data to be specified ( denotes a space character.
■ To make the BHT handle space characters as data You can specify the handling of trailing spaces in a data field with System Mode or an XFILE statement. System Mode: To handle trailing spaces as data, select "Data" in FIELD SPACE item on the SET PROTOCOL screen of the SET SYSTEM menu. XFILE statement: To handle trailing spaces as data, specify T to "protocolspec" in the XFILE statement. XFILE "d2.
Appendices Appendix H Programming Notes ■ Program file named APLINT.PD3 If a program file named APLINT.PD3 is stored in the BHT, the System Mode initiation sequence (by pressing the PW key with the SF and 1 keys held down) will not start System Mode but execute that user program. Making a program file named APLINT.PD3 allows you to: - enter an ID number at the start of System Mode and - set the condensed System Mode which is used for maintenance of user programs. To terminate the APLINT.
Appendix I Program Samples Writing the function for receiving both bar code entry and key entry Feature: This function receives earlier one of either bar code entry or key entry. If bar code reading is completed, the function returns the scanned bar code data; if key entry comes first, the function inhibits bar code reading and echoes back the key entry data, then returns the key entry data when the ENT key is pressed.
Appendices fnbarkey$ = .kb$ ’Then, return the character. exit def endif select .kb$ case chr$(13) fnbarkey$ = .rt$ exit def case chr$(8) ’BS key. if len(.rt$) then print chr$(8); ’Erase one character. .rt$ = left$(.rt$, len(.rt$)-1) endif case chr$(24) ’Clear key. while len(.rt$) ’Erase all characters entered. print chr$(8); .rt$ = left$(.rt$, len(.rt$)-1) wend case else if len(.rt$)
Testing the written function while 1 a$ = fnbarkey$ (1, "A", 15, "DL") print if a$<>"D" and a$<>"L" then print "Data="; a$ else print "ESC(";a$;") key push" endif wend end ’Infinite loop ’F4 and SFT/F4 as escape characters.
Appendices Appendix J Quick Reference for Statements and Functions Controlling program flow Statements CALL Calls an FN3 or SUB function. CHAIN Transfers control to another program. END Terminates program execution. FOR…NEXT Defines a loop containing statements to be executed a specified number of times. GOSUB Branches to a subroutine. GOTO Branches to a specified label.
Handling errors Statements ON ERROR GOTO Enables error trapping. RESUME Causes program execution to resume at a specified location after control is transferred to an errorhandling routine. Functions ERL Returns the current statement location of the program where a run-time error occurred. ERR Returns the error code of the most recent run-time error. Defining and allocating variables Statements COMMON Declares common variables for sharing between user programs.
Appendices Controlling the LCD screen Statements APLOAD Loads a user-defined font in the single-byte ANK mode. CLS Clears the LCD screen. CURSOR Turns the cursor on or off. KEY Assigns a string or a control code to a function key; also defines a function key as a backlight function on/off key. This statement also defines a magic key as a trigger switch, shift key, or software keyboard display key. KPLOAD Loads a user-defined Kanji font in the two-byte Kanji mode.
Controlling the keyboard input Statements INPUT Reads input from the keyboard into a variable. KEY Assigns a string or a control code to a function key; also defines a function key as a backlight function on/off key. This statement also defines a magic key as a trigger switch, shift key, or software keyboard display key. KEY ON Enables keystroke trapping for a specified function key. KEY OFF Disables keystroke trapping for a specified function key.
Appendices Communicating with I/Os Statements OUT Sends a data byte to an output port. POWER Controls the automatic power-off facility. WAIT Pauses program execution until a designated input port presents a given bit pattern. Functions FRE Returns the number of bytes available in a specified area of the memory. INP Returns a byte read from a specified input port. Communicating with the barcode device Statements CLOSE Closes file(s).
Manipulating data files and user program files Statements CLFILE Erases the data stored in a data file. CLOSE Closes file(s). FIELD Allocates string variables as field variables. GET Reads a record from a data file. KILL Deletes a specified file from the memory. OPEN Opens a data file for I/O activities. PUT Writes a record from a field variable to a data file. Functions LOC Returns the current position within a specified file. LOF Returns the length of a specified file.
Appendices Functions BCC$ Returns a block check character (BCC) of a data block. EOF Tests whether the end of a device I/O file has been reached. ETX$ Modifies the value of a terminator (ETX) for the BHT-protocol; also returns the current value of a terminator. INPUT$ Returns a specified number of characters read from the keyboard or from a device file. LOC Returns the current position within a specified file. LOF Returns the length of a specified file.
Manipulating string data Functions ASC Returns the ASCII code value of a given character. CHR$ Returns the character corresponding to a given ASCII code. HEX$ Converts a decimal number into the equivalent hexadecimal string. INSTR Searches a specified target string for a specified search string, and then returns the position where the search string is found. LEFT$ Returns the specified number of leftmost characters from a given string expression.
Appendices Appendix K Unsupported Statements and Functions BHT-BASIC does not support the following MS-BASIC statements and functions: - For handling sequential data files CVD CVI CVS LSET MKD$ MKI$ MKS$ PRINT# PRINT# USING RSET WRITE# - For RS-232C interface operation PRINT# USING WRITE# - For interrupt handling COM OFF COM ON COM STOP ON STCOM GOSUB ON STOP GOSUB STOP OFF STOP ON - For graphics and color control CIRCLE COLOR CONSOLE CSRLIN DRAW LINE POINT PSET WIDTH WINDOW - For I/O control
Index ASCII code 276, 284, 339, 346, 527, 558 Symbols auto-off mode 138, 154, 265, 266, 267 auto-repeat 110 , (comma) 15, 33, 55, 58, 63, 64, 109, 203, 204, 228, 229, 248, 249, 250, 294, 295, 296, 297, 298, 299, 302 B ’ (single quotation, single quote, apostrophe) 16, 54, 57, 310, 334 backlight iii, 165, 166, 167, 234, 235, 236, 390, 535, 538 _ (underline, underscore) 15, 33, 55, 56, 58, 78, 262, 295, 297, 298, 299, 504, 506 backlight function on/off key 166, 233, 234, 235, 236, 238, 553, 554 $INCL
COMMON 50, 54, 65, 67, 71, 75, 170, 171, block-structured statement 16, 47, 48, 49, 193, 195, 196, 199, 200, 213, 215, 217, 223, 226, 258, 261, 320, 322, 323, 327 173, 178, 181, 182, 187, 188, 209, 243, 244, 246, 336, 526, 552 common variable 30, 34, 35, 39, 50, 67, 75, 187, 209, 210, 336, 519, 521, 523, 524, 542, 552 build 6, 8, 14, 17, 18, 19, 20, 23, 24, 26, 35, 36, 38 communications device 126, 141, 421, 424, 425, 426, 431, 433, 434, 436, 441, 490, 556 C communications device file 154, 231, 251, 2
CURSOR iv, 190, 229, 249, 360, 363, 526, direct-connect interface 11, 141, 265, 286, 287, 288, 289, 391, 392, 533 553 cursor 97, 107, 169, 170, 171, 186, 190, 229, 242, 243, 244, 249, 253, 254, 294, 295, 302, 330, 350, 360, 376, 553 directory, directories 27, 37, 41, 42, 43, 129, 130, 183, 240, 459, 467, 495, 496, 497, 501, 502, 503, 506, 508, 509 double-touch reading 133, 134 cursor shape 97, 107, 190, 229, 249, 253, 362, 553 double-width 88, 90, 97, 101, 104, 117, 170, 171, 190, 229, 243, 245, 249, 2
FUNCTION...
integer constant, integerconstant 63, 177, 192, 193, 194, 196, 200, 202, 203, 204, 206, 207, 214, 216, 221, 222, 262, 263, 304, 323, 520 local variable 6, 7, 33, 71, 73, 195, 199, 215, 303, 304, 322, 552 LOCATE 97, 100, 101, 107, 170, 190, 229, 230, 249, 250, 253, 256, 294, 296, 333, 350, 360, 362, 363, 376, 526, 553 interpreter v, 3, 5, 8, 14, 35, 36, 45, 50, 54, 67, 68, 69, 70, 129, 138, 146, 149, 170, 212, 223, 238, 243, 257, 260, 273, 274, 281, 282, 284, 290, 358, 385 logical operation 70, 82 logica
OPEN 58, 61, 126, 129, 130, 132, 184, 185, 210, 211, 219, 220, 262, 263, 266, 267, 276, 283, 286, 287, 288, 298, 306, 307, 333, 370, 371, 379, 420, 514, 526, 556 N national character 107, 348, 349, 527, 528, 553 non-array real type, non-array real variable 34, 66, 187, 192, 194, 214, 321 open 17, 19, 21, 22, 24, 29, 40, 126, 131, 132, 133, 134, 240, 262, 263, 264, 265, 285, 286, 287, 289, 333, 419, 421, 425, 426, 433, 441, 467, 491, 492, 495, 496, 498, 499, 505, 507, 514, 516, 523, 525, 548, 555, 556 no
PRINT# 15, 55, 131, 297, 298, 346, 526, resume function ii, 45, 155, 156, 163, 293, 392, 441 556, 559 PRIVATE 6, 7, 71, 73, 215, 222, 303, 304, RETURN 47, 48, 147, 151, 223, 224, 260, 322, 522, 552 314, 513, 526, 551 program file 18, 27, 32, 43, 126, 144, 183, 193, 203, 240, 333, 358, 459, 460, 461, 466, 504, 505, 506, 514, 556 roaming 419, 434 RS 286 RS/CS 286, 287, 288, 533 program file name, programfilename 42, 181, 182, 547 RS-232C vi, 11, 559 protocol function 142, 143, 144, 357, 380, 382 S
System Mode 3, 45, 50, 110, 142, 143, 144, 156, 163, 164, 208, 273, 281, 284, 348, 389, 390, 391, 394, 395, 431, 432, 527, 528, 533, 535, 543, 546, 547 spread spectrum v, 388, 417, 418, 419, 420, 421, 422, 424, 425, 426, 428, 430, 431, 433, 434, 436, 439, 441, 447, 457, 458, 467, 490, 516 standard-size font, standard-size 88, 89, 92, 95, 98, 100, 102, 117, 119, 171, 190, 229, 244, 249, 253, 315, 317, 350, 362, 376, 407, 408, 532 system program 2, 3, 45 system status 496 start character, start/stop charac
user-defined font 47, 48, 57, 68, 84, 104, 169, 181, 192, 214, 243, 321, 527, 553 user-defined function 7, 31, 33, 34, 36, 48, 49, 57, 58, 68, 77, 149, 179, 180, 193, 195, 196, 199, 200, 201, 215, 216, 217, 322, 323, 334, 358 V variable iv, 5, 30, 31, 33, 34, 35, 36, 39, 41, 42, 43, 50, 53, 54, 57, 60, 61, 65, 66, 67, 69, 70, 77, 154, 156, 169, 170, 171, 177, 178, 179, 181, 182, 187, 188, 191, 192, 194, 195, 196, 199, 200, 201, 203, 204, 206, 207, 209, 210, 212, 213, 214, 215, 217, 221, 222, 228, 229, 230,
BHT-BASIC (BHT-100 series) Programmer’s Manual First Edition, October 2001 DENSO WAVE INCORPORATED The purpose of this manual is to provide accurate information in the development of application programs in BHT-BASIC. Please feel free to send your comments regarding any errors or omissions you may have found, or any suggestions you may have for generally improving the manual.