Summary of Contents for Denso BHT-BASIC 100 SERIES
Page 2
Specifications are subject to change without prior notice. All products and company names mentioned in this manual are trademarks or registered trade- marks of their respective holders. BHT is a trademark of DENSO CORPORATION.
Page 3
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 ®...
Page 4
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.
Page 5
Chapter 12. Power-related Functions Describes low battery warning, the prohibited simultaneous operation of the beeper/illumina- tion 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.
Page 6
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...
Page 7
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. For the INPUT statement Syntax: INPUT [;]["prompt"{,|;}]variable According to the above syntax, all of the following samples are correct: INPUT;keydata INPUT keydata INPUT "input =",keydata...
Page 8
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. Abbreviations AlphaNumerics and Katakana BASIC...
Chapter 1 Software Overview for the BHT CONTENTS Software Overview................... 2 1.1.1 Software Structure of the BHT ............. 2 1.1.2 Overview of BHT-BASIC ..............4 BHT-BASIC...................... 5 1.2.1 Features ....................5 1.2.2 What’s New in BHT-BASIC 3.5 Upgraded from BHT-BASIC 3.0? ..6 [ 1 ] Compiler ..................
1.1 Software Overview 1.1.1 Software Structure of the BHT The structure of software for the BHT is shown below. Flash memory Application User data User programs 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.
Page 11
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.
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. •...
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 fol- lowing features: Syntax Similar to Microsoft™...
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.
Page 15
Chapter 1. Software Overview for the BHT Defining and declaring user-defined functions more easily BHT-BASIC 3.5 has added FUNCTION … END FUNCTION END SUB , and DECLARE statements. With the former two, you may easily define your own functions— FUNCTION .
1.3 Program Development and Execu- tion 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."...
Page 17
Chapter 2 Development Environment and Procedures CONTENTS Overview of Development Environment ............11 2.1.1 Required Hardware ................11 2.1.2 Required Software................12 Overview of Developing Procedures ............. 13 2.2.1 Developing Procedures ..............13 2.2.2 Functions of BHT-BASIC 3.5.............. 14 Writing a Source Program ................15 2.3.1 Writing a Source Program by an Editor..........
Page 18
2.4.7 Options ....................30 [ 1 ] Compiling options..............30 [ 2 ] Linking options ................31 [ 3 ] Outputting debug information files..........31 [ 4 ] Outputting list files ..............32 [ 5 ] Outputting a mapfile ..............35 [ 6 ] Calculating the address for a statement causing a run-time error...................
Chapter 2. Development Environment and Procedures 2.1 Overview of Development Environ- ment 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: •...
Chapter 2. Development Environment and Procedures 2.2 Overview of Developing Proce- dures 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. •...
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 BHT- BASIC 3.5 Compiler will execute. The default editor is Windows Notepad. To write a source program efficiently, use of a commercially available editor is rec- ommended.
Page 24
• Comment lines starting with a single quotation mark (') and those with a 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. should be put starting from the 2nd column or the following columns.
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.5 Compiler supports the following menus and icons which provide quick...
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 pro- grams (files named XXX.OBJ) and then links those object programs to produce a user program (XXX.PD3).
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.
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 ]).
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.
[ 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).
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.
Page 32
• 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. •...
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.
[ 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.
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.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 output- ted to an editor or main window if an error message file (XXX.ERR) is produced.
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.
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 Description Debug information file Outputs debug information files (XXX.ADR, XXX.LBL, and XXX.SYM files).
Chapter 2. Development Environment and Procedures [ 2 ] Linking options Linking Options Description Mapfile Outputs map information to the file XXX.MAP. 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"...
When outputted, each list file has the header format as shown below. ←Version of BHT35CPL.DLL BHT-BASIC 3.5 Compiler Version X.XX Copyright (C) DENSO CORPORATION 1998. All rights reserved. source = Source filename.ext (to be given as an absolute path) Address-source list...
Page 41
Select the Symbol table check box and run the Compiler, and the following information will be outputted: ← Version of BHT35CPL.DLL BHT-BASIC 3.5 Compiler Version X.XX Copyright (C) DENSO CORPORATION 1998. All rights reserved. source = C:\Test.SRC Symbol table for common variables Symbol table for work variables C O M M O N...
Page 42
• 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 ( ).
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] 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 Compiles one or more designated file(s) into object file(s). Builds a user program with the specified program name. If +B programname is specified, the filename specified programname...
Page 47
Chapter 2. Development Environment and Procedures Compiling options Compiling options Description 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 ].) Outputs an address-source list to the file XXX.LST.
[ 3 ] Error Level Indication by ERRORLEVEL If you specify a 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 lev- els listed below.
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 direc- When the specified source tory where the source pro- program has been normally...
Page 50
Output Destination Conditions Address–Source list If the Address-source List check box is selected in the Set Options dialog box. Symbol table File XXX.LST (in the direc- If the Symbol table check tory where the source pro- box is selected in the Set gram is located) Options dialog box.
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.
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. It has the follow- ing functions: Functions of Transfer Utility/Ir-Transfer Utility C/Ir-Transfer Utility E Downloading extension programs Downloading programs...
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 Exe- cution 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.
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...
[ 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. (in single-line form) DEF FN (in block form) DEF FN...END DEF SUB...END SUB FUNCTION...END FUNCTION...
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 sig- nificant statement blocks or to jump out from the midst of those statement blocks, using the GOTO statement.
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.
Chapter 3. Program Structure 3.2.3 Included Files "Included files" are separate source programs which may be called by the INCLUDE meta- command. 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.
Page 60
Chapter 4 Basic Program Elements CONTENTS Structure of a Program Line................53 4.1.1 Format of a Program Line ..............53 [ 1 ] Labels..................53 [ 2 ] Statements ................54 [ 3 ] Comments ................. 54 4.1.2 Program Line Length................55 Usable Characters ..................
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. •...
[ 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.
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.
Chapter 4. Basic Program Elements 4.2.2 Special Symbols and Control Codes Symbols and control codes used outside of a character string have the following special mean- ing: Symbols and Typical use control codes String suffix for variables or user-defined functions (Dollar sign) Integer suffix for variables, constants (in decimal notation), or user- (Percent sign)
Page 66
Symbols and Typical use control codes • Separates statements. (Colon) • Separates time information in function. TIME$ Line feed control character in and other statements. INPUT (Semicolon) • Define the length of a string variable. (Square brackets) • Define the string length of the returned value of a string user- defined function.
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. •...
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. •...
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.
Page 70
Chapter 5 Data Types CONTENTS Constants....................... 63 5.1.1 Types of Constants ................63 [ 1 ] String Constants................ 63 [ 2 ] Numeric Constants..............63 Variables......................65 5.2.1 Types of Variables according to Format..........65 [ 1 ] String Variables ................. 65 [ 2 ] Numeric 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...
Page 72
Real Constants Real constants should be formatted as shown below. Syntax: sign mantissa Syntax: sign mantissa E sign exponent Where a lowercase letter " " is also allowed instead of uppercase letter " ." is a numeric string composed of a maximum of 10 significant digits. It can mantissa include a decimal point.
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.
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 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...
5.3 User-defined Functions Out of user-defined functions, the FUNCTION functions can be called from other files. The function can be called only in the file where that function is defined and DEF FN should start with an functions are classified into three types: integer functions, real DEF FN FUNCTION functions, and character functions, each of which should be defined in the following format:...
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 con- ditions.
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:...
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 GLOBAL statement, respectively. Global variables A global variable can be accessed by any routine in source files to share information between those routines.
Page 80
If used inside the 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 File 1...
Chapter 5. Data Types 5.5.2 Local Variables A local variable can be accessed only in a file where it is defined. Write preceding a PRIVATE desired variable name or DEFREG statement. (Example) PRIVATE aaa% PRIVATE bbb$[10] PRIVATE ccc$(5,3)[30] PRIVATE DEFREG ddd PRIVATE DEFREG eee%(5) Before access to a local variable, you should define it.
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 vari- able used inside the FUNCTION function without declaration is available only within a function where it is defined.
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)
Page 84
Chapter 6 Expressions and Operators CONTENTS Overview......................77 Operator Precedence ..................78 Operators....................... 80 6.3.1 Arithmetic Operators ................80 6.3.2 Relational Operators ................81 6.3.3 Logical Operators ................82 [ 1 ] The NOT operator ..............82 [ 2 ] The AND operator ..............83 [ 3 ] The OR operator ...............
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...
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 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.
Page 87
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) 0.25*2 (=0.5) 4+0.5 (=4.5)
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 Operations Arithmetic Operators Precedence Examples Negation Multiplication and division a*b, a/b Modulo arithmetic a MOD b Addition and subtraction...
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. The relational operators include the following: Relational Operators Meanings...
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 function bitwise, as shown in the sample below. IF d<200 AND f<4 THEN ...
Chapter 6. Expressions and Operators [ 2 ] The operator 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. Syntax: expression1 AND expression2 Truth Table for Bit in...
6.3.4 Function Operators The following two types of functions are available in BHT-BASIC, both of which work as func- tion operators: Built-in Functions Already built in BHT-BASIC, e.g., User-defined Functions Defined by using DEF FN (in single-line form), DEF FN END DEF (in block form), END SUB...
Page 93
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 returns the value of true so as to out- a1$<b1$ put -1.
Page 94
Chapter 7 I/O Facilities CONTENTS 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.2 Coordinates on the LCD..............
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. Character Screen mode Font size Letter type Dots (W x H) Chars x Lines enlargement Single-byte...
Page 97
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.
[ 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 functions. CSRLIN The coordinates will differ depending upon the screen mode and font size. Single-byte ANK mode •...
Page 100
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.
Page 101
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.
Page 103
Chapter 7. I/O Facilities Two-byte Kanji Mode • Standard-size font Half-width Kanji Half-width Kanji 16 x 16 dots (Double-width) 8 x 16 dots (Regular) Half-width Kanji Half-width Kanji 8 x 32 dots 16 x 32 dots (Quadruple) (Double-height) Full-width Kanji Full-width Kanji 16 x 16 dots (Regular) 32 x 16 dots (Double-width)
Page 104
• Small-size font Half-width Kanji Half-width Kanji 6 x 12 dots (Regular) 12 x 12 dots (Double-width) Half-width Kanji 6 x 24 dots Half-width Kanji (Double-height) 12 x 24 dots (Quadruple) Full-width Kanji Full-width Kanji 12 x 12 dots (Regular) 24 x 12 dots (Double-width) Full-width Kanji 12 x 24 dots...
Page 105
Chapter 7. I/O Facilities Cursor shape LOCATE statement specifies the cursor shape--Underline cursor, full block cursor, or invisible. You may define and load the desired cursor shape with the statement APLOAD KPLOAD and then specify the user-defined cursor with the statement.
Page 106
Two-byte Kanji Mode • Standard-size font ( 8 x 16 dots) In regular size Invisible Underline cursor Full block cursor In double-width Full block cursor Invisible Underline cursor In double-height Underline cursor Invisible Full block cursor In quadruple size Invisible Underline cursor Full block cursor...
Page 107
Chapter 7. I/O Facilities • Small-size font (6 x 12 dots) In regular size Invisible Underline cursor Full block cursor In double-width Invisible Underline cursor Full block cursor In double-height Full block cursor Invisible Underline cursor In quadruple size Underline cursor Full block cursor Invisible...
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.
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. SCREEN 0,0 : PRINT "ANK" ’Regular-size in ANK mode SCREEN 0,2 : PRINT "ANK"...
[ 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. SCREEN 0,0 : PRINT "ABC"; ’Regular-size in ANK mode SCREEN 0,6 : PRINT "ABC" ’Quadruple-size in ANK mode SCREEN 1,0 : PRINT "...
Page 111
Chapter 7. I/O Facilities Switching the character size from the regular-size to double-height or qua- druple-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. Assum- ing 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 APLOAD KPLOAD statement loads a user-defined font. APLOAD statement is capable of loading up to 32 single-byte ANK fonts to be displayed in the single-byte ANK mode. statement is capable of loading up to 128 two-byte Kanji fonts in full width to be KPLOAD displayed in the two-byte Kanji mode.
Chapter 7. I/O Facilities 7.1.6 VRAM function may read the VRAM data. The 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 state- ment and function.
Page 114
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 statement or function. If the bit is 1, the corresponding dot on the LCD will come ON. ’Set bit 7 only to 1 OUT &h10,&h80 19Fh...
Chapter 7. I/O Facilities 7.1.7 Other Facilities for the LCD Setting national characters Using the function displays currency symbols and special characters for countries. COUNTRY$ Refer to Appendix C2, "National Character Sets." Specifying the cursor shape LOCATE statement specifies the cursor shape. Cursor shape statement LOCATE...
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 Sys- To switch between the numeric entry system and alphanumeric entry system, use the statement in a user program as shown below.
Page 117
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"...
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.
7.4 Controlling and Monitoring the I/Os 7.4.1 Controlling by the Statement 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 Statement Turns on the indicator LED in green. OUT 1,&h02 Turns on the indicator LED in red.
Chapter 7. I/O Facilities 7.4.3 Monitoring by the Statement WAIT WAIT statement monitors the input and output devices (I/Os) listed in Appendix D, "I/O Ports." Unlike the function, the statement makes the I/O devices idle while no entry WAIT 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.
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 statement as shown below. Example for characters KEY 1,"AB"...
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 func- tion "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.
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.
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"...
- 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"...
Chapter 7. I/O Facilities 7.5.4 Software Keyboard [ 1 ] Enabling/disabling software keyboard Enable the software keyboard function by using the statement and then press the soft- ware keyboard display key* to show the software keyboard on the screen. On the keyboard you may press letter keys to enter ASCII characters.
Page 130
Taking a shortcut through the above flow If you issue the statement (e.g., OUT 5 ), 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 statement (e.g.,...
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.
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.
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 File Name Remarks Data File filename.extension drivename:filename.extension...
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*...
Page 136
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).
Chapter 8. Files 8.2.4 Data File Management by Directory Informa- tion 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 •...
Page 138
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;...
Page 139
Chapter 8. Files Restrictions on Input/Output of Data Files INPUT# LINE INPUT# , or PRINT# statement or INPUT$ function can access data files. To access data files, use a statement. Drive Defragmentation During downloading, a delay of a few seconds (response delay from the BHT) may occur according to the user area condition.
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 statement to the read-only file will result in a run-time error (43h).
Chapter 8. Files 8.3 Bar Code Device 8.3.1 Overview Opening the Bar Code Device by OPEN "BAR:" Statement BHT-100Q " " statement opens the bar code device. In this statement, you may spec- OPEN BAR: ify the following code types available in the BHT. The BHT can handle one of them or their combination.
Page 142
BHT-100B OPEN " BAR: " statement opens the bar code device. In this statement, you may spec- ify the following bar code types available in the BHT. The BHT can handle one of them or their combination. Available Bar Code Types Default Settings Universal product codes EAN-13*...
Page 143
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 statement. OPEN "BAR:" Options 2D codes QR Code - Model - Code version - Split-code scanning mode PDF417 - No option required...
Page 144
You can check whether the barcode buffer stores code data, by using any of the functions, and the statement. WAIT Any of the INPUT# 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 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.
Page 146
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 statement. You may select the read mode of the trigger switch by using the OPEN "BAR:"...
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.) •...
Page 148
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 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 com- puter: • Optical communications unit (CU) and its interface cable • Direct-connect interface cable For the communications specifications, refer to the BHT User's Manual.
8.4.3 Overview of Communications Protocols The BHT supports two communications protocols—BHT-protocol and BHT-Ir protocol for file transmission. Using the statement, the BHT may upload or download a file according XFILE 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 statement (Port &h6060) or in System Mode, you can upload or download a data file with the statement.
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 statement.
Page 153
Chapter 9 Event Polling and Error/Event Trapping CONTENTS Overview...................... 146 Event Polling....................147 [ 1 ] Programming sample .............. 147 [ 2 ] I/O devices capable of being monitored by the event polling ................148 Error Trapping....................149 [ 1 ] Overview ................. 149 [ 2 ] Programming for trapping errors ..........
9.1 Overview BHT-BASIC supports event polling and two types of trapping: error trapping and event trap- ping. – 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 rou- tine.
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 functions to check the data input for the bar code INKEY$ reader and the keyboard, respectively.
[ 2 ] I/O devices capable of being monitored by the event poll- Listed below are the I/O devices which the event polling can monitor. I/O Devices Monitor Means Events Keyboard Input of one character function INKEY$ from the keyboard Bar code reader Presence/absence of bar function...
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 error- handling routine (to which control is to be transferred if a run-time error occurs) by the label. ON ERROR GOTO err01 (Main routine) err01...
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.
Page 160
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 statement Ignores the entry of the pressed key and INPUT causes no interrupt.
Page 162
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.
Page 163
Chapter 11 Resume Function CONTENTS 11.1 Resume Function..................156...
Page 164
11.1 Resume Function The resume function automatically preserves the current status of a running application pro- gram (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.
Page 165
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 ................160 [ 1 ] Outline ..................160 [ 2 ] Remote wakeup operation ............160 [ 3 ] Remote wakeup program ............
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. If the battery output voltage drops further, the BHT displays the Level-2 message "Charge the battery!"...
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 function as follows: TIME$ (1) Set 1 to bit 2 on port 8.
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 speci- fied 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.
Page 169
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.
[ 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 ].
Page 171
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. Start of a remote wakeup program When a remote wakeup program starts, the resume function of the most recently running user program becomes disabled regardless of the resume setting made in System Mode.
Page 172
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 nor- mally ended. (Refer to Appendix D, "I/O Ports.”) Making use of the execution record, you may display an alarm message.
Page 173
Chapter 13 Backlight Function CONTENTS 13.1 Backlight Function ..................166...
Page 174
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 statement, you can enable/disable either or both the LCD backlight and key backlight.
Page 175
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 statement, the backlight function on/off key and ON-duration specified by the statement will be ignored. The backlight function is deactivated when the BHT is turned on.
Page 176
Chapter 14 Statement Reference CONTENTS APLOAD ..........169 LET ............. 247 BEEP ........... 174 LINE INPUT ........248 CALL ........... 177 LINE INPUT # ........251 CHAIN ..........181 LOCATE ..........253 CLFILE ..........183 ON ERROR GOTO ......257 CLOSE ..........
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).
Page 178
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 .
Page 179
• The cursor size will be as shown below. Display font Size (W x H) No. of elements Standard-size 12 x 12 dots 0 1 2 3 5 6 7 8 9 10 11 • An array integer variable--a work array, register array, or common array--for cur- should be declared by the , or...
Page 180
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning • No fontarrayname cursor- error 71: Syntax error arrayname is defined. • fontarrayname cursorar- has an array string vari- rayname able. • fontarrayname cursorar- rayname includes parentheses ( ). •...
Page 181
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) 15 (MSB) Reference: Statements: COMMON, DEFREG, DIM, KPLOAD, PRINT, SCREEN...
Chapter 14. Statement Reference I/O statement BEEP Drives the beeper or vibrator. Syntax: BEEP[onduration[,offduration[,repetitioncount [,frequency]]]] Parameter: onduration, offduration, 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. Description: BEEP sounds the beeper or drives the vibrator during the length of time specified by...
Page 183
You may change the beeper volume with the 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. •...
Page 184
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning The number of parameters or commas error 71: Syntax error (,) exceeds the limit. Run-time errors: Error code Meaning Parameter out of the range Example: BEEP bon%,boff%,count%,helz% BEEP bon%,boff%,count% BEEP bon%,boff%,,helz% BEEP bon%,,count%,helz% BEEP ,boff%,count%,helz%...
Flow control statement CALL Calls an function. Syntax: Syntax 1 (Calling an CALL "[drivename:]filename" functionnumber [data [,data]...] Syntax 2 (Calling a 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.
Page 186
Chapter 14. Statement Reference • filename is the name of an 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.") • is the function number of an FN3 specified by functionnumber filename •...
Page 187
Calling a user-defined function ( function) This statement calls a user-defined function specified by functionname . You may omit CALL when calling a function. • functionname should be a user-defined function defined by END SUB statement. • The number of realparameter s should be equal to that of dummyparame-...
Page 188
Chapter 14. Statement Reference Run-time errors: Error code Meaning Syntax error (" " is in incorrect syntax or the [drivename:]filename extension is not .FN3.) Parameter value out of range (In calling an function, the number of parameters exceeds 16.) Insufficient memory space (You nested calling statements of a user-defined function to more than 10 levels.) functionnumber...
Flow control statement CHAIN Transfers control to another program. Syntax: CHAIN "[drivename:]programfilename" Parameter: " [drivename:]programfilename " A string expression. Description: transfers control to a program specified by " CHAIN [drivename:]program- filename ". That is, it terminates the current running program (1st program) and closes all of the files being opened.
Page 190
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning No double quote precedes or follows error 3: ’"’ missing [drivename:]programfile- name error 71: Syntax error [drivename:]programfile- is not enclosed in double quotes. name Run-time errors: Error code Meaning Syntax error ("...
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: erases data in the data file specified by and resets the CLFILE filenumber number of written records in the directory to zero.
Page 192
Chapter 14. Statement Reference Example: OPEN "master.Dat" AS #1 FIELD #1,20 AS bar$,10 AS ky$ CLFILE #1 CLOSE #1...
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 sub- sequent OPEN statement.
Chapter 14. Statement Reference Clear Screen I/O statement Clears the LCD screen. Syntax: Description: clears the liquid crystal display (LCD) screen and returns the cursor to the upper left corner of the screen. • The statement does not affect settings made by displaymode in the statement.
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.
Page 196
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning A same variable name is double error 5: Variable name declared in a program. redefinition The length of a string variable is out of error 73: Improper the range from 1 to 255. string length Run-time errors: Error code...
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 con- sisting of alphanumerics and period (.). expr A string constant Description: CONST replaces a label, identifier or a character string specified by...
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.
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.
Chapter 14. Statement Reference User-defined function declarative statement DECLARE Declares user-defined function FUNCTION 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 DECLARE SUB subname[(dummyparameter [,dummyparameter...])] Parameter:...
Page 201
Description: DECLARE defines a user-defined function defined in other source program files. • Declaration of a user-defined function should appear preceding a calling state- ment of the user-defined function in your source program. • , and should be declared in the funcname subname dummyparameter...
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 ...])] Parameter:...
Page 203
Description: Creating a user-defined function creates a user-defined function. DEF FN • 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. •...
Page 204
Chapter 14. Statement Reference Syntax errors: When defining a user-defined function Error code and message Meaning error 61: Cannot use DEF DEF FN statement is defined in block-structured statements such as FN in control statements. structure You made double definition to a same error 64: Function function name.
Page 205
Run-time errors: Error code Meaning Insufficient memory space (You nested statements to more than 10 levels.) DEF FN String length out of the range (The returned value of the exceeds the allow- stringlength able range.) Example: Example 1 DEF FNadd(a%,b%)=a%+b% PRINT FNadd(3,5) Example 2 DEF FNappend$(a$,b$)[80]=a$+b$...
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 [,dummyparame- ter...])] [[stringlength]] Syntax 3 (Exiting from the function block prematurely): EXIT DEF...
Page 207
Description: Creating a user-defined function creates a user-defined function. The function definition block DEF FN...END DEF between is a set of some statements and functions. DEF FN END DEF • Definition of a user-defined function should appear preceding a calling statement of the user-defined function in a source program.
Page 208
Chapter 14. Statement Reference Calling a user-defined function FNfunctionname calls a user-defined function. • The number of s should be equal to that of realparameter dummyparame- s, and the types of the corresponding variables used in those parameters should be identical. •...
Page 209
When calling a user-defined function Error code and message Meaning • The number of the real parameters is error 68: Mismatch not equal to that of the dummy argument type parameters. or number • dummyparameter was an integer variable in defining a function, but realparameter is a real type in calling the function.
Page 211
numericinitialvaluedefinition For one-dimensional: {numericconstant[,numericconstant...]} DEFREG n6%(3)={9,8,7,6} For two-dimensional: {{numericconstant[,numericconstant...]}, {numer- icconstant[,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...]}, {string- constant[,stringconstant...]} ...} DEFREG s4$(1,1)={{"a","b"},{"c","1"}} stringlength An integer constant from 1 to 255. Description: DEFREG defines non-array or array register variables. •...
Page 212
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning A same register variable name is dou- error 6: Variable name ble declared in a program. redefinition • is not an integer error 71: Syntax error stringlength constant. • The number of the specified initial values is greater than that of the array elements.
Page 213
Example: Example 1: Valid DEFREG statements DEFREG a,e$ DEFREG b=100,c(10),d$(2,4)[10] DEFREG bps$="19200" DEFREG a%(2)={1,2} DEFREG a%(2)={1,,3} DEFREG a%(2)={,,3} DEFREG b%(1,1)={{},{1,2}} DEFREG b%(1,1)={,{1,2}} DEFREG 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...
Chapter 14. Statement Reference DIMension Memory control statement Declares and dimensions arrays; also declares the string length for a string variable. Syntax: DIM arraydeclaration[,arraydeclaration...] Parameter: arraydeclaration numericvariable (subscript) DIM n1%(12) DIM n2(5,6) stringvariable (subscript)[ [stringlength] ] DIM s1$(2) DIM s2$(2,6) DIM s3$(4)[16] DIM s4$(5,3)[30] subscript...
Page 215
• In declaring an array string variable, you can specify the string length. If its speci- fication 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 Terminates program execution. Syntax: Description: terminates program execution and sounds the beeper for a second. • An can appear anywhere in a source program. • When an statement executes, all of the files being opened become closed, and then either of the following operations takes place depending upon whether or not any application program has been selected as an execution program (to be run when the BHT is turned on) in System Mode.
Memory control statement ERASE Erases array variables. Syntax: ERASE arrayvariablename[,arrayvariablename...] Parameter: arrayvariablename An array numeric or array string variable. Description: erases an array variable(s) specified by and frees ERASE arrayvariablename the memory used by the array. • is the name of an array variable already declared by arrayvariablename statement.
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.
Page 219
Syntax errors: Error code and message Meaning error 71: Syntax error filenumber is missing. Run-time errors: Error code Meaning Parameter out of the range fieldwidth out of the range) Bad file name or number (You specified of an unopened file.) filenumber Improper file type (You specified...
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, increment Numeric expressions.
Page 221
• The default value of increment is 1. • You can nest FOR...NEXT statements to a maximum of 10 levels. • When using the statement together with block-structured statements FOR...NEXT DEF FN...END DEF FOR...NEXT FUNCTION...END FUNCTION IF...THEN ...ELSE...END IF SELECT...CASE...END SELECT SUB...END SUB WHILE...WEND ), you can nest them to a maximum of 30 levels.
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...])][[stringlength]] Syntax 3 (Existing from the function block prematurely): EXIT FUNCTION Syntax 4 (Ending the function block): END FUNCTION...
Page 223
Description: Creating a user-defined function FUNCTION END FUNCTION creates a user-defined function. The function defini- tion block between is a set of some statements FUNCTION END FUNCTION and functions. • You cannot make double definition to a same function name. •...
Page 224
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 s are passed not by address but by value. realparameter (So called "Call-by-value") Before any call to a FUNCTION...
Page 225
Error code and message Meaning error 96: Incomplete END FUNCTION is missing. control struc- ture (FUNC- TION...END FUNCTION) error 97: Cannot use FUNCTION … END FUNCTION statement is defined in other block- FUNCTION in structured statements such as control struc- statement blocks.
Page 226
Chapter 14. Statement Reference Example: File 1 File 2 DECLARE FUNCTION add(x,y) FUNCTION add(X,Y) A=1:B=2 add=X+Y PRINT "TEST" END FUNCTION C=add(A,B) PRINT C TEST Reference: Statements: DECLARE...
File I/O statement 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: reads the record specified by from the data file specified by recordnumber and assigns the data to the field variable(s) specified by the...
Page 228
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning is missing. error 71: Syntax error filenumber Run-time errors: Error code Meaning Bad file name or number (You specified of an unopened file.) filenumber Improper file type (You specified filenumber of a file other than data files.) File number out of the range...
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.
Page 230
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning The variable declared with error 7: Variable name GLOBAL statement had been already declared redefinition with statement. DEFREG • is out of the error 71: Syntax error stringlength range. •...
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 log- ical end of the subroutine and returns control to the statement just after the that called the subroutine.
Page 232
Chapter 14. Statement Reference Run-time errors: Error code Meaning without RETURN GOSUB Insufficient memory space (Too deep nesting) Reference: Statements: RETURN...
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 statement block, you can omit GOTO immediately following THEN ELSE , as shown below. IF a=0 THEN Lbl1 ELSE Lbl2 END IF •...
Chapter 14. Statement Reference Flow control statement IF...THEN...ELSE...END IF Conditionally executes specified statement blocks depending upon the evaluation of a condi- tional expression. Syntax: Syntax 1: IF conditionalexpression THEN statementblock1 [ELSE statementblock2] END IF Syntax 2: IF conditionalexpression ELSE statementblock END IF Parameter: conditionalexpression...
Page 235
• A block-structured statement block has the following advantages over a sin- gle-line statement (which is not supported in BHT-BASIC): - More complex conditions can be tested since an statement block can con- tain 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 statement, the program pauses and waits for INPUT the user to enter data from the keyboard while showing a prompting message spec- ified by...
Page 237
• The cursor shape specified by the most recently executed LOCATE statement takes effect. • Even after execution of the CURSOR OFF statement, the INPUT statement dis- plays 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.
Page 238
Chapter 14. Statement Reference Run-time errors: Error code Meaning The operation result is out of the allowable range. (Numeric is out of the range.) variable Reference: Statements: LINE INPUT LOCATE Functions: INKEY$ INPUT$...
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...
Page 240
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.
I/O statement 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.* (*Only for models equipped with a touch screen) Syntax: Syntax 1 (Assigning a string or a control code to a function key):...
Page 242
Chapter 14. Statement Reference Description: Assigning a string or a control code to a function key in syntax 1 assigns a string or a control code specified by to a stringdata function key specified by keynumber . Pressing the specified function key gener- ates 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.
Page 243
• 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. •...
Page 244
Chapter 14. Statement Reference If you issue KEY statements specifying a same function key, only the last NOTE 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 ON- time is 100 seconds.
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.
Page 247
Syntax errors: Error code and message Meaning • is not enclosed in error 71: Syntax error keynumber parentheses ( ). • Neither follows ( key- number Run-time errors: Error code Meaning Parameter out of the range keynumber is out of the range.) Reference: Statements: ON KEY...GOSUB...
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: deletes a data file or a user program file specified by KILL "[drive- name:]filename" • is used in conventional BHT series. In the BHT-100 series, it is [drivename:] merely for the compatibility with their specifications.
Page 249
Example: CLOSE IF kyIn$="Y" THEN KILL "Master.Dat" END IF Reference: Statements: CLFILE...
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...
Page 251
• 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 statement. CHAIN • If you load a font to the same kanjicode more than one time, the most recently specified font takes effect.
Page 252
Chapter 14. Statement Reference • An array integer variable--a work array, register array, or common array--for cur- should be declared by the , or state- sorarrayname DEFREG COMMON ment, 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.
Page 253
• If the double-width, double-height, or quadruple-size is specified, then user- defined cursors loaded by the will display in double-width, double- KPLOAD height, 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 •...
Page 254
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 SCREEN 1 KPLOAD &HEBC0,kp% PRINT CHR$(&HEB);CHR$(&HC0) Array Elements Bit in each array element kp%(0) kp%(5) kp%(10) kp%(15) 0 (LSB) 15 (MSB) Reference:...
Assignment statement Assigns a value to a given variable. Syntax: Syntax 1: [LET] stringvariable = stringexpression Syntax 2: [LET] numericvariable = numericexpression Description: assigns a value of expression on the right-hand side to a variable on the left- hand side. •...
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"...
Page 257
"prompt" is followed by a comma, the statement displays the prompting mes- sage 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.
Page 258
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning • is missing. error 71: Syntax error INPUT • Neither a comma (,) or semicolon (;) follows "prompt" • is not a string constant. "prompt" • stringvariable has a numeric variable.
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 and assigns it to...
Page 260
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning • is missing. error 71: Syntax error INPUT • filenumber is missing. • is not a string constant. "prompt" • stringvariable has a numeric variable. Run-time errors: Error code Meaning Bad file name or number (You specified...
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. Screen mode Screen font column cursorswitch Single-byte Standard-size 1 to 17 1 to 25...
Page 262
Chapter 14. Statement Reference • The entry ranges of the column and row are the same in the regular-size, double- width, double-height, and quadruple-size. • Any parameter value outside its range will result in a run-time error. • Specification of the maximum value to moves the cursor off the screen column and out of sight.
Page 263
• If the double-height or quadruple-size is specified, specification of the maximum value to 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.
Page 264
Chapter 14. Statement Reference Run-time errors: Error code Meaning Parameter out of the range Example: LOCATE 1,2 LOCATE xPos,xCSRLIN LOCATE ,,2 Reference: Functions: CSRLIN...
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 if an error occurs during program execu- label tion.
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.
Page 267
Syntax errors: Error code and message Meaning • has not been defined. error 71: Syntax error label • label is missing. Run-time errors: Error code Meaning Parameter out of the range expression is negative or greater than 255.) Insufficient memory space (The program nesting by GOSUB statements only is too deep.)
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...
Page 269
• When using the ON KEY...GOSUB statement together with block-structured state- ments ( DEF FN...END DEF FOR...NEXT FUNCTION...END FUNCTION IF...THEN...ELSE...END IF SELECT...CASE...END SELECT SUB...END SUB ), you can nest them to a maximum of 30 levels. WHILE...WEND • Specifying 32 to keynumber will be ignored.
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.
Page 271
• 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 statement. If you specify OPEN filelength when opening any of existing data files (including downloaded data files), then the will be ignored.
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.
Page 273
• 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 com- munications device file concurrently.
Page 274
Chapter 14. Statement Reference Auto-off mode ( OPEN "BAR:F" AS #7 CODE "A" If you press the trigger switch , the illumination LED comes on. When you release the switch or when the BHT completes bar code reading, then the illu- mination LED will go off.
Page 275
• 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 sec- ond or more.
Page 276
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 (univer- sal product codes, interleaved 2 of 5 (ITF), Codabar (NW7), Code 39, and Code 128).
Page 277
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 specifying the following: Split code scanning allowed splitmode...
Page 278
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.
Page 279
Universal product codes ( Syntax : A[:[code][1stchara[2ndchara]] [,[code][1stchara[2ndchara]]] [,[code][1stchara[2ndchara]]]] where code , or specifying the following: Bar code type code EAN-13 or UPC-A EAN-8 UPC-E is omitted, the default is all of the universal product codes. code 1stchara 2ndchara are flag characters representing a country code and should be numerals from 0 to 9.
Page 280
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 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 condi- tion: mini.no.digits ≤...
Page 281
Codabar (NW-7) ( 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 are the minimum and maxi- mini.no.digits max.no.digits mum 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 ≤...
Page 282
Chapter 14. Statement Reference Code 39 ( 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 are the minimum and maximum mini.no.digits max.no.digits 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.digits ≤...
Page 283
Code 128 ( 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 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.
Page 284
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...
Page 285
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 prod- uct codes, Interleaved 2 of 5 (ITF), Codabar (NW-7), Code 39, and Code 128.
Page 286
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:"...
Page 287
(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. A single-line code EAN-13 "9012345678904" At multi-line code EAN-13 "9012345678904"...
Page 288
Chapter 14. Statement Reference readcode BHT-100B The BHT supports seven types of bar codes--the universal product codes, Inter- leaved 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.) Universal product codes ( Syntax:...
Page 289
Interleaved 2 of 5 (ITF) ( 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 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 ≤...
Page 290
Chapter 14. Statement Reference is a check digit. Specifying a 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 ( 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...
Page 291
Code 128 ( Syntax : K[:[mini.no.digits[-max.no.digits]] [,[mini.no.digits[-max.no.digits]]] [,[mini.no.digits[-max.no.digits]]]] where mini.no.digits 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.
Page 292
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.
Page 293
Syntax errors: Error code and message Meaning The number of the specified read error 71: Syntax error codes exceeds eight. Run-time errors: Error code Meaning Syntax error readcode is missing.) Parameter out of the range readcode is not correct.) File already open File number out of the range Device files prohibited from opening concurrently (You attempted to open the bar code device file and IrDA inter-...
Chapter 14. Statement Reference File I/O statement OPEN "COM:" Opens a communications device file. Syntax: Syntax 1 (For the direct-connect interface): OPEN "COMn:[baud][,[parity][,[charalength][,[stop- bit][,[RS/CS][,[timeout]]]]]] "AS [#] filenumber Syntax 2 (For the IrDA interface): OPEN "COMn: [baud] "AS [#] filenumber Parameter: baud For the IrDA interface 115200, 57600, 38400, 19200, 9600, or 2400...
Page 295
Description: OPEN "COM:" opens a communications device file and associates it with file- number for allowing input/output activities using the communications interface. • If optional parameters enclosed with brackets are omitted, the most recently spec- ified values or the defaults become active. Listed below are the defaults: Baud rate 9600 bps...
Page 296
Chapter 14. Statement Reference charalength charalength is a character length or the number of data bits. It should be (default) or bits. stopbit is the number of stop bits. It should be (default) or bits. stopbit The IrDA interface is compliant with the IrDA physical layer (IrDA- NOTE SIR1.0), so the vertical parity, character length, and stop bit length are fixed to none, 8 bits, and 1 bit, respectively.
Page 297
Syntax errors: Error code and message Meaning is missing. error 71: Syntax error filenumber Run-time errors: Error code Meaning Syntax error (The "COM:x" contains an invalid parameter.) File already open File number out of the range File already open (You attempted to open the bar code device file and the IrDA interface of the communications device file concurrently.) (You attempted to concurrently open the two types of communi- cations device files -- IrDA interface and spread spectrum inter-...
Chapter 14. Statement Reference I/O statement 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: sends a data byte designated by to a port specified by data portnumber...
Page 299
Run-time errors: Error code Meaning Parameter out of the range is out of the range.) portnumber data Example: The above example sets the LCD contrast to the maximum. Reference: Statements: WAIT Functions:...
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...
Page 301
Turning off the power immediately Execution of immediately turns off the power. POWER OFF POWER 0 • The execution of POWER OFF POWER 0 deactivates the resume function if pre- set. Disabling the automatic power-off facility POWER CONT disables the automatic power-off facility. Run-time errors: Error code Meaning...
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...
Page 303
CR/LFcontrol CR/LFcontrol determines where the cursor is to be positioned after the PRINT statement executes. • If is a comma (,), the cursor moves to the column position of a CR/LFcontrol least multiple of 8 plus one following the last character output. Statement example: PRINT 123, Output:...
Page 304
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning contains a comma (,) or semico- error 71: Syntax error data lon (;). Reference: Statements: LOCATE, PRINT USING, SCREEN...
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...
Page 306
Chapter 14. Statement Reference • If CR/LFcontrol is a semicolon (;), the PRINT # statement outputs data with- out 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 #...
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 &...
Page 308
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-justi- fied.
Page 309
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: Displays the entire stringexpression Statement example: PRINT USING "@";"ABC"...
Page 310
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 statement. PRINT Syntax errors: Error code and message Meaning error 71: Syntax error •...
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 [,registerdefini- tion...] Parameter: varname numericvar [(subscript)] stringvar [(subscript)[[stringlength]]] registerdefinition non-arraynumericvar [=numericconstant] arraynumericvar(subscript)
Page 312
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 charac- ters. Description: defines variables declared by PRIVATE...
Page 313
Run-time errors: Error code Meaning Parameter out of the range Insufficient memory space (The variable area has run out.) Duplicate definition (An array is double declared.) Reference: Statements: DEFREG , and GLOBAL...
Chapter 14. Statement Reference File I/O statement 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: writes a record from a field variable(s) declared by the FIELD...
Page 315
Syntax errors: Error code and message Meaning is missing. error 71: Syntax error filenumber Run-time errors: Error code Meaning Parameter out of the range (• is out of the range.) filenumber (• recordnumber is out of the range.) Insufficient memory space Bad file name or number (You specified of an unopened file.)
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: reads as many data values as necessary in turn from data stored by READ DATA statement and assigns them, one by one, to each variable in the...
Page 317
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: • 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.
Chapter 14. Statement Reference Declarative statement Declares the rest of a program line to be remarks or comments. Syntax: Syntax 1: REM comment Syntax 2: ’ comment Description: 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.
I/O statement RESTORE Specifies a DATA statement location where the READ statement should start reading data. Syntax: RESTORE [label] Description: specifies a statement location where the statement should RESTORE DATA READ start reading data, according to label designating the DATA statement.
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: returns control from the error-handling routine to a specified location of the RESUME main program to resume program execution.
Page 321
Run-time errors: Error code Meaning without error RESUME RESUME statement occurs outside of an error-handling rou- tine.) Reference: Statements: ON ERROR GOTO Functions:...
Chapter 14. Statement Reference Flow control statement RETURN Returns control from a subroutine or an event-handling routine (for keystroke interrupt). Syntax: RETURN Description: statement in a subroutine returns control to the statement immediately fol- RETURN lowing the that called the subroutine. GOSUB RETURN statement in an event-handling routine for keystroke interrupt returns con-...
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 charaattribute A numeric expression which returns a value from 0 to 65535. Description: displaymode in the...
Page 324
Chapter 14. Statement Reference charaattribute sets the tone, character enlargement, and font reverse attributes as listed below. Tone Character enlarge- SCREEN ,charaat- Font reverse attribute attribute ment attribute tribute Black Regular Normal SCREEN ,0 Reversed (Highlighted) SCREEN ,1 Double-width Normal SCREEN ,2 Reversed (Highlighted) SCREEN ,3...
Page 325
charaattribute is expressed with a bit array as shown below. Font reverse attribute Tone attribute 0: Normal 00000000: Black 1: Reversed (Highlighted) 01000000: Dark gray 10000000: Light gray Character enlargement attribute 11111111: White 11111111: White 000: Regular 001: Double-width 010: Double-height 011: Quadruple •...
Page 326
Chapter 14. Statement Reference Example: mode% = .scMB+.scSmall ’Kanji mode, small-size font attrib% = .scW2H1+.scDGray ’Double-width, dark gray SCREEN mode%, attrib% Run-time errors: Error code Meaning Parameter out of the range...
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, test2 A numeric or string expression. Description: This statement executes one of s depending upon the value of...
Page 328
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 state- ments (...
User-defined function statement SUB...END SUB Names and defines user-defined function 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]...)] Parameter: subname...
Page 330
Chapter 14. Statement Reference Description: Creating a user-defined function END SUB creates a user-defined function. The function definition block between END SUB is a set of some statements and functions. • You cannot make double definition to a same function name. •...
Page 331
Syntax errors: When defining a user function Error code and message Meaning You made double definition to a same error 64: Function function name. redefinition • The string length is out of the range. error 71: Syntax error • The string length is not an integer constant.
Page 332
Chapter 14. Statement Reference Run-time errors: Error code Meaning Insufficient memory space (You nested statements to more than 10 levels.) 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...
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 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...
Page 334
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning • is missing. error 71: Syntax error portnumber • ANDbyte is missing. Run-time errors: Error code Meaning 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: continues to execute as long as the WHILE...WEND statementblock con- ditionalexpression is true (not zero) according to the steps below. (1) The conditionalexpression in the...
Page 336
Chapter 14. Statement Reference Syntax errors: Error code and message Meaning Too deep nesting. error 26: appears outside of the error 57: Incorrect use WEND WHILE statement block. of WHILE...WEND error 58: Incomplete WEND corresponds to WHILE control struc- ture Reference: Statements: FOR…NEXT...
I/O statement XFILE Transmits a designated file according to the specified communications protocol. Syntax: XFILE "[drivename:]filename"[,"protocolspec"] Parameter: "[drivename:]filename" "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 communi- cations protocol specified by "protocolspec."...
Page 338
Chapter 14. Statement Reference - Transmission direction Parameter omitted (default) Transmits a file from the BHT. Receives a file from the host com- puter 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.
Page 339
- 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 30 sec. Retries of ENQ, 10 times Retries of ENQ, 60 times 60 sec. Retries of ENQ, 20 times Retries of ENQ, 120 times 90 sec.
Page 340
Chapter 14. Statement Reference • A communications device file should be opened before execution of the XFILE statement. (For the file opening, refer to the statement.) OPEN "COM:" • The XFILE statement uses the interface specified by the OPEN "COM:" state- ment.
Page 341
Run-time errors: Error code Meaning Syntax error ([drivename:]filename is not correct.) Insufficient memory space (During file reception, the memory runs out.) File type mismatch (The received file is not a data file.) Received text format not correct Bad file name or number (You specified filename of an unopened file.) File not found File already open...
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.
Page 343
Fatal Error: Error code and message Meaning No included file is found. fatal error 30: Cannot find include file "XXX" Included files are nested. fatal error 31: Cannot nest include file...
Chapter 14. Statement Reference Additional Explanation for Statements Effective range of labels Labels are effective only in a file. Definition of common variables (by statement) COMMON In an object to be executed first (that is, in a main object), you should define all common vari- ables to be accessed.
Page 345
Chapter 15 Function Reference CONTENTS ABS ............. 338 INT ............366 ASC ............. 339 LEFT$ ..........367 BCC$ ........... 340 LEN ............. 368 CHKDGT$ ........... 342 LOC ............ 369 CHR$ ..........346 LOF ............. 371 COUNTRY$ ........348 MARK$ ..........372 CSRLIN ..........
Chapter 15. Function Reference ABSolute Numeric function Returns the absolute value of a numeric expression. Syntax: ABS(numericexpression) Description: returns the absolute value of numericexpression . The absolute value is the magnitude of numericexpression without regard to sign. For example, both ABS (-12.34) ABS (12.34) are equal to 12.34.
ASCii code String function Returns the ASCII code value of a given character. Syntax: ASC(stringexpression) Description: 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.") •...
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...
Page 349
Run-time errors: Error code Meaning Parameter out of the range is out of the range.) checktype...
Chapter 15. Function Reference CHecK DiGiT String function CHKDGT$ Returns a check digit of bar code data. Syntax: CHKDGT$(barcodedata,CDtype) Parameter: barcodedata CDtype String expressions. Description: CHKDGT$ calculates a check digit (CD) of barcodedata according to the calcu- lation method specified by , and then returns it as one-character string.
Page 351
Sample coding 4: CD.Data$=CHKDGT$("a123Qa","N") "Q" is a CD position character, so calculates the CHKDGT$ correct CD and will become "-." CD.Data$ When (EAN or UPC), identifies the EAN or UPC of CDtype CHKDGT$ barcodedata depending upon the data length (number of digits) as listed below.
Page 352
Chapter 15. Function Reference When CDtype (ITF), the length of barcodedata must be an even num- ber of two or more digits. If not, returns a null string. CHKDGT$ - To check that the CD is correct: Pass a CD-suffixed to a as shown below.
Page 353
When CDtype (Codabar), the length of barcodedata must be three dig- its or more including start and stop characters. If not, returns a null CHKDGT$ string. - To check that the CD is correct: Pass a CD-suffixed barcodedata to a CHKDGT$ as shown below.
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 equiva- lent single-byte character.
Page 355
• To display a Kanji code, use a shift JIS code as shown below. The shift JIS code is 8ABFh. SCREEN 1 PRINT CHR$(&h8A);CHR$(&hBF) Reference: Statements: PRINT Functions:...
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 , and Description: Syntax 1...
Page 357
• 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 CHAIN statements. • If "countrycode" has more than one character, only the first one takes effect. •...
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 statement.
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.
Page 360
Chapter 15. Function Reference Run-time errors: Error code Meaning Parameter out of the range is out of the range.) date Reference: Functions: TIME$...
End Of File File I/O function 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: tests for an end of a device I/O file designated by filenumber .
Page 362
Chapter 15. Function Reference Run-time errors: Error code Meaning Bad file name or number (You specified of an unopened file.) filenumber Improper file type (You specified of a data file.) filenumber File number out of the range Reference: Statements: INPUT#, LINE INPUT#, OPEN "BAR:", OPEN "COM:"...
ERror Line Error-handling function Returns the current statement location of the program where a run-time error occurred. Syntax: Description: returns the current statement location of the program where a run-time error occurred most recently. • The function works only with line numbers and not with labels. •...
Chapter 15. Function Reference ERRor code Error-handling function Returns the error code of the most recent run-time error. Syntax: Description: 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$ func- tion for decimal-to-hexadecimal conversion when using the...
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...
Chapter 15. Function Reference FREe area Memory management function 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: 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: function converts a decimal number from -32768 to 32767 into the equivalent HEX$ hexadecimal string which is expressed with 0 to 9 and A to F.
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, returns a null INKEY$ string.
INPort data I/O function 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: reads one-byte data from an input port specified by portnumber and returns the 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.
Page 371
Run-time errors: Error code Meaning Parameter out of the range is out of the range.) numcharas Bad file name or number (You specified of an unopened file.) filenumber Improper file type (You specified filenumber of a data file.) File number out the range Reference: Statements: CURSOR, INPUT, LINE INPUT, LOCATE,...
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 searchstring A string expression.
Page 373
• A returned value of INSTR is a decimal number from 0 to 255, depending upon the conditions as listed below. Conditions Returned value First character position of the search is found within searchstring string first found. targetstring is greater startposition than the length of targetstring...
Chapter 15. Function Reference INTeger Numeric operation function Returns the largest whole number less than or equal to the value of a given numeric expres- sion Syntax: INT(numericexpression) Parameter: numericexpression A real expression. Description: returns the largest whole number less than or equal to the value of numericexpression by stripping off the fractional part.
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: extracts a portion of a string specified by by the LEFT$ stringexpression...
Chapter 15. Function Reference LENgth String function Returns the length (number of bytes) of a given string. Syntax: LEN(stringexpression) Description: returns the length of stringexpression , that is, the number of bytes in the range from 0 to 255. • If stringexpression is a null string, returns the value 0.
LOcation Counter of file File I/O function 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: returns the current position within a file (a data file, communications device file, or bar code device file) specified by filenumber •...
Page 378
Chapter 15. Function Reference Run-time errors: Error code Meaning Bad file name or number (You specified of an unopened file.) filenumber File number out of the range statement executed without a FIELD statement. FIELD statement is found.) Reference: Statements: OPEN Functions:...
Location Of File File I/O function Returns the length of a specified file. Syntax: LOF([#]filenumber) Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: returns the length of a data file or communications device file specified by filenumber •...
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:...
Page 381
• The first one byte of a returned value contains one of the following letters repre- senting code types: Code type First one byte of a returned value QR Code Split QR Code (in non-edit mode) PDF417 (Supported by the BHT-100Q only) MaxiCode Data Matrix EAN-13 or UPC-A...
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. Description: Starting from a position specified by startposition...
Page 383
Run-time errors: Error code Meaning Parameter out of the range Reference: Functions: LEFT$, LEN, RIGHT$...
Chapter 15. Function Reference POSition I/O function Returns the current column number of the cursor. Syntax: POS(0) Description: 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...
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, extracts a portion of a string speci- RIGHT$ fied by...
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.
Page 387
Run-time errors: Error code Meaning Parameter out of the range Bad file name or number (You specified filenumber of an unopened file.) Improper file type (You specified filenumber of a file other than data files.) File number out of the range statement executed without a statement.
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...
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 lead- ing space (meaning + sign) 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...
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"...
Page 392
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."...
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.
Chapter 15. Function Reference VALue String function Converts a string into a numeric value. Syntax: VAL(stringexpression) Parameter: stringexpression A string expression which represents a decimal number. Description: converts the string specified by into a numeric value. stringexpression • If stringexpression is nonnumeric, returns the value 0.
Page 395
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) ......399 16.3.1 Function Number List of CONSOLE.FN3.........
16.1 Overview In addition to the BHT-BASIC statements and functions, the BHT-100 series supports the fol- lowing extended functions which can be invoked by the CALL statement. Extended func- Used to: Remarks tions Read or write system settings from/ SYSTEM.FN3 to the memory.
Chapter 16. Extended Functions 16.2 Reading or writing system set- tings from/to the memory (SYSTEM.FN3) 16.2.1 Function Number List of SYSTEM.FN3 SYSTEM.FN3 may read or write system settings depending upon the function number specified, as listed below. Function number Used to: Read numeric data from System Mode settings .fcSysIGet Write numeric data to System Mode settings...
16.2.2 Detailed Function Specifications Read numeric data from System Mode settings .fcSysIGet 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: Numeric data read from the specified system menu item DATA%...
Page 399
Chapter 16. Extended Functions Item number DATA%, numeric data of Initial Attribute System menu item the system menu item value (PARA%) .syCmifApl 12 Default interface to be R/W .syCmifOpt 0 IrDA interface used for user pro- .syCmifCon 1 Direct-connect interface grams .syCmifSys 13 Default interface to be R/W .syCmifOpt 0 IrDA interface...
Page 400
Item number DATA%, numeric data of Initial Attribute System menu item the system menu item value (PARA%) .syHPrtyOp 23 Horizontal parity for R/W .syHPtyOff 0 No parity (OFF) IrDA interface 1 Add (ON) .syHPtyOn .syLnkTmOp 24 Timeout for data link R/W .syLnkT0 0 No timeout establishment for IrDA...
Page 401
Chapter 16. Extended Functions Item number DATA%, numeric data of Initial Attribute System menu item the system menu item value (PARA%) .syScnMark 38 Scanning range – 0 Normal mode (Driven by the marker trigger switch) (BHT-100Q) – 1 Fixed to ON –...
Page 402
Write numeric data to System Mode settings .fcSysISet Syntax: CALL "SYSTEM.FN3" .fcSysISet PARA%,DATA% Description: This function writes numeric data ( ) to the system menu item DATA% specified by PARA% Parameter: PARA% Item number of the system menu Numeric data to be specified DATA% (See the system menu items list given in Function #1.) Returned value:...
Page 403
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...
Page 404
Get font information .fcFontInf 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: Number of fonts N.FONT% VERSION$ Sets of the font name, font size, and font version in the following format Font name Font size...
Page 405
Chapter 16. Extended Functions Get link status between the BHT and the LAN-support .fcCLkGet Syntax: CALL "SYSTEM.FN3" .fcCLkGet STATE% Description: This function returns the link status ( ) of the latest communi- STATE% cation between the BHT and the LAN-support CU. Parameter: (None) Returned value:...
Page 406
Place the LAN-support CU in system reconfiguration .fcCMdRqst 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 "...
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: Draw a dot .fcDot Draw a full line .fcLine Draw a dotted line .fcDtLine Draw a filled rectangle .fcRectFil Draw a rectangle .fcRect...
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% on the LCD. COLOR% Parameter: POINT% Coordinates to locate a dot X-coordinate (0≤POINT%(0)≤199) POINT%(0)
Page 409
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% COLOR% on the LCD. Parameter: RECT%() Coordinates to define a line Initial X-coordinate (0≤RECT%(0)≤199)
Draw a dotted line .fcDtLine Syntax: CALL "CONSOLE.FN3" .fcDtLine RECT%(),PTN%, ATTRIB%,COLOR% Description: This function draws a dotted line specified by between two PTN% points specified by RECT%() according to the attributes specified by ATTRIB% COLOR% on the LCD. Parameter: RECT%() Coordinates to define a line Initial X-coordinate (0≤RECT%(0)≤199) RECT%(0)
Chapter 16. Extended Functions Run-time errors: Error code Meaning Parameter out of the range Mismatch parameter number Mismatch parameter type 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...
Page 412
Parameter: RECT%() Coordinates to define a rectangle Initial X-coordinate (0≤RECT%(0)≤199) RECT%(0) Initial Y-coordinate (0≤RECT%(1)≤303) RECT%(1) Final X-coordinate (0≤RECT%(2)≤199) RECT%(2) Final Y-coordinate (0≤RECT%(3)≤303) RECT%(3) ATTRIB% Drawing attributes* Draw a line in the color specified by .cnColor COLOR% Draw a line in reverse display in the cur- .cnInvert rent color COLOR%...
Page 413
Chapter 16. Extended Functions Draw a rectangle .fcRect Syntax: CALL "CONSOLE.FN3" .fcRect RECT%(),ATTRIB%, COLOR% Description: This function draws a rectangle defined by two diagonal points speci- fied by RECT%() according to the attributes specified by ATTRIB% COLOR% on the LCD. X-coordinate Initial coordinates...
Run-time errors: Error code Meaning Parameter out of the range Mismatch parameter number Mismatch parameter type 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% Get drawn dot state...
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 , to be enabled. DATA% Parameter: DATA% Number of function touch keys 0 (Disable all function touch keys) .cnFKey0 Enable 4 function touch keys...
Page 416
ATTRIB% Character attributes Regular-size .cnW1H1 Double-width .cnW2H1 Double-height .cnW1H2 Quadruple-size .cnW2H2 Returned value: (None) Run-time errors: Error code Meaning Parameter out of the range Mismatch parameter number Mismatch parameter type Create a user-defined touch key and set a character(s) to .fcUKey be displayed on the touch key Syntax:...
Chapter 16. Extended Functions ATTRIB% Character attributes Regular-size .cnW1H1 Double-width .cnW2H1 Double-height .cnW1H2 Quadruple-size .cnW2H2 Returned value: (None) Run-time errors: Error code Meaning 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.) Mismatch parameter number Mismatch parameter type Insufficient number of array variable elements...
Get coordinates on the touch screen that is pressed last .fcPnlGet 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 X-coordinate (0≤POINT%(0)≤199) POINT%(0) Y-coordinate (0≤POINT%(1)≤303) POINT%(1) Run-time errors: Error code...
Chapter 16. Extended Functions 16.4 Controlling system files (SYSMDFY.FN3) 16.4.1 Function Number List of SYSMDFY.FN3 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: Get version of BHT system reconfig file...
16.4.2 Detailed Function Specifications Get version of BHT system reconfig file .fcMdBVGet Syntax: CALL "SYSMDFY.FN3" FILE$, VERSION$ .fcMdBVGet Description: This function returns the version ( VERSION$ ) of the BHT system reconfig file specified by FILE$ Parameter: FILE$ Filename Returned value: VERSION$ Version, 4 characters fixed Run-time errors:...
Page 421
Chapter 16. Extended Functions Get filename of BHT system reconfig file .fcMdBNGet 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$ Filename consisting of drive name and file name, max. 14 characters (No drive name might be returned.) Returned value: (None)
Page 422
Reconfigure CU system .fcMdCDo 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$ Filename Returned value: (None) Note: Before using this function, you need to (1) open the IrDA communica- tions device file with OPEN "COM:"...
Chapter 16. Extended Functions 16.5 Calculating a CRC (CRC.FN3) 16.5.1 Function Number List of CRC.FN3 may calculate a CRC depending upon the function number specified, as listed CRC.FN3 below. Function number Used to: Calculate a CRC-CCITT. .fcCcitt Calculate a CRC-16. .fcCrc16 16.5.2 Detailed Function Specifications Calculate a CRC-CCITT...
Page 424
Calculate a CRC-16 .fcCrc16 Syntax: CALL "CRC.FN3" .fcCrc16 STRING1$, [ STRING2$, [...,]] CRC$ Description: This function calculates a CRC of character strings specified by , ... and returns the calculation STRING1$ STRING2$ STRING8$ result in CRC$. Up to eight character strings may be specified by assigning them to non-array string variables.
Page 425
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.1 Overview ..................
Shown below is an example of the spread spectrum system configuration using the BHT. For details, refer to the BHT User’s Manual. Access point (master) BHT (station) Host computer Domain: 0 Domain: 0 Security ID: DENSO Security ID: DENSO Channel: 1 Sub channel: 1 + / Roaming function...
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 spec- trum communications device built in the BHT changes. Spread spectrum Communication communications device Open (power on) Impossible...
17.2 Programming for Spread Spec- trum Communication When programming for spread spectrum communication, use the following statement and extension functions: statement ( OPEN OPEN "COM3:" Refer to Section 17.3, "Spread Spectrum Communications-related Statement." (2) Spread spectrum library ( ) for controlling the spread spectrum communications SS.FN3 device Refer to Section 17.4, "Spread Spectrum Communication Library (SS.FN3)."...
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) 17.3 Spread Spectrum Communica- tions-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 Communica- tion Library (SS.FN3) 17.4.1 Overview The spread spectrum communication library ( ) used in a BHT-BASIC statement SS.FN3 CALL 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.
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) 17.4.2 Detailed Function Specifications Read integer from the wireless block parameter .fcParaIGet Syntax: CALL "SS.FN3" .fcParaIGet PARA%,DATA% Description: This function reads integer ( ) from the wireless block setting speci- DATA% fied by PARA%...
Page 432
Read string from the wireless block parameter .fcParaSGet Syntax: CALL "SS.FN3" .fcParaSGet PARA%,DATA$ Description: This function reads string ( DATA$ ) from the wireless block setting speci- fied by PARA% Parameters: Item number PARA% Returned value: DATA$ String read from the specified wireless block setting Correspondence table: Item number Wireless block...
Page 433
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) Write integer to the wireless block parameter .fcParaISet Syntax: CALL "SS.FN3" .fcParaISet PARA%,DATA% Description: This function writes integer ( ) to the wireless block setting specified DATA% PARA% Parameters:...
Page 434
.fcParaSSet Write string to the wireless block parameter Syntax: CALL "SS.FN3" .fcParaSSet PARA%,DATA$ Description: This function writes string ( ) to the wireless block setting specified DATA$ PARA% Parameters: Item number PARA% Returned value: DATA$ String to be written to the specified wireless block setting Correspondence table: Item number Wireless block...
Page 435
Chapter 17. Spread Spectrum Communication (For models equipped with a spread spectrum wireless block) Check wireless block synchronization with master .fcSyncInf Syntax: CALL "SS.FN3" .fcSyncInf TIMEOUT%,ASSOC% Description: This function checks whether the wireless block is synchronized with the master. According to the timeout length specified by TIMEOUT% , the system oper- ates as follows:...
Page 436
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 ............431 18.2.1 General Procedure ................431 [ 1 ] Configure Spread Spectrum Communications Device ....
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 com- munication system, respectively.
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 set- tings in System Mode or by using the extension library in a user program: SS.FN3...
[ 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 ].
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)."...
[ 5 ] Check Spread Spectrum Communications Device Syn- chronization with Master Using a spread spectrum communications device for TCP/IP communication requires synchro- nizing with the master (e.g., access point). To check the synchronization, use the extension library SS.FN3 In any of the following cases, a spread spectrum communications device may not be synchro- nized with the master: •...
Chapter 18. TCP/IP [ 6 ] Connect to TCP/IP Communications Pathway Use the extension library . Connecting to the TCP/IP communications pathway SOCKET.FN3 requires the following settings (specified in [ 2 ]): • IP address • Subnet mask • Default gateway There are two ways to specify these parameters.
[ 8 ] Disconnect TCP/IP Communications Pathway Use the extension library . Refer to Section 18.6, "Socket Library SOCKET.FN3 (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%.
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.
Page 446
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 Communica- tion If TCP/IP communication becomes no longer possible during data transmission, any of the fol- lowing run-time errors will be returned: Run-time errors: Error code Meaning Power-off detected. (The BHT has been turned off during data 105h transmission and then turned on.
Page 448
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 repeat- edly 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: ’ Main program on error goto Err.TCP ’ Prepare for error interrupt (To Err.TCP ’ at the time of error occurrence) open "COM3:" as #hCom3% ’ Open a spread spectrum communications device ’ Use the OPEN "COM3:" statement sock.stts% = 1 ’...
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-Sup- port System To communicate with the LAN-support CU, specify the following system settings in System Mode or by using the extension library SYSTEM.FN3 in a user program:...
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 •...
[ 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)."...
Chapter 18. TCP/IP [ 5 ] Connect to TCP/IP Communications Pathway Use the extension library . Connecting to the TCP/IP communications pathway SOCKET.FN3 requires the following settings (specified in [ 2 ]): • IP address • Subnet mask • Default gateway There are two ways to specify these parameters.
[ 7 ] Disconnect TCP/IP Communications Pathway Use the extension library . Refer to Section 18.6, "Socket Library SOCKET.FN3 (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%.
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 Communica- tion 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]...
Page 457
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"...
Chapter 18. TCP/IP 18.4 Socket API 18.4.1 Overview 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 proto- cols required for the TCP/IP transport layer: transmission control protocol (TCP) for streams and user datagram protocol (UDP) for datagrams.
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.
Page 462
’Initialize socket identifier set ’<----- Equivalent to BSD4.4 socket API FD_ZERO macro CALL "SOCKET.FN3" .fcFDZERO R.SOCKSET$ ’Initialize read socket identifier set CALL "SOCKET.FN3" .fcFDZERO W.SOCKSET$ ’Initialize write socket identifier ’set CALL "SOCKET.FN3" .fcFDZERO E.SOCKSET$ ’Initialize exception socket ’identifier set ’Add socket identifier to read socket identifier set ’<----- Equivalent to BSD4.4 socket API FD_SET macro CALL "SOCKET.FN3"...
Page 463
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.SOCKSET$[41] ’Exception socket ID set ’************************************************...
Page 464
’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...
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)." 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.
Page 466
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"...
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.
Page 468
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...
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.
[ 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.
Page 471
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 ← Specified length Record 1 CR LF ← Short CR LF Record 2 ← Short, with trailing spaces Record 3 Spaces CR LF...
Page 472
Line delimiters inside data records The FTP client can send and receive all codes from 00h to FFh as described above. The treat- ment 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. Specified record length Record n2 Record n1...
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. Configure the FTP client with the extension library FTP.FN3 Use the function to check whether there is sufficient free memory available to hold...
[ 3 ] Calculating Memory Requirements The FTP protocol specifications do not provide for checking the amount of BHT memory avail- able during downloads. If the BHT runs out of memory during a download, the FTP client can- cels the transfer and deletes the partially downloaded file. The user application program must, therefore, check availability with the 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 ÷...
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 min. 15 IPADDRESS$ Subnet mask min. 15 SUBNETMASK$ Default gateway min.
Page 477
Chapter 18. TCP/IP Function Number List Corresponding Number Used to: Socket API Function –– accept() .fcAccept Assign address to socket bind() .fcBind Connect socket connect() .fcConnect –– getpeername() .fcGPName –– getsockname() .fcGSName Get socket option getsockopt() .fcGSckOpt Convert host long (4 bytes) to network byte htonl() .fcHToNL order...
Page 478
Corresponding Number Used to: Socket API Function Create socket socket() .fcSocket –– writev() .fcWritev Close socket close() .fcClose Specify TCP/IP communications pathway Unique to BHT .fcTSetup Connect TCP/IP communications pathway Unique to BHT .fcTCnnSys with system settings Connect TCP/IP communications pathway Unique to BHT .fcTCnnUsr with user settings...
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 ADDRESS 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.
Page 480
Connect socket .fcConnect Syntax: CALL "SOCKET.FN3" .fcConnect SOCKFD%, FAMILY%, PORT%, address where address ADDRESS 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. Parameters: Socket identifier SOCKFD%...
Page 481
Chapter 18. TCP/IP Get socket option .fcGSckOpt Syntax: CALL "SOCKET.FN3" .fcGSckOpt SOCKFD%, OPTNAME%, option where option OPTION% 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.
Page 482
Convert host long (4 bytes) to network byte order .fcHToNL 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.
Page 483
Chapter 18. TCP/IP Convert network short (2 bytes) to host byte order .fcNToHS 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.
Page 484
Run-time errors: Error code Meaning Power-off detected 105h An internal error has occurred in the TCP/IP module during data 106h transmission. The TCP/IP module has not been initiated. 107h The memory for the TCP/IP module has became insufficient dur- 108h ing data transmission.
Page 486
Example: Overwrite operation Incoming data: 1024 bytes ("0123456789..0123") Receive buffer: 8 elements, 128 characters each for a total of 1024 bytes • After initializing receive buffer [ Strings ] 125 126 127 128 Element 0 – – – – – –...
Page 487
Chapter 18. TCP/IP Receive data sent to the specified UDP socket .fcRcvfrom Syntax: CALL "SOCKET.FN3" .fcRcvfrom SOCKFD%, RECVBUFF$[()], RECVLEN%, RECVMODE%, FAMILY%, PORT%, address, RECVSIZE% [,RECVFLAG%] where address ADDRESS IPADDRESS$ Description: This function receives data sent to the UDP socket specified by the socket identifier.
Page 488
Run-time errors: Error code Meaning Power-off detected 105h An internal error has occurred in the TCP/IP module during data 106h transmission. The TCP/IP module has not been initiated. 107h The memory for the TCP/IP module has became insufficient dur- 108h ing data transmission.
Page 489
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.
Page 490
Initialize socket identifier set .fcFDZERO 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: Socket identifier set SOCKFDSET$ Return value: (None) Add socket identifier to socket identifier set .fcFDSET...
Page 491
Chapter 18. TCP/IP Get socket identifier status from socket identifier set .fcFDISSET Syntax: CALL "SOCKET.FN3" .fcFDISSET SOCKFD%, SOCKFDSET$, FDISSET% Description: This function gets the status of the specified socket identifier in the speci- fied socket identifier set. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API FD_ISSET macro.
Page 492
Run-time errors: Error code Meaning Power-off detected 105h An internal error has occurred in the TCP/IP module during data 106h transmission. The TCP/IP module has not been initiated. 107h The memory for the TCP/IP module has became insufficient dur- 108h ing data transmission.
Page 493
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 ADDRESS IPADDRESS$ Description: This function transmits data from the specified buffer to the IP address and port number connected to the specified socket identifier.
Page 494
Set socket options .fcSSckOpt Syntax: CALL "SOCKET.FN3" .fcSSckOpt SOCKFD%, OPTNAME%, option where option OPTION% 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.
Page 495
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: Socket identifier SOCKFD% HOWTO%...
Page 496
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.
Page 497
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: Socket identifier SOCKFD% Return value: (None) Run-time errors: Error code...
Page 498
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: Communications device IFTYPE% Link layer LAYERMODE% The communications device ( ) must be one of the following val- IFTYPE% ues: COM1 (IrDA communications device)
Page 499
Chapter 18. TCP/IP Connect TCP/IP communications pathway with system .fcTCnnSys settings Syntax: CALL "SOCKET.FN3" .fcTCnnSys INTERFACE% Description: This function connects the TCP/IP communications pathway based on the system settings. Parameters: INTERFACE% Communications pathway Return value: (None) Run-time errors: Error code Meaning Communications device file not open Cannot connect to communications pathway...
Page 500
Connect TCP/IP communications pathway with user set- .fcTCnnUsr tings Syntax: CALL "SOCKET.FN3" .fcTCnnUsr INTERFACE%, IPADDRESS$, SUBNETMASK$, GATEWAY$ Description: This function connects the TCP/IP communications pathway based on the supplied user settings. Parameters: INTERFACE% Communications pathway Internet address in dotted quad notation IPADDRESS$ SUBNETMASK$ Subnet mask in dotted quad notation...
Page 501
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% Communications pathway Return value: (None) Run-time errors: Error code Meaning Communications pathway already disconnected 104h Power-off detected 105h A parameter is invalid.
Page 502
Set TCP/IP system settings .fcTSysSet Syntax: CALL "SOCKET.FN3" .fcTSysSet PARA%, data where data DATA% DATA$ Description: This function sets the specified TCP/IP system settings to the new value. Parameters: PARA% Item number New setting for TCP/IP system settings ( data DATA /DATA$ Return value:...
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 Login user name 0 to 16 USERNAME$ Login password 0 to 16...
Page 504
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 Restart marker replay. Service ready in nnn minutes.
Page 505
Chapter 18. TCP/IP Reply Codes Description Connection closed; transfer aborted. Requested file action not taken. File unavailable (e.g., file busy). Requested action aborted: local error in processing. Requested action not taken. Insufficient storage space in system. Syntax error, command unrecognized. This may include errors such as command line too long.
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. Parameters: (None) Return value: FTP client handle, for use by following functions FTPHANDLE% REPLY% Server response to FTP command...
Page 507
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 set- tings. Parameters: FTP server IP address in dotted quad notation SERV.IP$ User name for FTP authentication USERNAME$...
Page 508
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 Power-off detected 105h An internal error has occurred in the TCP/IP module during data 106h...
Page 509
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$ FTP server current directory REPLY% Server response to FTP command Run-time errors:...
Page 510
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% FTP client handle NEWDIR$ New directory Return value: Server response to FTP command REPLY% Run-time errors: Error code...
Page 511
Chapter 18. TCP/IP Download file from FTP server .fcRETR 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: FTP client handle FTPHANDLE%...
Page 512
FLD$ Field lengths in bytes. Delimit the field length specifi- cations with commas (,) or semicolons (;). (This parameter applies only to downloaded data files.) "<field length 1> [,<field length 2>,... <field length n>]" (n=1 to 16, field length = 1 to 254) Flag controlling a progress display consisting of an 8- DISP.MODE% digit number giving the number of bytes transferred...
Page 513
Chapter 18. TCP/IP Run-time errors: Error code Meaning Syntax error (Incorrect file name) Number of field items or number of digits in a field out of the range Insufficient memory space Wrong file type Invalid text received File already open Too many files Record exceeds 255 bytes.
Page 514
Upload file to FTP server .fcSTOR 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: FTP client handle FTPHANDLE% SERV.FNAME$...
Page 515
Chapter 18. TCP/IP Run-time errors: Error code Meaning File not found File already open User break with cancel (C) key Power-off detected 105h An internal error has occurred in the TCP/IP module during data 106h transmission. The TCP/IP module has not been initiated. 107h The memory for the TCP/IP module has became insufficient dur- 108h...
Page 516
Get FTP system settings .fcFSysGet Syntax: CALL "FTP.FN3" .fcFSysGet PARA%, ftp.para where ftp.para FTP.PARA% FTP.PARA$ Description: This function gets the current setting for the specified FTP system settings. Parameters: Item number PARA% Return value: ftp.para Current setting for FTP system settings of type integer/ string ( FTP.PARA%/FTP.PARA$ Correspondence tables:...
Page 517
Chapter 18. TCP/IP Change FTP system settings .fcFSysSet Syntax: CALL "FTP.FN3" .fcFSysSet PARA%, ftp.para where ftp.para FTP.PARA% FTP.PARA$ Description: This function changes the specified FTP system settings to the new value. Parameters: Item number PARA% New setting for FTP system settings of type integer/ ftp.para string ( FTP.PARA%/FTP.PARA$...
Page 518
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% FTP client handle Port number PORT% Return value: (None) Run-time errors: Error code Meaning Power-off detected 105h...
Page 519
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$ from the FTP server. Parameters: FTP client handle FTPHANDLE% File name to be deleted SERV.FNAME$ Return value: Server response to FTP command REPLY%...
Page 520
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 ................527 C1. Character Set ................. 527 C2. National Character Sets ..............528 Appendix D I/O Ports ..................
Appendices Appendix A Error Codes and Error Messages A1. Run-time Errors Error code Meaning Internal system error NEXT without Syntax error RETURN without GOSUB Out of DATA DATA values remain to be read by the READ statement.) Parameter out of the range The operation result is out of the allowable range.
Page 522
Error code Meaning Improper file type (The statement attempts an operation that conflicts with the file type- -data file, communications device file, or bar code device file.) File already open OPEN statement executed for the already opened file.) The file name is different from that in the receive header. Too many files File number out of the range The number of the records is greater than the defined maximum...
Page 523
Appendices Error code Meaning Communications pathway already connected 103h Communications pathway already disconnected 104h Power-off detected 105h An internal error has occurred in the TCP/IP module during data 106h transmission. The TCP/IP module has not been initiated. 107h The memory for the TCP/IP module has became insufficient during 108h data transmission.
Page 524
Error code Meaning There is no user for login request. 295h Failed to get the setting value (Failed to set the value) 400h Failed to open a spread spectrum communications device file 401h The CU has been linked with any other BHT. 503h LAN-support CU setting being made.
Page 526
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...
Page 527
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 vari- able name) error 6: Variable name redefinition...
Page 528
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...
Page 529
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:...
Page 530
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: ’(’...
Page 531
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...
Page 532
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: •...
Page 533
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 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. FIELD POWER APLOAD PRINT PRINT# BCC$ READ BEEP GOSUB RECORD CALL GOTO CASE RESTORE CHAIN...
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 state- ment.
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, respec- tively.
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 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. Port No.
Page 538
Port No. assign- Monitors the following: ment Software keyboard Disabled .pnAlpCtrl .pvAlpOff function Enabled .pvAlpOn Software keyboard Hidden display Displayed .pvAlpDisp Software keyboard Lower area .pvAlpBotm display position on Upper area .pvAlpTop the screen Software keyboard Not allowed movement Allowed .pvAlpMove Wakeup function Deactivated...
Page 539
Appendices Port No. assign- Monitors the following: ment Magic key 1 Released .pnMKey 6040h Held down .pvM1kyOn Magic key 2 Released Held down .pvM2kyOn Magic key 3 Released Held down .pvM3kyOn Magic key 4 Released Held down .pvM4kyOn Communications BHT-protocol .pnCmPrtcl 6060h .pvCPBHT...
Page 540
Port No. assign- Monitors the following: ment Execution record of Woken up .pnRwuHost 60F2h .pvRwuRgst remote wakeup remotely Termination of Terminated nor- .pvRwuEdOk remote wakeup mally Timeout for remote .pnRwuWtT 60F3h 1-255 (sec) wakeup Screen mode ANK mode .pnScrnMdL 6110h Kanji mode .pvScMB Screen font size...
Page 541
Appendices Port No. assign- Monitors the following: ment Scanning range Normal mode .pnScnMark 6320h marker (Driven by the (BHT-100Q/BHT- trigger switch) 100QF only) Fixed to ON Fixed to OFF 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.
Page 542
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"...
Page 543
Appendices Output Ports A user program can control the hardware through the output ports by using the 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. Port No.
Page 544
Port No. assign- Controls the following: ment LCD backlight Deactivate .pnBLight 6022h Activate .pvBLLcd Key backlight Deactivate Activate .pvBLKey Effective held- .pnTmPOff 6030h 1-255 down time of power key Communications BHT-protocol .pnCmPrtcl 6060h .pvCPBHT protocol BHT-Ir protocol .pvCPBHTIr ID (lower byte) .pnBHTIDL 6061h 0-255...
Page 545
Appendices Port No. assign- Controls the following: ment Transmission 9600 bps .pnRwuSpd 60F1h .pvRwu96 speed for remote 19200 bps .pvRwu192 wakeup 38400 bps .pvRwu384 57600 bps .pvRwu576 115200 bps .pvRwu1152 Execution record of Woken remotely .pnRwuHost 60F2h .pvRwuRgst remote wakeup Termination of Terminated normally .pvRwuEdOk...
Page 546
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 function after selection of the wakeup time will automatically reset TIME$ this bit to zero.
Page 547
Appendices 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 defrag- mentation, 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 Default Data Assignment The default data assignment is shown below. Non-shift mode Shift mode BS, CR, and C are a backspace (08h), carriage return (0Dh), and cancel (18h) code, respectively.
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 This area may be used JIS Level 1 font, 16-dot (120 KB) as a user area if you JIS Level 2 font, 16-dot (112 KB) delete these fonts.
Page 550
The size and area allocation of the memory incorporated in the BHT differ depending upon the models as listed below. BHT series Models User area BHT-100 BHT-102B 1900 BHT-102BF BHT-103Q 4524 BHT-103QF Plus 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."...
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.
Page 552
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:...
Page 553
Appendices Example 3 When specifying a field data to be searched, do not include trailing spaces in a data field. Send data Receive data Data to be searched Search data to be specified denotes a space character.)
Page 554
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.
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.
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.
Page 557
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.
Page 558
Testing the written function while 1 ’Infinite loop a$ = fnbarkey$ (1, "A", 15, "DL") ’F4 and SFT/F4 as escape characters. print if a$<>"D" and a$<>"L" then print "Data="; a$ else print "ESC(";a$;") key push" endif wend...
Appendices Appendix J Quick Reference for Statements and Functions Controlling program flow Statements CALL Calls an function. Transfers control to another program. CHAIN Terminates program execution. Defines a loop containing statements to be exe- … NEXT cuted a specified number of times. Branches to a subroutine.
Page 560
Handling errors Statements Enables error trapping. ON ERROR GOTO Causes program execution to resume at a speci- RESUME fied location after control is transferred to an error- handling routine. Functions Returns the current statement location of the pro- gram where a run-time error occurred. Returns the error code of the most recent run-time error.
Page 561
Appendices Controlling the LCD screen Statements Loads a user-defined font in the single-byte ANK APLOAD mode. Clears the LCD screen. Turns the cursor on or off. CURSOR Assigns a string or a control code to a function key; also defines a function key as a backlight function on/off key.
Page 562
Controlling the keyboard input Statements Reads input from the keyboard into a variable. INPUT 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 key- board display key.
Page 563
Appendices Communicating with I/Os Statements Sends a data byte to an output port. Controls the automatic power-off facility. POWER Pauses program execution until a designated input WAIT port presents a given bit pattern. Functions Returns the number of bytes available in a speci- fied area of the memory.
Page 564
Manipulating data files and user program files Statements Erases the data stored in a data file. CLFILE Closes file(s). CLOSE Allocates string variables as field variables. FIELD Reads a record from a data file. Deletes a specified file from the memory. KILL Opens a data file for I/O activities.
Page 565
Appendices Functions Returns a block check character (BCC) of a data BCC$ block. Tests whether the end of a device I/O file has been reached. Modifies the value of a terminator (ETX) for the ETX$ BHT-protocol; also returns the current value of a terminator.
Page 566
Manipulating string data Functions Returns the ASCII code value of a given character. Returns the character corresponding to a given CHR$ ASCII code. Converts a decimal number into the equivalent HEX$ hexadecimal string. Searches a specified target string for a specified INSTR search string, and then returns the position where the search string is found.
Appendices Appendix K Unsupported Statements and Functions BHT-BASIC does not support the following MS-BASIC statements and functions: - For handling sequential data files MKD$ PRINT# USING MKI$ RSET MKS$ WRITE# LSET PRINT# - For RS-232C interface operation PRINT# USING WRITE# - For interrupt handling COM OFF ON STOP GOSUB...
Need help?
Do you have a question about the BHT-BASIC 100 SERIES and is the answer not in the manual?
Questions and answers