Copyright © 2003 DENSO WAVE INCORPORATED All rights reserved. No part of this publication may be reproduced in any form or by any means without permission in writing from the publisher. Specifications are subject to change without prior notice. Microsoft, MS-DOS, Windows, and WindowsNT are registered trademarks of Microsoft Corporation. TM Bluetooth is a trademark owned by its proprietor and used by DENSO WAVE under license. BHT is a trademark of DENSO CORPORATION.
Preface This manual describes the syntax and development procedure of BHT-BASIC 3.5 which is a programming language for developing application programs of the BHT-8000. It is intended for programmers who already have some experience in BASIC programming. For the basic description about the BASIC language, refer to documentations concerning Microsoft BASIC ® or QuickBASIC ® . For the details about Windows™, refer to the Microsoft Windows documentations.
How this book is organized This manual is made up of 16 chapters and appendices. Chapter 1. Software Overview for the BHT Surveys the software structure of the BHT and introduces the programs integrated in the ROM and the language features of BHT-BASIC. Chapter 2. Development Environment and Procedures Describes hardware and software required for developing application programs and the developing procedure. Chapter 3.
Chapter 12. PowerPower-related Functions Describes low battery warning, the prohibited simultaneous operation of the beeper / illumination LED, the wakeup, and remote wakeup. Chapter 13. Backlight Function Describes the backlight function Chapter 14. Statement Reference Describes the statements available in BHT-BASIC, including the error codes and messages. Chapter 15. Function Reference Describes the functions available in BHT-BASIC, including the error codes and messages. Chapter 16.
Notational Conventions Used in This Book Several notational conventions are used in this book for the sake of clarity. 1. Reserved words are printed in UPPERCASE. These are BHT-BASIC’s keywords. You should not use them as label names or variable names. Example: CHAIN, GOSUB, and ABS 2. Parameters or arguments which should be specified in the statements or functions are expressed in italics. Example: characode and onduration 3. Items enclosed in square brackets [ ] are optional, which can be omitted.
Icons Used in This Book Statements and functions unique to BHT-BASIC. Syntax for the Statement Reference and Function Reference The syntax in programming is expressed as shown in the example below.
Abbreviations ANK Alpha-Numeric and Katakana BASIC Beginners All purpose Symbolic Instruction Code BCC Block Check Character BHT Bar code Handy Terminal CTS(CS) Clear To Send (RS-232C signal control line) CU Communication Unit I/F Interface I/O Input/Output LCD Liquid Crystal Display LED Light-Emitting Diode MOD Modulo MS-DOS Microsoft-Disk Operating System RAM Random Access Memory ROM Read Only Memory RTS(RS) Request To Send (RS-232C signal control line) VRAM Video RAM Relat
Chapter 1 Software Overview for the BHT CONTENTS 1.1 Software Overview .................................................................................................. 2 1.1.1 Software Structure of the BHT....................................................................... 2 1.1.2 Overview of BHT-BASIC ............................................................................... 4 1.2 BHT-BASIC .......................................................................................................
1.1 Software Overview 1.1.1 Software Structure of the BHT The structure of software for the BHT is shown below. Flash memory User programs User data Application programs Extension libraries and extended functions System Mode System programs BHT-BASIC Interpreter Font files Drivers Hardware The BHT has a flash memory and RAM. All of the system programs, user programs, extension libraries, and extended functions are stored in the flash memory. The RAM is used to run those programs efficiently.
Chapter 1. Software Overview for the BHT □System Programs Drivers A set of programs which is called by the BHT-BASIC Interpreter or System Mode and directly controls the hardware. The drivers include the Decoder Software used for bar code reading. BHTBHT-BASIC Interpreter Interprets and executes user programs. System Mode Sets up the execution environment for user programs.
1.1.2 Overview of BHT-BASIC With BHT-BASIC, you can customize application programs for meeting your specific needs as given below. - Retrieving products names, price information, etc. in a master file. - Making a checking procedure more reliable with check digits in bar code reading. - Improving the checking procedure by checking the number of digits entered from the keyboard. - Calculating (e.g., subtotals and totals).
Chapter 1. Software Overview for the BHT 1.2 BHT-BASIC 1.2.1 Features BHT-BASIC is designed as an optimal programming language in making application programs for the bar code handy terminal BHT, and to enable efficient program development, with the following features: Syntax Similar to Microsoft™ BASIC BHT-BASIC uses the BASIC language which is the most widely used one among the high-level languages. The syntax of BHT-BASIC is as close as possible to that used in Microsoft BASIC(MS-BASIC).
1.2.2 What’s New in BHT-BASIC 3.5 Upgraded from BHT-BASIC 3.0? Based on BHT-BASIC 3.0, BHT-BASIC 3.5 newly supports the following functions: [ 1 ] Compiler Object linkage editor, Linker While BHT-BASIC 3.0 Compiler compiles a single source program into a single user program, BHT-BASIC 3.5 Compiler can convert more than one source program into individual object programs (intermediate code files for a user program) and then combine them together through Linker to build a user program.
Chapter 1. Software Overview for the BHT Defining and declaring useruser-defined functions functions more easily BHT-BASIC 3.5 has added FUNCTION…END FUNCTION, SUB...END SUB, and DECLARE statements. With the former two, you may easily define your own functions—FUNCTION and SUB. With the latter one, you may declare FUNCTION and SUB functions which are defined in any other source files. Scoping variables to be local or global (with PRIVATE or GLOB GLOBAL AL statement) In BHT-BASIC 3.
1.3 Program Development and Execution BHT-BASIC consists of Compiler and Interpreter. 1.3.1 Compiler BHT-BASIC 3.5 Compiler consists of the following Compiler, Linker and Librarian: Compiler Compiler, which is one of the development tools, compiles source programs written on a PC into the resulting "object files." It checks syntax of source programs during compilation and makes an error file if any syntax error is found.
Chapter 2 Development Environment and Procedures CONTENTS 2.1 Overview of Development Environment................................................................ 11 2.1.1 Required Hardware ..................................................................................... 11 2.1.2 Required Software....................................................................................... 12 2.2 Overview of Developing Procedures..................................................................... 13 2.2.
2.4.7 Options........................................................................................................ 30 [ 1 ] Compiling options ............................................................................... 30 [ 2 ] Linking options.................................................................................... 31 [ 3 ] Outputting debug information files ...................................................... 31 [ 4 ] Outputting list files ...............................................
Chapter 2. Development Environment and Procedures 2.1 Overview of Development Environment The following hardware and software are required for developing user programs: 2.1.1 Required Hardware Personal computer Use a computer operating with Windows95/98/NT/2000/XP. BHT (Bar code handy terminal) - BHT-8000 series CU (Optical communications unit) For IrDA communication, the following CU is required.
2.1.2 Required Software • OS Windows95/98/NT/2000/XP • Editor • BHT-BASIC 3.5 Compiler • Transfer Utility (option) • Ir-Transfer Utility C (option) BHTC35W.EXE BHT35CPL.DLL (Integrated environment manager) BHT35LNK.DLL (Compiler) BHT35LIB.DLL (Linker) BHTC35W.MSG (Librarian) TU3.EXE (Error message file) TU3W.EXE (MS-DOS-based) TU3W32.EXE (16-bit Windows-based) IT3C.EXE IT3CW32.EXE • Ir-Transfer Utility E (option) IT3EW32.
Chapter 2. Development Environment and Procedures 2.2 Overview of Developing Procedures 2.2.1 Developing Procedures The program developing procedures using BHT-BASIC 3.5 are outlined below. - Making source programs Make source programs with an editor according to the syntax of BHT-BASIC. - Producing a user program (compiling and linking) Compile the source programs into object programs by BHT-BASIC Compiler.
2.2.2 Functions of BHT-BASIC 3.5 BHT-BASIC 3.5 contains Compiler, Linker, and Librarian whose functions are listed below. Functions of Compiler Description Syntax check Detects syntax errors in source programs. Output of object files Translates source programs into object files and outputs them. Output of debug information Outputs list files and debug information files required for debugging.
Chapter 2. Development Environment and Procedures 2.3 Writing a Source Program 2.3.1 Writing a Source Program by an Editor To write a source program, use an editor designed for operating environments where the BHT-BASIC 3.5 Compiler will execute. The default editor is Windows Notepad. TIP To write a source program efficiently, use of a commercially available editor is recommended. For the operation of such an editor, refer to the instruction manual for the editor. 2.3.
• Comment lines starting with a single quotation mark (') and those with a REM should have the following description rules each. A single quotation mark (') can be put starting from the 1st or the following columns, or immediately following any other statement. A REM should be put starting from the 2nd column or the following columns. To put a REM following any other statement, a colon (:) should precede the REM.
Chapter 2. Development Environment and Procedures 2.4 Producing a User Program 2.4.1 Starting the BHT-BASIC 3.5 Compiler Start the Compiler, e.g., by choosing the "BHTC35W.EXE" from the Windows Explorer or the "BHT-BASIC 3.5" registered to the Start menu. Menu bar Tool bar Main window The BHT-BASIC 3.
2.4.2 Outline of User Program or Library Production Procedure Unlike the BHT-BASIC 3.0 Compiler that converts a single source program into a user program (file named XXX.PD3), the BHT-BASIC 3.5 Compiler converts source programs into object pro-grams (files named XXX.OBJ) and then links those object programs to produce a user program (XXX.PD3). A sequence of the compiling and linking processes is called "Build." The BHT-BASIC 3.5 Compiler can also build a library (XXX.LIB).
Chapter 2. Development Environment and Procedures 2.4.3 Designating a Single Source File or a Project File 2.4.3.1 Designating a single source file Just as in the conventional BHT-BASIC 3.0 Compiler, you may designate a single source file to build a user program or library. [ 1 ] Select a source file (1) In any of the following methods, display the Open File dialog box shown below: From the File menu, choose the Open command. Click the open file button in the toolbar.
2.4.3.2 Designating a project file To build a library out of a single source file or to build a user program or library out of multiple source files, you need to create a project file (described in [ 1 ] later) or select an existing project file (in [ 2 ]). You may add files or delete existing files to/from the designated project file (described in [ 3 ] and [ 4 ], respectively).
Chapter 2. Development Environment and Procedures [ 2 ] Select an existing project file You may select an existing project file in the Select Project File dialog box or in the Open File dialog box. Selecting in the Select Project File dialog box (1) In any of the following methods, display the Select Project File dialog box shown below: From the File menu, choose the Open Project command. Click the open project button (yellow) in the toolbar. While holding down the Ctrl key, press the P key.
[ 3 ] Add files to a project file You may add one or more source files and libraries to a project file at a time. (1) Create a new project (Refer to [ 1 ] in this subsection) or select an existing project file to which you want to add files (Refer to [ 2 ] in this subsection). (2) In either of the following methods, display the Add File(s) dialog box shown below: From the Project menu, choose the Add File command. Click the add file button in the toolbar.
Chapter 2. Development Environment and Procedures [ 4 ] Select files in the active project From files existing in the active project, you may select files that you want to compile or build. (1) In either of the following methods, display the Project Configuration Files dialog box shown below: From the Project menu, choose the Select File command. Click the select file button (red) in the toolbar.
• Main Object display area This area shows the name of a main object in a user program if you have selected "User program (PD3)" with the "Type of File to be Created" selection button. If you have selected "Create library (LIB)," nothing will appear on this area. • Type of File to be Created Lets you select whether you create a user program (PD3) or library (LIB). • Add File button Adds the currently selected files to the active project. (Refer to “[ 3 ] Add files to a project file.
Chapter 2. Development Environment and Procedures 2.4.4 Compiling and Building First specify the options and then proceed to the compiling or building process. [ 1 ] Specifying the compiling and linking options (1) In either of the following methods, display the Set Options dialog box shown below: From the Tools menu, choose the Options command. Click the option button in the toolbar. (2) Select the check boxes of the options you want to specify. For details about the options, refer to Subsection 2.4.
[ 2 ] Compiling In any of the following methods, compile the currently selected source file(s) into an object file(s): From the Build menu, choose the Compile command. In the Project Configuration Files dialog box, click the Compile button. (For details about the Project Configuration Files dialog box, refer to Subsection 2.4.3.2, [ 4 ].) Click the compile start button in the toolbar. While holding down the Ctrl key, press the G key. If compiling ends normally, the screen shown below will appear.
Chapter 2. Development Environment and Procedures 2.4.5 Setting the Editor for Displaying Files Set the editor that you want to use for displaying source files and error message files (XXX.ERR) according to the steps below. (1) From the Tools menu, choose the Set Editor command. The Set Editor dialog box appears as shown below. (2) In the Command line edit box, type the filename of the editor.
2.4.6 Error Messages and Their Indication onto the Main Window [ 1 ] Selecting either an editor or main window as an error message output device According to the procedure below, you may select whether error messages should be outputted to an editor or main window if an error message file (XXX.ERR) is produced. (1) From the Tools menu, choose the Options command. The Set Options dialog box appears as shown below.
Chapter 2. Development Environment and Procedures [ 2 ] How error messages are displayed on the editor or main window During building, the BHT-BASIC 3.5 Compiler may detect errors which can be divided into two types: syntax errors and fatal errors. Syntax errors If the Compiler detects a syntax error, it outputs the error message to the XXX.ERR file. For details about the file, refer to Subsection 2.4.9, "Output from the BHT-BASIC 3.5 Compiler.
2.4.7 Options To specify compiling options and linking options, select the check-box options you want in the Set Options dialog box. Each of available options is explained below. [ 1 ] Compiling options Compiling Options Debug information file Address-source List Symbol table X (Cross) reference Variable size Description Outputs debug information files (XXX.ADR, XXX.LBL, and XXX.SYM files). If this option is not selected, no debug information file will be outputted.
Chapter 2. Development Environment and Procedures [ 2 ] Linking options Linking Options Mapfile Description 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" check box in the Set Options dialog box and run the Compiler, then the Compiler will output three types of debug information files.
[ 4 ] Outputting list files The Compiler may output three types of list files as listed below depending upon the options specified at the start of compiling, in order to help you program and debug efficiently. List File Address-source list Symbol table Cross reference Option Filename Extension Select the Address-source List check box. Select the Symbol table check box. Select the X (Cross) reference check box. .
Chapter 2. Development Environment and Procedures • Address of object program in intermediate language Shows an intermediate language address corresponding to a source program line in four-digit hexadecimal notation. • Line number in source program Shows a line number for a source program statement in four-digit decimal notation. • Source program statement Shows the same content as a statement written in a source program.
• Symbol table for common variables variables Lists common variables arranged according to their types. An array variable has a suffix of parentheses ( ). • Symbol table for work variables variables Lists work variables and dummy arguments arranged according to their types. An array variable has a suffix of parentheses ( ). • Symbol table for register variables variables Lists register variables arranged according to their types. An array variable has a suffix of parentheses ( ).
Chapter 2. Development Environment and Procedures [ 5 ] Outputting a mapfile Select the Mapfile check box of the Linking Options in the Set Options dialog box and build a user program, and the mapfile as shown below will be outputted. The mapfile will be given the same name as the project file and annexed with an extension .MAP.
• Map for useruser-defined functions 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/NT/2000/XP. [ 1 ] Syntax At the MS-DOS command prompt, type in the following format: BHTC35W [options] [[directorypath]filename…][options] directorypath You may specify either an absolute path or relative path.
[ 2 ] Options The BHT-BASIC 3.5 Compiler supports three types of options—compiler processing options, compiling options, and linking option. Compiler Compiler processing options Processing options Description +C Compiles one or more designated file(s) into object file(s). +B programname Builds a user program with the specified program name. If no programname is specified, the filename specified first will apply. Builds a library with the specified library name.
Chapter 2. Development Environment and Procedures Compiling options Compiling options +D Description +D Outputs debug information files (XXX.ADR, XXX.LBL. and XXX.SYM files). (Same as you select the Debug information file check box in the Set Options dialog box. Refer to Subsection 2.4.7, [ 1 ].) Outputs an address-source list to the file XXX.LST. (Same as you select the Address-source List check box in the Set Options dialog box. Refer to Subsection 2.4.7, [ 1 ].) Outputs a symbol table to the file XXX.
[ 3 ] Error Level Indication by ERRORLEVEL If you specify a +E option at the command line and run the BHT-BASIC 3.5 Compiler, the ERRORLEVEL of MS-DOS allows the Compiler to set the compiling end status to the MS-DOS environmental variable ERRORLEVEL after completion of processing, as any of the error levels listed below. By referring to this ERRORLEVEL, you can learn the compiling end status. ERRORLEVEL Description 0 Normal end 1 No designated file or path found.
Chapter 2. Development Environment and Procedures 2.4.9 Output from the BHT-BASIC 3.5 Compiler The BHT-BASIC 3.5 Compiler outputs the following information as well as object programs to the destination depending upon the conditions. Output Destination Conditions Object file File XXX.OBJ (in the directory where the source program is located) User program File YYY.PD3 (in the directory where the project is located) Library file File YYY.
Output Address–Source list Symbol table Destination File XXX.LST (in the direcTory where the source pro-gram is located) Cross reference Sizes of variables Mapfile File XXX.ERR (in the directory where the source program is located) or File YYY.ERR (in the directory where the project is located) File YYY.MAP (in the direcTory where the project is located) XXX represents a source program filename. YYY represents a project name.
Chapter 2. Development Environment and Procedures 2.4.10 Structure of User Programs and Libraries If you specify a user program to be produced in the Project Configuration Files dialog box, the BHT-BASIC 3.5 Compiler produces a user program provided that no compiling error or link error occurs. The user program file will be given the same name as the project file and annexed with an extension .PD3.
2.5 Downloading 2.5.1 Overview of Transfer Utility/Ir-Transfer Utility C/Ir-Transfer Utility E Transfer Utility/Ir-Transfer Utility C/Ir-Transfer Utility E transfers user programs and data files (e.g., master files) between the BHT and the connected personal computer.
Chapter 2. Development Environment and Procedures 2.6 Executing a User Program 2.6.1 Starting To run a user program, start System Mode and select the desired program in the EXECUTE PROGRAM menu. If you have selected a user program as an auto-start execution program in the SET SYSTEM menu of System Mode, then the BHT will automatically run the program when turned on.
Chapter 3 Program Structure CONTENTS 3.1 Program Overview ................................................................................................ 47 3.1.1 Statement Blocks......................................................................................... 47 [ 1 ] Subroutines ........................................................................................ 47 [ 2 ] Error-/Event-handling Routines ..........................................................
Chapter 3. Program Structure 3.1 Program Overview 3.1.1 Statement Blocks A statement block is a significant set of statements (which is also called "program routine"). The following types of statement blocks are available in programming for the BHT: Statement Blocks Description Subroutine A routine called by the GOSUB statement. Error-/event-handling routine An error-/event-handling routine to which control is passed when an error trap or event (of keystroke) trap occurs, respectively.
[ 3 ] User-defined Functions Before calling user-defined functions, it is necessary to define those functions with any of the following statements. Generally, those statements should be placed before the main routine starts. DEF FN (in single-line form) DEF FN ..END DEF (in block form) SUB ..END SUB FUNCTION ..END FUNCTION When using SUB and FUNCTION functions written in other files, it is necessary to declare them with the DECLARE statement before calling them.
Chapter 3. Program Structure 3.1.2 Notes for Jumping into/out of Statement Blocks It is not recommended to jump control from a main routine or subroutines into the midst of significant statement blocks or to jump out from the midst of those statement blocks, using the GOTO statement. Statement Blocks Jump into Jump out × × × × × × × △ Subroutine Error-/event-handling routine Block-format user-defined function Block-structured statement ×: To be avoided. A run-time error may occur.
3.2 Handling User Programs 3.2.1 User Programs in the Memory The user area of the memory (memories) in the BHT can store more than one user program. (For details about memories, refer to Appendix F, "Memory Area.") If you have selected one of those programs as an execution program in the Setting menu of System Mode, the BHT automatically runs the user program when powered on. For the operating procedure of System Mode, refer to the BHT User’s Manual. 3.2.
Chapter 3. Program Structure 3.2.3 Included Files "Included files" are separate source programs which may be called by the INCLUDE metacommand. Upon encounter with the INCLUDE metacommand in a source program, the Compiler fetches the designated included file and then compiles the main source program while integrating that included file to generate a user program. You should specify the name of an included file by using the REM $INCLUDE or ’$INCLUDE.
Chapter 4 Basic Program Elements CONTENTS 4.1 Structure of a Program Line .................................................................................. 53 4.1.1 Format of a Program Line ........................................................................... 53 [ 1 ] Labels................................................................................................. 53 [ 2 ] Statements.......................................................................................... 54 [ 3 ] Comments ..
Chapter 4. Basic Program Elements 4.1 Structure of a Program Line 4.1.1 Format of a Program Line A program line consists of the following elements: [label] [statement] [:statement] ... [comment] • label A label is placed at the beginning of a program line to identify lines. • statement A statement is a combination of functions, variables, and operators according to the syntax. A group of the statements is a program. • comment You may describe comments in order to make programs easy to understand.
[ 2 ] Statements Statements can come in two types: executable and declarative statements. • Executable statements They make the Interpreter process programs by instructing the operation to be executed. • Declarative statements statements They manage the memory allocation for variables and handle comments. Declarative statements available in BHT-BASIC are listed below.
Chapter 4. Basic Program Elements 4.1.2 Program Line Length A program line is terminated with a CR code by pressing the carriage return key. The allowable line length is basically 512 characters excluding a CR code placed at the end of the line. In either of the following two description ways, however, you can write a program line of up to 8192 characters: In the samples below, symbol "" denotes a CR code entered by the carriage return key. • Extend a program line with an underline (_) and a CR code.
4.2 Usable Characters 4.2.1 Usable Characters Listed below are characters which can be used for writing programs. Note that a double quote (") cannot be used inside a character string. Symbols | and ~ inside a character string will appear as ↓and →on the LCD of the BHT, respectively. If used outside of a character string, symbols and control codes below have special meaning described in Subsection 4.2.2. • Alphabet letters Including both the uppercase and lowercase letters(A to Z and a to z).
Chapter 4. Basic Program Elements 4.2.
Symbols and control codes : (Colon) ; (Semicolon) [] (Square brackets) {} (Braces) # (Pound sign) Typical use • Separates statements. • Separates time information in TIME$ function. Line feed control character in INPUT and other statements. • Define the length of a string variable. • Define the string length of the returned value of a string userdefined function. Define the initial value for an array element. • File number prefix in OPEN, CLFILE, FIELD, and other statements.
Chapter 4. Basic Program Elements 4.3 Labels A label can contain the following characters: • Alphabet characters • Numeral characters • Period (.) Rules for naming labels • The label length should be limited to 10 characters including periods. • A program can contain up to 9999 labels. • Label names make no distinction between uppercase and lowercase letters. The following labels, for example, will be treated as the same label.
4.4 Identifiers Identifiers for the names of variables should comprise the same alphanumerics as the labels. Rules for naming identifiers • The identifier length should be limited to 10 characters including periods and excluding $ (dollar sign) and % (percent sign) suffixes. • Every type of variables can contain up to 255 identifiers. • A reserved word cannot be used by itself for an identifier name, but can be includedwithin an identifier name.
Chapter 4. Basic Program Elements 4.5 Reserved Words "Reserved words" are keywords to be used in statements, functions, and operators. For the reserved words, refer to Appendix B, "Reserved Words." Rules for using reserved words words • A reserved word cannot be used by itself for a label name, a variable name, or other identifiers, but can be included within them.
Chapter 5 Data Types CONTENTS 5.1 Constants.............................................................................................................. 63 5.1.1 Types of Constants...................................................................................... 63 [ 1 ] String Constants....................................................................................... 63 [ 2 ] Numeric Constants................................................................................... 63 5.
Chapter 5. Data Types 5.1 Constants 5.1.1 Types of Constants A constant is a data item whose value does not change during program execution. Constants are classified into two types: string constants and numeric constants. Constant Example String constants "ABC", "123" Numeric constants Integer constants In decimal notation In hexadecimal notation Real constants 123%, -4567 &HFFF, &h1A2B 123.45, -67.
Real Constants Real constants should be formatted as shown below. Syntax: sign mantissa Syntax: sign mantissa E sign exponent Where a lowercase letter "e" is also allowed instead of uppercase letter "E." mantissa is a numeric string composed of a maximum of 10 significant digits. It can include a decimal point. If included in a real constant as shown below, a comma (,) for marking every three digits will cause a syntax error.
Chapter 5. Data Types 5.2 Variables A variable is a symbolic name that refers to a unit of data storage. The contents of a variable can change during program execution. 5.2.1 Types of Variables according to Format Variables are classified into two types: string variables and numeric variables, each of which is subclassified into non-array and array types.
Memory Occupation A string variable occupies the memory space by (the number of characters + one) bytes, where the added one byte is used for the character count. That is, it may occupy 2 to 256 bytes. If a non-array string variable consisting of 20 characters is declared, for example, it will occupy 21-byte memory space. [ 2 ] Numeric Variables • NonNon-array integer variables variables A non-array integer variable should be formatted with an identifier followed by a percent-age sign (%) as shown below.
Chapter 5. Data Types 5.2.2 Classification of Variables Work Variables A work variable is intended for general use. You may use it either by declaring with the DIM statement as a non-array variable or without declaration as an array variable. The following examples show work variables: DIM a(10),b%(5),c$(1) d=100:e%=45 FOR count%=s1%TO s2% NEXT count% At the start of a user program, the Interpreter initializes all of the work variables to zero (0) or a null character string.
5.3 User-defined Functions Out of user-defined functions, the SUB and FUNCTION functions can be called from other files. The DEF FN function can be called only in the file where that function is defined and should start with an FN.
Chapter 5. Data Types 5.4 Type Conversion 5.4.1 Type Conversion BHT-BASIC has the type conversion facility which automatically converts a value of one data type into another data type during value assignment to numeric variables and operations; from a real number into an integer number by rounding off, and vice versa, depending upon the conditions.
5.4.2 Type Conversion Examples The following examples show the type conversion from real to integer. Assignment of Real Expressions to Integer Variables When assigning the value of the real expression (right side) to the integer variable (left side), the Interpreter carries out the type conversion. Syntax: Example: integervariable = realexpression b% = 123.45 Where b% will become 123.
Chapter 5. Data Types 5.5 Scope of Variables You may scope work variables and register variables to be local or global with the PRIVATE or GLOBAL statement, respectively. (1) Global variables A global variable can be accessed by any routine in source files to share information between those routines. Before access to it, you need to declare it with the GLOBAL statement. (2) Local variables A local variable can only be accessed by any routine in a source file where it is defined.
If used inside the SUB or FUNCTION function in the same file where the global variable is defined, the variable will also have the same value. (Example 2) The variable aa% defined by the GLOBAL statement will have the same value as aa% within the FUNCTION.
Chapter 5. Data Types 5.5.2 Local Variables A local variable can be accessed only in a file where it is defined. Write PRIVATE preceding a desired variable name or DEFREG statement. (Example) PRIVATE PRIVATE PRIVATE PRIVATE PRIVATE aaa% bbb$[10] ccc$(5,3)[30] DEFREG ddd DEFREG eee%(5) Before access to a local variable, you should define it. If used inside more than one SUB or FUNCTION function in the same file where the local variable is defined, all of those variables will also have the same value.
5.5.3 Variables Not Declared to be Global or Local If not declared to be global or local, a variable is closed in each file where it is defined. A variable used inside the FUNCTION or SUB function without declaration is available only within a function where it is defined.
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 COMMON a% printaa(x) SUB printaa(x) COMMON a% print a%+x a%=2 SUB printaa(5) To use a% as a common variable in Files 1 and 2, define the variable with the COMMON statement in each file.
Chapter 6 Expressions and Operators CONTENTS 6.1 Overview ............................................................................................................... 77 6.2 Operator Precedence............................................................................................ 78 6.3 Operators .............................................................................................................. 79 6.3.1 Arithmetic Operators ...........................................................
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 Arithmetic operator Relational operator Logical operator Function operator String operator Description Performs arithmetic operations. Compares two values.
6.2 Operator Precedence When an expression contains more than one operator, BHT-BASIC performs the operations in the standard precedence as shown below. Precedence 1. Parentheses ( ) The parentheses allow you to override operator precedence; that is, operations enclosed with parentheses are first carried out. For improving the readability of an expression, you can use parentheses to separate two operators placed in succession. 2. Function operations 3.
Chapter 6. Expressions and Operators 6.3 Operators 6.3.1 Arithmetic Operators Arithmetic operators include a negative sign (-) and operators for multiplication (*), division (/), addition (+), and subtraction (-). They also include modulo operator MOD.
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.
Chapter 6. Expressions and Operators 6.3.3 Logical Operators A logical operator combines multiple tests and manipulates Boolean operands, then returns the results. It is used, for example, to control the program execution flow or test the value of an INP function bitwise, as shown in the sample below. IF d<200 AND f<4 THEN ... WHILE i>10 OR k<0 ... IF NOT p THEN ... barcod%=INP(0)AND &h02 Listed below are the four types of logical operators available.
[ 2 ] The AND operator The AND operator ANDs the same order bits in two expressions on either side of the operator, then sets 1 to the resultant bit if both of these bits are 1. Syntax: expression1 AND expression2 Truth Table for AND Bit in Expression 1 Bit in Expression 2 Resultant Bit 0 0 1 1 0 1 0 1 0 0 0 1 [ 3 ] The OR operator The OR operator ORes the same order bits in two expressions on either side of the operator, then sets 1 to the resultant bit if at least one of those bits is 1.
Chapter 6. Expressions and Operators 6.3.4 Function Operators The following two types of functions are available in BHT-BASIC, both of which work as function operators: BuiltBuilt-in Functions Already built in BHT-BASIC, e.g., ABS and INT. UserUser-defined Functions Defined by using DEF FN (in single-line form), DEF FN...END DEF (in block form), SUB...END SUB, or FUNCTION...END FUNCTION statement. 6.3.5 String Operators A character string operator may concatenate or compare character strings.
Comparison of Character Strings The string operators compare two character strings according to character codes assigned to individual characters. In the example below, the expression a1$
Chapter 7 I/O Facilities CONTENTS 7.1 Output to the LCD Screen..................................................................................... 86 7.1.1 Display Fonts............................................................................................... 86 [1] Screen mode and font size .................................................................. 86 [2] Character attributes (Reverse font and enlargement attribute) ............ 88 7.1.2 Coordinates on the LCD...............................
7.1 Output to the LCD Screen 7.1.1 Display Fonts [1] Screen mode and font size Listed below are the fonts available on BHT.
Chapter 7. I/O Facilities Screen mode The ANK mode displays ANK characters listed in Appendices C1 and C2. The Kanji mode displays the following characters: • Half-width: Katakana and alphanumerics • Full-width: JIS Levels 1 and 2 Kanji, alphabets and symbols NOTE Half-width Kanji characters differ from ANK characters in size. Font size The standard- and small-size fonts may be displayed. To display Kanji characters, it is necessary to download Kanji font files listed below.
[2] Character attribute) attributes (Reverse font and enlargement Reverse font attribute Characters may be reversed (highlighted). Enlargement attribute Characters may be displayed in regular-size and double-width as listed in [ 1 ]. Switching the character attributes You may switch the reverse font attribute and enlargement attribute by using the SCREEN statement (charaattribute parameter). Refer to Chapter 14, SCREEN.
Chapter 7. I/O Facilities 7.1.2 Coordinates on the LCD To locate characters on the coordinates of the LCD screen, use the LOCATE statement. To obtain the current cursor position, use the CSRLIN and POS functions. The coordinates will differ depending upon the screen mode and font size.
Two-byte Kanji Mode • Standard-size font Be careful about the specification of line numbers in figures below. A single column shown below represents an area for a half-width character; Double columns represent an area for a full-width character.
Chapter 7. I/O Facilities • Small-size font Be careful about the specification of line numbers in figures below. A single column shown below represents an area for a half-width character; Double columns represent an area for a full-width character.
7.1.3 Dot Patterns of Fonts Character fonts In the figures below, " " shows a display area for characters. Any character is displayed within a set of the display areas. "□ " shows a delimiter area that separates characters from each other and contains no display data. The corresponding dots are always off.
Chapter 7.
Cursor shape The LOCATE statement specifies the cursor shape--Underline cursor, full block cursor, or invisible. You may define and load the desired cursor shape with the APLOAD or KPLOAD statement and then specify the user-defined cursor with the LOCATE statement. If the double-width character size is specified, the cursor will be displayed in double width.
Chapter 7.
7.1.4 [1] Mixed Display of Different Screen Modes, Font Sizes, and/or Character Enlargement Sizes ANK Mode and Kanji Mode Together in One Line ANK characters and Kanji characters may display together in the same line on the LCD screen as shown below. CLS SCREEN 0 LOCATE 1,1:PRINT "ABCDEFGHabcdefgh" SCREEN 1 LOCATE 1,1:PRINT " " If the display data is outputted to the same location more than one time as shown in the above program, the BHT overwrites the old data with new data.
Chapter 7. I/O Facilities [3] Regular-Size and Double-Width Characters Together on the Same Screen The regular-size and double-width characters may display together on the same screen as shown below.
7.1.5 Displaying User-defined Characters Loading a useruser-defined font The APLOAD or KPLOAD statement loads a user-defined font. The APLOAD statement is capable of loading up to 32 single-byte ANK fonts to be displayed in the single-byte ANK mode. The KPLOAD statement is capable of loading up to 128 two-byte Kanji fonts in full width to be displayed in the two-byte Kanji mode.
Chapter 7. I/O Facilities 7.1.6 VRAM The INP function may read the VRAM data. The OUT statement writes data into the VRAM so that graphics may be displayed on the LCD dotwise. Specifying an address bytewise An address on the LCD may be specified bytewise by giving a port number in the OUT statement and INP function.
Setting an 88-bit binary pattern The data of an 8-bit binary pattern should be designated by bit 7 (LSB) to bit 0 (MSB) in the OUT statement or INP function. If the bit is 1, the corresponding dot on the LCD will come ON.
Chapter 7. I/O Facilities 7.1.7 Displaying the System The BHT-8000 may display the shifted key icon and alphabet input icon at the right end of the bottom line of the LCD. For details about the icon shapes, refer to the BHT’s User’s Manual. Turning the system status indication on or off You may turn the system status indication on or off on the SET DISPLAY menu in System Mode. The default is ON.
Notes when displaying the system status with OUT statement Specifying the system status indication with the OUT statement overwrites the system status on the current data shown at the right end of the bottom line of the LCD. If Kanji characters are shown at the right end of the bottom line, the lower half of the Kanji is overwritten with the system status but with the upper half remaining on the LCD.
Chapter 7. I/O Facilities 7.1.8 Other Facilities for the LCD Setting national characters characters Using the COUNTRY$ function displays currency symbols and special characters for countries. Refer to Appendix C2, "National Character Sets." Specifying the cursor shape The LOCATE statement specifies the cursor shape.
7.2 Input from the Keyboard 7.2.1 Alphabet Entry In addition to the numeric entry from the keypad, the BHT-8000 supports software keyboard entry. Switching between the Numeric Entry System and Alphanumeric Entry System To switch between the numeric entry system and alphanumeric entry system, use the OUT statement in a user program as shown below. OUT &h60B0,0 ’Switch to the numeric entry system* OUT &h60B0,1 ’Switch to the alphanumeric entry system *Selected when the BHT-8000 is cold-started.
Chapter 7. I/O Facilities Alphabet Entry Procedure (1) Switch to the alphanumeric entry system as follows: Issue "OUT &h60B0,1". (2) Switch to the alphabet entry mode as follows: Press the SF key or issue "OUT &h60B1,1". The ALP icon appears.
When no key is ready to be established, pressing any of the function keys, BS, C, ENT, and magic keys will return the key data of the pressed key. (Example: If you press the 1, 1, 2, and 3 keys) The key data of "T" and "V" will be returned. The "Y" is not established yet. (Example: If you press the C, 1, 1, 1, and ENT keys) The 18H and "U" will be returned. 7.2.2 Other Facilities for the Keyboard [ 1 ] Auto-repeat The keys on the BHT series are not auto-repeat.
Chapter 7. I/O Facilities 7.3 Timer and Beeper 7.3.1 Timer Functions The timer functions (TIMEA, TIMEB, and TIMEC) are available in BHT-BASIC for accurate time measurement. Use these timer functions for monitoring the keyboard waiting time, communications timeout errors, etc. TIMEA = 100 ’10 sec WAIT 0,&H10 BEEP PRINT "10sec." TIMEC = 20 ’2 sec WAIT 0,&H41 BEEP PRINT "2sec.or Keyboard" 7.3.2 BEEP Statement The BEEP statement sounds a beeper and specifies the frequency of the beeper.
7.4 Controlling and Monitoring the I/Os 7.4.1 Controlling by the OUT Statement The OUT statement can control the input and output devices (I/Os) listed in Appendix D, I/O Ports." The table below lists some examples. OUT Statement OUT 1,&h02 OUT 1,&h01 OUT 1,&h00 OUT OUT OUT OUT 3,&hXX (XX : 00 to 07) 4,&h00 4,&h01 6,&hXX (XX : 00 to FF) 7.4.2 I/O Devices Turns on the indicator LED in green. Turns on the indicator LED in red. Turns off the indicator LED. Sets the LCD contrast.
Chapter 7. I/O Facilities 7.4.3 Monitoring by the WAIT Statement The WAIT statement monitors the input and output devices (I/Os) listed in Appendix D, "I/O Ports." Unlike the INP function, the WAIT statement makes the I/O devices idle while no entry occurs, thus saving power consumption. The table below lists some examples.
Chapter 8 Files CONTENTS 8.1 File Overview........................................................................................................111 8.1.1 Data Files and Device I/O Files ..................................................................111 8.1.2 Access Methods .........................................................................................111 8.2 Data Files ............................................................................................................ 112 8.2.
Chapter 8. Files 8.1 File Overview 8.1.1 Data Files and Device I/O Files BHT-BASIC treats not only data files but also bar code device I/Os and communications device I/Os as files, by assigning the specified names to them. File Type Data File Device I/O File Device I/O File File Name filename.extension drivename:filename.extension BAR: COM: Remarks Bar code device Communications device TIP Data files and user program files are stored in the user area of the memory. 8.1.
8.2 Data Files 8.2.1 Overview Like user programs, data files will be stored in the user area of the memory. The user area is located at drives A and B. Note that drive B in the BHT-8000 is provided for ensuring the compatibility with conventional BHT series. The memory space available for data files is (Memory space on drive A - Memory space occupied by user programs). For the memory mapping, refer to Appendix F, "Memory Area." You may check the current occupation of the memory with the FRE function.
Chapter 8. Files 8.2.3 Structure of Data Files Record Record A data file is made up of a maximum of 32767 records. A record is a set of data in a data file and its format is defined by the FIELD statement. The maximum length of a record is 255 bytes including the number of the character count bytes* (= the number of the fields). * When transferring data files, the BHT-protocol/BHT-Ir protocol automatically prefixes a character count byte in binary format to each data field.
8.2.4 Data File Management by Directory Information The Interpreter manages data files using the directory information stored in the system area of the memory. The directory information, for example, contains the following: filename.extension Information of Each Field (Field length) Number of Written Records Maximum Number of Registrable Records • Number of Written Records Means the number of records already written in a data file, which the LOF function can return.
Chapter 8. Files 8.2.5 Programming for Data Files Input/Output for Numeric Data - To write numeric data into a data file: It is necessary to use the STR$ function for converting the value of a numeric expression into a string. To write -12.56 into a data file, for example, the field length of at least 6 bytes is required. When using the FIELD statement, designate the sufficient field length; otherwise, the data will be lost from the lowest digit when written to the field.
Restrictions on Input/Output of Data Files No INPUT#, LINE INPUT#, or PRINT# statement or INPUT$ function can access data files. To access data files, use a PUT or GET statement. Drive Defragmentation During downloading, a delay of a few seconds (response delay from the BHT) may occur according to the user area condition. To eliminate the delay, defragment the drive for the size required for downloading beforehand. Doing so will also reduce the device open time in communications.
Chapter 8. Files 8.2.6 About Drives The BHT-8000 has logical drives. Drive B is provided for ensuring compatibility with other BHT series. If you specify drive name "B:" preceding a filename.extension and open an existing file, then the BHT will open the file as a read-only file. Executing the PUT statement to the read-only file will result in a run-time error (43h). If you specify drive name "A:" or omit a drive name, the BHT will open the file as a read/write file.
8.3 Bar Code Device 8.3.1 Overview Opening the Bar Code Device by OPEN "BAR:" Statement The OPEN "BAR:" statement opens the bar code device. In this statement, you may specify the following bar code types available in the BHT. The BHT can handle one of them or their combination. Available Bar Code Types Universal product codes EAN-13*1 EAN-8 UPC-A*1 UPC-E Default Settings No national flag specified. Interleaved 2of5 (ITF) No length of read data specified. No check digit.
Chapter 8. Files Specifying Options in the OPEN "BAR:" Statement Statement You may also specify several options as listed below for each of the bar code types in the OPEN "BAR:" statement.
8.3.2 Programming for Bar Code Device Code Mark The MARK$ function allows you to check the code mark (denoting the code type) and the length of the inputted bar code data. This function returns a total of three bytes: one byte for the code mark and two bytes for the data length. Multiple Code Reading You may activate the multiple code reading feature which reads more than one code type while automatically identifying them.
Chapter 8. Files Controlling the Indicator LED and Beeper (Vibrator) for of Successful Reading By using the OPEN "BAR:" statement, you can control: • whether the indicator LED should light in green or not (Default: Light in green) • whether the beeper should beep or not (Default: No beep) (The BHT-8000 may control the vibrator also.) when a bar code is read successfully. For detailed specification of the OPEN "BAR:" statement, refer to Chapter 14.
8.4 Communications Device 8.4.1 Overview The available communications interface in BHT is as follows. • IrDA interface • Direct-connect interface • Bluetooth interface (For BHTs with Bluetooth communications device) For the Bluetooth interface, refer to Chapter 18. 8.4.
Chapter 8. Files 8.4.3 Programming for Data Communications Setting the Communications Parameters Use the OPEN "COM:" statement to set the communications parameters. For IrDA interface Communications Parameters Transmission speed (bps) Effective Setting 115200,57600,38400,19200,9600,2400 Default 9600 Parameters other than the transmission speed are fixed (Parity = None, Character length = 8bits, Stop bit length = 1 bit), since the physical layer of the IrDA interface complies with the IrDA-SIR 1.2.
8.4.4 Overview of Communications Protocols The BHT supports two communications protocols—BHT-protocol and BHT-Ir protocol for file transmission. Using the XFILE statement, the BHT may upload or download a file according to either of these protocols. [ 1 ] BHT-protocol This protocol may be used also in System Mode. For the communications specifications of the BHT-protocol, refer to the BHT User's Manual.
Chapter 8. Files [ 2 ] BHT-Ir protocol In addition to the BHT-protocol, the BHT supports the BHT-Ir protocol. If you select the BHT-Ir protocol by using the OUT statement (Port &h6060) or in System Mode, you can upload or download a data file with the XFILE statement. The BHT-Ir protocol may be used also in System Mode. For the communications specifications of the BHT-Ir protocol, refer to the BHT User’s Manual.
8.4.5 File Transfer Tools [ 1 ] Transfer Utility Transfer Utility is optionally available in two versions: MS-DOS–based and Windows-based. It supports the BHT-protocol and allows you to upload or download user program files and data files between the host and the BHT, when invoked by the XFILE statement. This utility can also transfer user program files and data files to/from System Mode.
Chapter 9 Event Polling and Error/Event Trapping CONTENTS 9.1 Overview ............................................................................................................. 128 9.2 Event Polling.......................................................................................................... 129 [ 1 ] Programming sample ......................................................................... 129 [ 2 ] I/O devices capable of being monitored by the event polling.............. 130 9.
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 routine.
Chapter 9. Event Polling and Error/Event Trapping 9.2 Event Polling [ 1 ] Programming sample The program below shows the event polling example which monitors the bar code reader and the keyboard for occurrence of events. This example uses the EOF and INKEY$ functions to check the data input for the bar code reader and the keyboard, respectively.
[ 2 ] I/O devices capable of being monitored by the event polling Listed below are the I/O devices which the event polling can monitor.
Chapter 9. Event Polling and Error/Event Trapping 9.3 Error Trapping [ 1 ] Overview If a run-time error occurs during program running, error trapping makes the program cause an interrupt upon completion of the machine instruction so as to transfer control from the current program to the error-handling routine which has been specified by a label.
[ 2 ] Programming for trapping errors To trap errors, use the ON ERROR GOTO statement in which you should designate the error-handling routine (to which control is to be transferred if a run-time error occurs) by the label.
Chapter 9. Event Polling and Error/Event Trapping 9.4 Event (of Keystroke) Trapping [ 1 ] Overview If any of the function keys previously specified for keystroke trapping is pressed, event trapping makes the program cause an interrupt so as to transfer control from the current program to the specified event-handling routine. This trapping facility checks whether any of the function keys is pressed or not between every execution of the statements.
If function keys specified for keystroke trapping are pressed during execution of the following statements or functions relating keyboard input, this trapping facility operates as described below. Statements or Functions INPUT statement Keystroke Trapping Ignores the entry of the pressed key and causes no interrupt. LINE INPUT statement Same as above. INPUT$ function Same as above. INKEY$ function Ignores the entry of the pressed key, but causes an interrupt.
Chapter 10 Sleep Function CONTENTS 10.1 Sleep Function ..................................................................................................
10.1 Sleep Function The BHT supports the sleep function that automatically interrupts program execution if no event takes place within the specified length of time in the BHT, thereby minimizing its power consumption. Upon detection of any event, the BHT in the sleep state immediately starts the interrupted user program. By using the OUT statement, you may set the desired length of time to the sleep timer within the range from 0 to 25.5 seconds in increment of 100 ms. The default is 1 second.
Chapter 11 Resume Function CONTENTS 11.1 Resume Function ..............................................................................................
11.1 Resume Function The resume function automatically preserves the current status of a running application 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.
Chapter 12 Power-related Functions CONTENTS 12.1 Low Battery Warning......................................................................................... 140 12.2 Prohibited Simultaneous Operation of the Beeper, Illumination LED, and LCD Backlight.......................................................................................................... 140 12.3 Wakeup Function .............................................................................................. 141 12.
12.1 Low Battery Warning If the output voltage of the battery cartridge drops below a specified lower level limit when the BHT is in operation, then the BHT displays the Level-1 message "Battery voltage has lowered." on the LCD and beeps three times. After that, it will resume previous regular operation.
Chapter 12. Power-related Functions 12.3 Wakeup Function The wakeup function allows you to turn the BHT on at the wakeup time (of the system clock) specified in user programs. To set the wakeup time, use the TIME$ function as follows: (1) Set 1 to bit 2 on port 8. Switches the TIME$ function to the setting of the wakeup time. (2) Set the wakeup time by using the TIME$ function. (3) Set 1 to bit 0 on port 8. Activates the wakeup function.
12.4 Remote Wakeup Function [1] Outline The remote wakeup function allows you to wake up the BHT from a remote location so as to run the specified user program (hereafter referred to "remote wakeup program") by sending the specified message from the host computer to the BHT via the CU. Developing user programs utilizing the remote wakeup at both the host computer and BHT enables you to automatically maintain the master system or update user programs.
Chapter 12. Power-related Functions [2] Remote wakeup operation About BHT internal operation enabling remote wakeup If the BHT is turned off normally* with the remote wakeup function activated, then it will become ready to receive commands from the host computer at the timing shown below during the specified timeout period. During this operation, nothing appears on the LCD.
If the host receives no response from the BHT for 30 ms, go back to step (1). (3) Perform steps (1) and (2) repeatedly for 60 seconds or more. If the host receives no response from the BHT during the period, it should proceed to the specified error processing. Refer to the sample program given below. sample_e.c At the BHT (1) Turn the BHT off and put it on the CU. (2) Upon receipt of any data, the BHT will check the data.
Chapter 12. Power-related Functions Host computer BHT Start the remote wakeup. Ready for remote wakeup. Transacted by the BHT system program. Start the remote wakeup start timer. Start the sending timer or counter. Turn the BHT off. Send Start 30 ms count. Any response Yes from the BHT? No 30 ms elapsed? "WAKE" No Yes End the remote wakeup. by the BHT hardware. Yes No Turn the BHT on to ready to receive commands.
[3] Remote wakeup program File name The BHT may handle the file named "BHTRMT.PD3" as a remote wakeup program. Upon receipt of data containing a “WAKE” character string, the BHT checks whether the BHTRMT.PD3 file exists. If the file exists, the BHT will start the remote wakeup operation described in [ 2 ].
Chapter 12. Power-related Functions (4) Set the BHT station ID to be used in the BHT response message Set a 6-byte numeric string referring to the lower 6 digits of the BHT serial number as a station ID which will be used in the response message to the host. To write and read the setting, use the extended function SYSTEM.FN3 (Functions #3 and #4). For details, refer to Chapter 16, "Extended Functions.
Checking the execution record of remote wakeup When starting, a user program (including a remote wakeup program) may check via the I/O ports whether the BHT remotely woke up at the last powering on and its operation was normally ended. (Refer to Appendix D, "I/O Ports.”) Making use of the execution record, you may display an alarm message. Port No. 60F2h Bit 0 Bit 1 Specifications 0 0 0 1 1 0 At the last powering on, the BHT remotely woke up and its operation was interrupted.
Chapter 13 Backlight Function CONTENTS 13.1 Backlight Function.............................................................................................
13.1 Backlight Function The BHT has a backlight function (LCD backlight and key backlight). Pressing the M1 key while holding down the Shift key activates or deactivates the backlight function. The default length of backlight ON-time (ON-duration) is 3 seconds. By using an OUT statement, you can enable/disable either or both the LCD backlight and key backlight. (Refer to Appendix D, "I/O Ports.
Chapter 13. Backlight Function Setting 0 to port 6020h deactivates the backlight function and turns off the backlight if lit. When the backlight function is activated with the OUT statement, the backlight function on/off key and ON-duration specified by the KEY statement will be ignored. The backlight function isOFF when you turn onthe BHT. Backlight OFF With the OUT statement, set 1 to port 6020h Backlight ON With the OUT statement, set 0 to port 6020h.
Chapter 14 Statement Reference CONTENTS KPLOAD ................................................ 222 LET ........................................................ 227 LINE INPUT ........................................... 228 LINE INPUT # ........................................ 230 LOCATE ................................................. 232 ON ERROR GOTO ................................ 235 ON…GOSUB,ON…GOTO .................. 236 ON KEY…GOSUB ................................. 238 OPEN......................
Chapter 14. Statement Reference ____________________________________________________________________ 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.
• If you issue more than one APLOAD statement specifying a same character code, the last statement takes effect. • Only when the Interpreter executes the APLOAD statement, it refers to the array data defined by fontarrayname. So, once a user program has finished load-ing the user font, changing the data in the array or deleting the array itself (by the ERASE statement) will not affect the already loaded user font.
Chapter 14. Statement Reference • The cursor size will be as shown below. Display font Size (W×H) No. of elements Standard-size 6×8 dots 6 6×6 dots 6 LSB MSB Small-size LSB MSB • An array integer variable--a work array, register array, or common array—for cursorarrayname should be declared by the DIM, DEFREG, or COMMON statement, respectively. DIM cp0%(11) DEFREG cp1%(11) COMMON cp2%(11) The array variable should be one-dimensional and have at least 12 elements.
Syntax errors: Error code and message error 71: Syntax error Meaning • No fontarrayname or cursorarrayname is defined. • fontarrayname or cursorarrayname has an array string variable. • fontarrayname or cursorarrayname includes parentheses ( ). • fontarrayname or includes subscripts. cursorarrayname RunRun-time errors: Error code 05h Meaning Parameter out of the range (• characode is out of the specified range.) (• The array structure is not correct.
Chapter 14. Statement Reference ____________________________________________________________________ I/O statement BEEP Drives the beeper or vibrator. ____________________________________________________________________ Syntax: BEEP[onduration[,offduration[,repetitioncount [,frequency]]]] Parameter: onduration, offduration, and repetitioncount Numeric expressions, each of which returns a value from 0 to 255. frequency A numeric expression which returns a value from 0 to 32767.
You may change the beeper volume with the OUT statement. (For details, refer to Appendix D, "I/O Ports.") If you set a value other than 0, 1, and 2 to frequency, the beeper volume is automatically set to the maximum and not adjustable. • Specification of any of 3 through 61 to frequency deactivates the beeper or vibrator. • Specification of zero to onduration deactivates the beeper. • Specification of a value except for zero to onduration and specification of zero to offduration keep beeping.
Chapter 14. Statement Reference Syntax errors: Error code and message error 71: Syntax error Meaning The number of parameters or commas (,) exceeds the limit.
____________________________________________________________________ Flow control statement CALL Calls an FN3 or SUB function. ____________________________________________________________________ Syntax: Syntax 1 (Calling an FN3): CALL "[drivename:]filename" functionnumber [data [,data]...] Syntax 2 (Calling a SUB): CALL functionname [(realparameter[,realparameter…])] Parameter: [drivename:]filename A string expression. functionnumber An integer constant. data A string variable or a numeric variable.
Chapter 14. Statement Reference • filename is the name of an FN3 function. The extension of the file names is fixed to .FN3. (For the FN3 functions, refer to Chapter 16, "Extended Functions" or the "BHT-BASIC Extension Library Manual.") • functionnumber is the function number of an FN3 specified by filename. • data is a variable for the function number of the FN3 (that is, it is used as an argument to the FN3 function).
Calling a useruser-defined function (SUB function) This statement calls a user-defined function specified by functionname. You may omit CALL when calling a SUB function. • functionname should be a user-defined function defined by SUB...END SUB statement. • The number of realparameters should be equal to that of dummyparameters, and the types of the corresponding variables used in those parameters should be identical.
Chapter 14. Statement Reference RunRun-time errors: Error code 02h Meaning Syntax error ("[drivename:]filename" is in incorrect syntax or the extension is not .FN3.) 05h 1Fh Parameter value out of range (In calling an FN3 function, the number of parameters exceeds 16.) Insufficient memory space (You nested calling statements of a user-defined function to more than 10 levels.
____________________________________________________________________ Flow control statement CHAIN Transfers control to another program. ____________________________________________________________________ Syntax: CHAIN "[drivename:]programfilename" Parameter: "[drivename:]programfilename" A string expression. Description: CHAIN transfers control to a program specified by "[drivename:]programfilename".
Chapter 14. Statement Reference Syntax errors: Error code and message error 3: ’"’ missing Meaning No double quote precedes or [drivename:]programfile-name. error 71: Syntax error [drivename:]programfile-name enclosed in double quotes. follows is not RunRun-time errors: Error code 02h Meaning Syntax error ("[drivename:]programfilename" is in incorrect syntax or the extension is not .PD3.) 07h Insufficient memory space (The 1st program uses too many variables.
____________________________________________________________________ CLear FILE File I/O statement CLFILE Erases the data stored in a data file. ____________________________________________________________________ Syntax: CLFILE [#]filenumber Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: CLFILE erases data in the data file specified by filenumber and resets the number of written records in the directory to zero.
Chapter 14. Statement Reference Example: OPEN "master.
____________________________________________________________________ File I/O statement CLOSE Closes file(s). ____________________________________________________________________ Syntax: CLOSE [[#]filenumber[,[#]filenumber...]] Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: CLOSE closes file(s) specified by filenumber(s). • The file number(s) closed by the CLOSE statement becomes available for a sub-sequent OPEN statement.
Chapter 14. Statement Reference ____________________________________________________________________ CLear Screen I/O statement CLS Clears the LCD screen. ____________________________________________________________________ Syntax: CLS Description: CLS clears the liquid crystal display (LCD) screen and returns the cursor to the upper left corner of the screen. • The CLS statement does not affect settings made by displaymode or charaattribute in the SCREEN statement.
____________________________________________________________________ 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.
Chapter 14. Statement Reference Syntax errors: Error code and message error 5: Variable name redefinition Meaning A same variable name is double declared in a program. error 73: Improper string length The length of a string variable is out of the range from 1 to 255. RunRun-time errors: Error code Meaning 07h Insufficient memory space (The COMMON statement defines too much data.
____________________________________________________________________ Declarative statement CONST Defines symbolic constants to be replaced with labels. ____________________________________________________________________ Syntax: CONST constname = expr Parameter: constname A label, identifier, or string expression of characters consisting of alphanumerics and period (.).
Chapter 14. Statement Reference ____________________________________________________________________ I/O statement CURSOR Turns the cursor on or off. ____________________________________________________________________ Syntax: CURSOR {ON |OFF } Description: When a user program is initiated, the cursor is set to OFF. CURSOR ON turns on the cursor for keyboard entry operation by the INKEY$ function. CURSOR OFF turns off the cursor.
____________________________________________________________________ Declarative statement DATA Stores numeric and string literals for READ statements. ____________________________________________________________________ Syntax: DATA literal[,literal...] Parameter: literal A numeric or string constant. Description: DATA stores numeric and string literals so that READ statements can assign them to variables. • A DATA statement can appear anywhere in a source program.
Chapter 14. Statement Reference ____________________________________________________________________ User-defined function declarative statement DECLARE Declares user-defined function FUNCTION or SUB externally defined. ____________________________________________________________________ Syntax: Syntax 1 (Defining a numeric FUNCTION): DECLARE FUNCTION funcname [(dummyparameter[,dummyparameter...])] Syntax 2 (Defining a string FUNCTION): DECLARE FUNCTION funcname [(dummyparameter [,dummyparameter...
Description: DECLARE defines a user-defined function defined in other source program files. • Declaration of a user-defined function should appear preceding a calling statement of the user-defined function in your source program. • funcname, subname, and dummyparameter should be declared in the same way as the function names and real parameters defined in the original functions (defined in other source program files). • You cannot make double definition to a same function name.
Chapter 14. Statement Reference ____________________________________________________________________ DEFine FuNction User-defined function definition statement DEF FN (Single-line form) Names and defines a user-defined function. ____________________________________________________________________ Syntax: Syntax 1 (Defining a numeric function): DEF FNfunctionname[(dummyparameter[,dummyparameter...])]=expression Syntax 2 (Defining a string function): DEF FNfunctionname[(dummyparameter [,dummyparameter..
Description: Creating a user-defined function DEF FN creates a user-defined function. • Definition of a user-defined function should appear preceding a calling statement of the user-defined function in a source program. • You cannot make double definition to a same function name. • The DEF FN statement should not be defined in the block-structured statements (DEF FN ..END DEF, FOR ..NEXT, FUNCTION ..END FUNCTION, IF ..THEN ...ELSE ..END IF, SELECT ..CASE ..END SELECT, SUB ..END SUB and WHILE ..
Chapter 14. Statement Reference Syntax errors: When defining a user-defined function Error code and message Meaning error 61: Cannot use DEF FN The DEF FN statement is defined in blockincontrol structure structured statements such as FOR and IF statements. error 64: Function redefinition You made double definition to a same function name.
RunRun-time errors: Error code 07h Meaning Insufficient memory space (You nested DEF FN statements to more than 10 levels.) 0Fh String length out of the range (The returned value of the stringlength exceeds the allow-able range.
Chapter 14. Statement Reference ____________________________________________________________________ DEFine FuNction...END DEFine User-defined function definition statement DEF FN…END DEF Names and defines a user-defined function. (Block form) ____________________________________________________________________ Syntax: Syntax 1 (Defining a numeric function): DEF FNfunctionname[(dummyparameter[,dummyparameter...
Description: Creating a user-defined function DEF FN ..END DEF creates a user-defined function. The function definition block between DEF FN and END DEF is a set of some statements and functions. • Definition of a user-defined function should appear preceding a calling statement of the user-defined function in a source program. • You cannot make double definition to a same function name. • This statement block should not be defined in the block-structured statements (DEF FN ..END DEF, FOR ..NEXT, FUNCTION .
Chapter 14. Statement Reference Calling a user-defined function FNfunctionname calls a user-defined function. • The number of realparameters should be equal to that of dummyparameters, and the types of the corresponding variables used in those parameters should be identical. • If you specify a global variable in realparameter when calling a user-defined function, the user-defined function cannot update the value of the global variable.
When calling a user-defined function Error code and message error 68: Mismatch argument type or number Meaning • The number of the real parameters is not equal to that of the dummy parameters. • error 69: Function undefined dummyparameter was an integer variable in defining a function, but realparameter is a real type in calling the function. (If dummypa-rameter was a real variable in defining a function and realparameter is an integer type, then no error occurs.
Chapter 14. Statement Reference ____________________________________________________________________ DEFine REGister Declarative statement DEFREG Defines register variables. ____________________________________________________________________ Syntax: DEFREG registerdefinition[,registerdefinition ...] Parameter: registerdefinition non-arraynumericvariable [=numericconstant] DEFREG n1%=10 DEFREG n2=12.
numericinitialvaluedefinition For one-dimensional: {numericconstant[,numericconstant...]} DEFREG n6%(3)={9,8,7,6} For two-dimensional: {{numericconstant[,numericconstant...]}, {numericconstant[,numericconstant...]} ...} DEFREG n7(1,2)={{10,11,12},{13,14,15}} stringinitialvaluedefinition For one-dimensional: {stringconstant[,stringconstant...]} DEFREG s3$(3)={"a","bc","123","45"} For two-dimensional: {{stringconstant[,stringconstant...]}, {stringconstant[,stringconstant...]} ...
Chapter 14. Statement Reference Syntax errors: Error code and message error 6: Variable redefinition name error 71: Syntax error Meaning A same register variable name is double declared in a program. • stringlength is not an integer constant. • The number of the specified initial values is greater than that of the array elements. • The list of initial values is terminated with a comma. • The type of the specified variable does not match that of its initial value.
Example: Example 1: Valid DEFREG statements DEFREG 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 a%(1,1):3 DEFREG b$(1,1)[ 3] ={,{"123"}} The elements of the above array have the following initial values
Chapter 14. Statement Reference ____________________________________________________________________ DIMension Memory control statement DIM Declares and dimensions arrays; also declares the string length for a string variable. ____________________________________________________________________ Syntax: DIM arraydeclaration[,arraydeclaration...
• In declaring an array string variable, you can specify the string length. If its specification is omitted, the default value of 20 characters takes effect. • If no subscript is specified for a string variable, the Compiler automatically regards the string variable as a non-array string variable so that the default for a non-array string variable, 40 characters, takes effect.
Chapter 14. Statement Reference ____________________________________________________________________ Flow control statement END Terminates program execution. ____________________________________________________________________ Syntax: END Description: END terminates program execution and sounds the beeper for a second. • An END can appear anywhere in a source program.
____________________________________________________________________ Memory control statement ERASE Erases array variables. ____________________________________________________________________ Syntax: ERASE arrayvariablename[,arrayvariablename...] Parameter: arrayvariablename An array numeric or array string variable. Description: ERASE erases an array variable(s) specified by arrayvariablename and frees the memory used by the array.
Chapter 14. Statement Reference ____________________________________________________________________ File I/O statement FIELD Allocates string variables as field variables. ____________________________________________________________________ Syntax: FIELD [#]filenumber,fieldwidth fieldvariable...] AS fieldvariable [,fieldwidth AS 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.
Syntax errors: Error code and message error 71: Syntax error Meaning filenumber is missing. RunRun-time errors: Error code 05h Meaning Parameter out of the range (fieldwidth out of the range) Bad file name or number (You specified filenumber of an unopened file.) 34h 36h Improper file type (You specified filenumber of a file other than data files.) 3Ah File number out of the range 3Ch FIELD overflow (A FIELD statement specifies the record length exceeding 255 bytes.
Chapter 14. Statement Reference ____________________________________________________________________ Flow control statement FOR…NEXT Defines a loop containing statements to be executed a specified number of times. ____________________________________________________________________ Syntax: FOR controlvariable = initialvalue TO finalvalue [STEPincrement] NEXT [controlvariable] Parameter: controlvariable A non-array numeric variable. initialvalue, finalvalue, and increment Numeric expressions.
• The default value of increment is 1. • You can nest FOR ..NEXT statements to a maximum of 10 levels. • When using the FOR ..NEXT statement together with block-structured statements (DEF FN ..END DEF, FOR ..NEXT, FUNCTION ..END FUNCTION, IF ..THEN ...ELSE ..END IF, SELECT ..CASE ..END SELECT, SUB ..END SUB and WHILE ..WEND), you can nest them to a maximum of 30 levels. • A same controlvariable should not be reused in a nested loop.
Chapter 14. Statement Reference ____________________________________________________________________ User-defined function statement FUNCTION…END FUNCTION Names and creates user-defined function FUNCTION. ____________________________________________________________________ Syntax: Syntax 1 (Defining a numeric function): FUNCTION funcname [(dummyparameter [,dummyparameter...])] Syntax 2 (Defining a string function): FUNCTION funcname [(dummyparameter [,dummyparameter...
Description: Creating a user-defined function FUNCTION...END FUNCTION creates a user-defined function. The function definition block between FUNCTION and END FUNCTION is a set of some statements and functions. • You cannot make double definition to a same function name. • This statement block should not be defined in the block-structured statements (DEF FN ..END DEF, FOR ..NEXT, FUNCTION ..END FUNCTION, IF ..THEN ...ELSE ..END IF, SELECT ..CASE ..END SELECT, SUB ..END SUB and WHILE ..
Chapter 14. Statement Reference • If you specify a global variable in realparameter when calling a user-defined function, the user-defined function cannot update the value of the global variable. This is because all realparameters are passed not by address but by value. (So called "Call-by-value") NOTE Before any call to a FUNCTION...END FUNCTION, you need to place def-inition of the FUNCTION function or declaration of the FUNCTION by the DECLARE statement in your source program.
When calling a user-defined function Error code and message error 68: Mismatch argument type or number Meaning • The number of the real parameters is not equal to that of the dummy parameters. • dummyparameter was an integer variable in defining a function, but realparameter is a real type in calling the function. (If dummyparameter was a real variable in defining a function and realparameter is an integer type, then no error occurs.
Chapter 14. Statement Reference ____________________________________________________________________ File I/O statement GET Read 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.
Syntax errors: Error code and message error 71: Syntax error Meaning filenumber is missing. RunRun-time errors: Error code 34h Meaning Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than data files.) 3Ah File number out of the range 3Eh A PUT or GET statement executed without a FIELD statement. 3Fh Bad record number (No record to be read in a data file.
Chapter 14. Statement Reference ____________________________________________________________________ Declarative statement GLOBAL Declares one or more work variables or register variables defined in a file, to be global. ____________________________________________________________________ Syntax: Syntax 1: GLOBAL varname [,varname...] Syntax 2: GLOBAL DEFREG registerdefinition [,registerdefinition...
subscript For one-dimensional: For two-dimensional: integerconstant integerconstant,integerconstant Where integerconstant is a numeric expression which returns a value from 0 to 254. stringlength An integer constant from 1 to 255 which indicates the number of characters. Description: GLOBAL allows variables declared by varname to be referred to or updated in other programs.
Chapter 14. Statement Reference ____________________________________________________________________ Flow control statement GOSUB Branches to a subroutine. ____________________________________________________________________ Syntax: GOSUB label Description: GOSUB calls a subroutine specified by label. • Within the subroutine itself, you use a RETURN statement which indicates the logical end of the subroutine and returns control to the statement just after the GOSUB that called the subroutine.
____________________________________________________________________ Flow control statement GOTO Branches to a specified label. ____________________________________________________________________ Syntax: GOTO label Description: GOTO unconditionally transfers control to a label specified by label. • In an IF statement block, you can omit GOTO immediately following THEN or ELSE, as shown below. IF a=0 THEN Lbl1 ELSE Lbl2 END IF • GOTO allows you to branch anywhere in your program.
Chapter 14. Statement Reference ____________________________________________________________________ Flow control statement IF…THEN…ELSE…END IF Conditionally executes specified statement blocks depending upon the evaluation of a conditional expression.
• A block-structured IF statement block has the following advantages over a single-line IF statement (which is not supported in BHT-BASIC): - More complex conditions can be tested since an IF statement block can contain more than one line for describing conditions. - You can describe as many statements or statement blocks as you want.
Chapter 14. Statement Reference ____________________________________________________________________ I/O statement INPUT Reads input from the keyboard into a variable. ____________________________________________________________________ Syntax: INPUT [;]["prompt"{,|;}]variable Parameter: "prompt" A string constant. variable A numeric or string variable.
• The cursor shape specified by the most recently executed LOCATE statement takes effect. • Even after execution of the CURSOR OFF statement, the INPUT statement displays the cursor. • Data inputted by the user will echo back to the LCD. To assign it to variable, it is necessary to press the ENT key. Pressing the ENT key causes also a line feed. If INPUT is followed by a semicolon (;) in an INPUT statement, however, line feed is suppressed.
Chapter 14. Statement Reference RunRun-time errors: Error code 06h Reference: Statements: Functions: Meaning The operation result is out of the allowable range. (Numeric variable is out of the range.
____________________________________________________________________ File I/O statement INPUT # Reads data from a device I/O file into specified variables. ____________________________________________________________________ Syntax: INPUT #filenumber,variable[,variable...] Parameter: filenumber A numeric expression which returns a value from 1 to 16. variable A numeric or string variable.
Chapter 14. Statement Reference • Notes for entering numeric data: Valid characters include 0 to 9, a minus sign (-), and a period (.). They should be in correct numeric data form. If not, INPUT # statement accepts only numeric data from the first character up to correctly formed character, as valid data. If no valid data is found, the INPUT # statement automatically assigns a zero (0) to variable.
____________________________________________________________________ I/O statement KEY Assigns a string or a control code to a function key; also defines a function key as a backlight function on/off key. This statement also defines a magic key as a trigger switch, shift key, or battery voltage display key.
Chapter 14. Statement Reference Description: Assigning a string or a control code to a function key KEY in syntax 1 assigns a string or a control code specified by stringdata to a function key specified by keynumber. Pressing the specified function key generates the assigned string data or control code and then passes it to the user program as if each character is keyed in directly from the keyboard. • keynumber is a key number assigned to a particular function key.
• Pressing the M1 key (key number 30) while holding down the shift key functions as a backlight on/off control key by default. • If pressed together with the shift key, any numerical key can operate as a function key. • onduration is the length of time in seconds from when the backlight is turned on to automatic turning-off.
Chapter 14. Statement Reference NOTE If you issue KEY statements specifying a same function key, only the last KEY statement takes effect. The description below, for example, makes the function key numbered 3 operate as a backlight function on/off key and the length of backlight ON-time is 100 seconds. KEY 3,"a" KEY 3,"BL100" The description below assigns string data "a" to the function key numbered 3. The default backlight function on/off key (combination of M1 key and shift key) will be restored.
____________________________________________________________________ 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 and 33 to 38. Description: KEY ON KEY ON enables keystroke trapping for a function key specified by keynumber.
Chapter 14. Statement Reference Syntax errors: Error code and message error 71: Syntax error Meaning • keynumber is not enclosed in parentheses ( ). • Neither ON or OFF follows (key-number). RunRun-time errors: Error code 05h Reference: Statements: Meaning Parameter out of the range (keynumber is out of the range.) KEY and ON KEY ..
____________________________________________________________________ File I/O statement KILL Deletes a specified file from the memory. ____________________________________________________________________ Syntax: KILL "[drivename:]filename" Parameter: "[drivename:]filename" A string expression. Description: KILL deletes a data file or a user program file specified by "[drive-name:]filename". • [drivename:] is used in conventional BHT series.
Chapter 14. Statement Reference Example: CLOSE IF kyIn$="Y"THEN KILL "Master.
____________________________________________________________________ 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.
Chapter 14. Statement Reference • The loaded user-defined fonts are effective during execution of the user program which loaded those fonts and during execution of the successive user programs chained by the CHAIN statement. • If you load a font to the same kanjicode more than one time, the most recently specified font takes effect. • Only when the Interpreter executes the KPLOAD statement, it refers to the array data defined by fontarrayname.
• An array integer variable--a work array, register array, or common array--for cursorarrayname should be declared by the DIM, DEFREG, or COMMON statement, respectively. DIM KP0%(5) DEFREG KP1%(5) COMMON KP2%(5) The array variable should be one-dimensional and have at least 6 elements. Each th element data should be an integer and stored in the area from the 1st to 6 elements of the array.
Chapter 14. Statement Reference • If the double-width is specified, then user-defined cursors loaded by the KPLOAD will display in double-width, respectively. For details, refer to Chapter 7, Subsection 7.1.3 "Dot Patterns of Fonts." Syntax errors: Error code and message error 71: Syntax error Meaning • No fontarrayname or cursorarrayname is defined. • fontarrayname or cursorarrayname has an array string variable. • fontarrayname or cursorarrayname includes parentheses ( ).
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 kp%(0) Reference: Statements: kp%(5) kp%(10) kp%(15) Bit in each array element 0 (LSB) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (MSB) APLOAD, COMMON, DEFREG, DIM, PRINT, and SCREEN 226
Chapter 14. Statement Reference ____________________________________________________________________ Assignment statement LET Assigns a value to a given variable. ____________________________________________________________________ Syntax: Syntax 1: [LET] stringvariable = stringexpression Syntax 2: [LET] numericvariable = numericexpression Description: LET assigns a value of expression on the right-hand side to a variable on the left-hand side.
____________________________________________________________________ LINE INPUT 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.
Chapter 14. Statement Reference If "prompt" is followed by a comma, the statement displays the prompting message but no question mark or space is appended to the prompting message. LINE INPUT "data=",a$ data= • The cursor shape specified by the most recently executed LOCATE statement takes effect. • Even after execution of the CURSOR OFF statement, the LINE INPUT statement displays the cursor. • Data inputted by the user will echo back to the LCD.
____________________________________________________________________ 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.
Chapter 14. Statement Reference Syntax errors: Error code and message error 71: Syntax error Meaning • INPUT is missing. • filenumber is missing. • "prompt" is not a string constant. • stringvariable has a numeric variable. RunRun-time errors: Error code 34h Meaning Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than device I/O files.
____________________________________________________________________ I/O statement LOCATE Moves the cursor to a specified position and changes the cursor shape. ____________________________________________________________________ Syntax: Syntax 1: LOCATE [column][,row[,cursorswitch]] Syntax 2: LOCATE,,cursorswitch Parameter: A numeric expression which returns a value given below.
Chapter 14. Statement Reference • The entry ranges of the column and row are the same in the regular-size, double-width. • Any parameter value outside its range will result in a run-time error. • Specification of the maximum value to column moves the cursor off the screen and out of sight.
RunRun-time errors: Error code Meaning 05h Parameter out of the range Example: LOCATE 1,2 LOCATE xPos, LOCATE ,,2 Reference: Functions: xCSRLIN CSRLIN and POS 234
Chapter 14. Statement Reference ____________________________________________________________________ Error control statement ON ERROR GOTO Enables error trapping. ____________________________________________________________________ Syntax: ON ERROR GOTO label Description: ON ERROR GOTO enables error trapping so as to pass control to the first line of an error-handling routine specified by label if an error occurs during program execution.
____________________________________________________________________ Flow control statement ON…GOSUB, ON…GOTO Branches to one of specified labels according to the value of an expression. ____________________________________________________________________ Syntax: Syntax 1: ON expression GOSUB label [,label...] Syntax 2: ON expression GOTO label [,label...] Parameter: expression A numeric expression which returns a value from 1 to 255. Description: ON...GOSUB or ON...
Chapter 14. Statement Reference Syntax errors: Error code and message error 71: Syntax error Meaning • label has not been defined. • label is missing. RunRun-time errors: Error code 05h Meaning Parameter out of the range (expression is negative or greater than 255.) 07h Insufficient memory space (The program nesting by GOSUB statements only is too deep.) Reference: Statements: GOSUB, GOTO, and SELECT ..CASE ..
____________________________________________________________________ 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 and 33 to 38. Description: According to label, ON KEY ..
Chapter 14. Statement Reference Syntax errors: Error code and message error 71: Syntax error Meaning • label has not been defined. • label is missing. • keynumber is not enclosed in parentheses ( ). RunRun-time errors: Error code 05h Meaning Parameter out of the range (keynumber is out of the range.) 07h Insufficient memory space (The program nesting by GOSUB statements is too deep.
____________________________________________________________________ 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.
Chapter 14. Statement Reference • filelength is the maximum number of registrable records in a file. It can be set only when a new data file is created by an OPEN statement. If you specify filelength when opening any of existing data files (including downloaded data files), then the filelength will be ignored. • Specifying only filelength does not allocate memory. Whether or not a PUT statement can write records up to the specified filelength depends on the memory occupation state.
____________________________________________________________________ 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.
Chapter 14. Statement Reference • Only a single bar code device file can be opened at a time. The total number of files which can be opened at a time is 16 including data files and communications device files. • The BHT cannot open the bar code device file and the IrDA interface of the communications device file concurrently. If you attempt to open them concurrently, a run-time error will occur. The BHT can open the bar code device file and the direct-connect interface concurrently.
□Auto-off mode (F) OPEN "BAR :F"AS #7 CODE "A" *1 *2 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 illumination LED will *1 go off. Holding down the trigger switch lights the illumination LED for a maximum of 5 seconds. While the illumination LED is on, the BHT can read a bar code until a bar code is read successfully or the bar code devices file becomes closed.
Chapter 14. Statement Reference • If readmode is omitted, the BHT defaults to the auto-off mode. • In the momentary switching mode, alternate switching mode, or continuous reading mode, after you read a low-quality bar code which needs more than one second to be read, keeping applying the barcode reading window to that bar code may re-read the same bar code in succession at intervals of one second or more.
readcode The BHT supports seven types of bar codes--the universal product codes, Interleaved 2 of 5 (ITF), Standard 2 of 5 (STF), Codabar (NW-7), Code 39, Code 93, and Code 128. The BHT can read also EAN-128 if Code 128 is specified. (For readable bar code types, refer to the BHT User’s Manual.
Chapter 14. Statement Reference □Interleaved 2 of 5 (ITF) (I) Syntax : I[:[mini.no.digits[-max.no.digits]][CD] [,[mini.no.digits[-max.no.digits]][CD]] [,[mini.no.digits[-max.no.digits]][CD]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively. They should be a numeral from 2 to 99 and satisfy the following conditions: mini.no.digits •max.no.digits If both of mini.no.digits and max.no.
CD is a check digit. Specifying a C to CD makes the Interpreter check bar codes with MOD-16. The check digit is included in the number of digits. OPEN "BAR :"AS #1 CODE "N :8AAC" □Code 39 (M) ) Syntax: M[:[mini.no.digits[-max.no.digits]][CD] [,[mini.no.digits[-max.no.digits]][CD]] [,[mini.no.digits[-max.no.digits]][CD]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively.
Chapter 14. Statement Reference □Code 128 (K) ) Syntax : K[:[mini.no.digits[-max.no.digits]] [,[mini.no.digits[-max.no.digits]]] [,[mini.no.digits[-max.no.digits]]]] where mini.no.digits and max.no.digits are the minimum and maximum numbers of digits for bar codes to be read by the BHT, respectively. They should be a numeral from 1 to 99, excluding start/stop characters and check digit. They should satisfy the following condition: mini.no.digits •max.no.digits If both of mini.no.digits and max.no.
(4) FNC4 An FNC4 converts data encoded by the code set A or B into a set of extended ASCII-encoded data (128 added to each official ASCII code value). A single FN4 character converts only the subsequent data character into the extended ASCII-encoded data. A pair of FNC4 characters placed in successive positions converts all of the subsequent data characters preceding the next pair of FNC4 characters or the stop character, into the extended ASCII-encoded data.
Chapter 14. Statement Reference Syntax errors: Error code and message error 71: Syntax error Meaning The number of the specified read codes exceeds eight. RunRun-time errors: Error code 02h Meaning Syntax error (readcode is missing.) 05h Parameter out of the range (readcode is not correct.
____________________________________________________________________ File I/O statement OPEN "COM: " Opens a communications device file.
Chapter 14. Statement Reference Description: OPEN "COM:" opens a communications device file and associates it with filenumber for allowing input/output activities using the communications interface. • If optional parameters enclosed with brackets are omitted, the most recently specified values or the defaults become active.
charalength charalength is a character length or the number of data bits. It should be 8(default) or 7 bits. stopbit stopbit is the number of stop bits. It should be 1 (default) or 2 bits. NOTE The IrDA interface is compliant with the IrDA physical layer (IrDA-SIR1.2), so the vertical parity, character length, and stop bit length are fixed to none, 8 bits, and 1 bit, respectively. If selected, those parameters will be ignored. RS/CS RS/CS enables or disables the RS/CS control.
Chapter 14. Statement Reference Syntax errors: Error code and message error 71: Syntax error Meaning filenumber is missing. RunRun-time errors: Error code 02h Meaning Syntax error (The x in "COM:x" contains an invalid parameter.) 37h File already open 3Ah File number out of the range 45h File already open (You attempted to open the bar code device file and the IrDA interface of the communications device file concurrently.
____________________________________________________________________ I/O statement OUT Sends a data byte to an output port. ____________________________________________________________________ Syntax: OUT portnumber,data Parameter: portnumber A numeric expression. data A numeric expression which returns a value from 0 to 255. Description: OUT sends a data byte designated by data to a port specified by portnumber.
Chapter 14. Statement Reference RunRun-time errors: Error code 05h Meaning Parameter out of the range (portnumber or data is out of the range.) Example: OUT 3,7 The above example sets the LCD contrast to the maximum.
____________________________________________________________________ I/O statement POWER Controls the automatic power-off facility. ____________________________________________________________________ Syntax: Syntax 1 (Turning off the power according to the power-off counter): POWER counter Syntax 2 (Turning off the power immediately): POWER {OFF •0 } Syntax 3 (Disabling the automatic power-off facility): POWER CONT Parameter: counter A numeric expression which returns a value from 0 to 32767.
Chapter 14. Statement Reference Turning off the power immediately Execution of POWER OFF or POWER 0 immediately turns off the power. • The execution of POWER OFF or POWER 0 deactivates the resume function if preset. Disabling the automatic power-off facility POWER CONT disables the automatic power-off facility. RunRun-time errors: Error code 05h Meaning Parameter out of the range (counter is out of the range.
____________________________________________________________________ I/O statement PRINT Displays data on the LCD screen. ____________________________________________________________________ Syntax: PRINT [data[CR/LFcontrol...]] Parameter: data A numeric or string expression. CR/LFcontrol A comma (,) or a semicolon (;). Description: PRINT displays a number or a character string specified by data at the current cursor position on the LCD screen (To position the cursor, use a LOCATE statement.
Chapter 14. Statement Reference CR/LFcontrol CR/LFcontrol determines where the cursor is to be positioned after the PRINT statement executes. • If CR/LFcontrol is a comma (,), the cursor moves to the column position of a least multiple of 8 plus one following the last character output. Statement example: PRINT 123, Output: 123 _ ] ] ] ] ] ] ( is a space.) • If CR/LFcontrol is a semicolon (;), the cursor moves to the column position immediately following the last character output.
____________________________________________________________________ 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 (;).
Chapter 14. Statement Reference • If CR/LFcontrol is a semicolon (;), the PRINT # statement outputs data without adding spaces or control codes. Statement example: PRINT #1,"ABC";"123"; Output: ABC123 • If neither a comma (,) nor semicolon (;) is specified to CR/LFcontrol, the PRINT # statement adds a CR and LF codes.
____________________________________________________________________ I/O statement PRINT USING Displays data on the LCD screen under formatting control. ____________________________________________________________________ Syntax: Syntax 1 (Displaying numbers): PRINT USING "numericformat";expression [CR/Lfcontrol [expression]...] Syntax 2 (Displaying strings): PRINT USING "stringformat";stringexpression [CR/Lfcontrol [stringexpression]...] Parameter: numericformat #, a decimal point (.), and/or +.
Chapter 14. Statement Reference numericformat numericformat is a formatting string consisting of #, decimal point (.), and/or +,each of which causes a special printing effect as described below. # Represents a digit position. If the number specified by expression has fewer digits than the number of digit positions specified by #, then it is padded with spaces and right-justified. Statement example: PRINT USING "#####";123 Output: ] ] 123 ] ( is a space.
stringformat stringformat is a formatting string consisting of !, @, and/or &&, each of which causes a special printing effect as described below. ! Displays the first character of the stringexpression. Statement example: PRINT USING "!";"ABC" Output: A @ Displays the entire stringexpression. Statement example: PRINT USING "@";"ABC" Output: ABC && Displays the first n+2 characters of the stringexpression, where n is the number of spaces between the ampersands (&&).
Chapter 14. Statement Reference CR/LFcontrol CR/LFcontrol determines where the cursor is to be positioned after the PRINT USING statement executes. For details, refer to the CR/LFcontrol in the PRINT statement. Syntax errors: Error code and message error 71: Syntax error Meaning • numericformat is not correct. • expression or stringexpression contains a comma (,) or semicolon (;). error 86: ’;’ missing No semicolon (;) follows "numericformat" or "stringformat".
____________________________________________________________________ Declarative statement PRIVATE Declares one or more work variables or register variables defined in a file, to be private (aslocal variables). ____________________________________________________________________ Syntax: Syntax 1: PRIVATE varname [,varname...] Syntax 2: PRIVATE DEFREG registerdefinition [,registerdefinition...
Chapter 14. Statement Reference subscript For one-dimensional: For two-dimensional: integerconstant integerconstant,integerconstant Where integerconstant is a numeric expression which returns a value from 0 to 254. stringlength An integer constant from 1 to 255 which indicates the number of characters. Description: PRIVATE defines variables declared by varname or registerdefinition as local variables which can be referred to or updated in that file.
RunRun-time errors: Error code 05h Meaning Parameter out of the range 07h Insufficient memory space (The variable area has run out.) 0Ah Duplicate definition (An array is double declared.
Chapter 14. Statement Reference ____________________________________________________________________ File I/O statement PUT Writes a record from a field variable to a data file. ____________________________________________________________________ Syntax: PUT [#]filenumber[,recordnumber] Parameter: filenumber A numeric expression which returns a value from 1 to 16. recordnumber A numeric expression which returns a value from 1 to 32767.
Syntax errors: Error code and message error 71: Syntax error Meaning filenumber is missing. RunRun-time errors: Error code 05h Meaning Parameter out of the range (• filenumber is out of the range.) (• recordnumber is out of the range.) 07h Insufficient memory space 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than data files.
Chapter 14. Statement Reference ____________________________________________________________________ I/O statement READ Reads data defined by DATA statement(s) and assigns them to variables. ____________________________________________________________________ Syntax: READ variable[,variable...] Parameter: variable A numeric or string variable.
If the string data is invalid as numeric data, the READ statement assigns the value 0 to the numeric variable. Statement example: DATA "ABC" READ c PRINT c Output: 0 • The number of data values stored by the DATA statement must be equal to or greater than that of variables specified by the READ statement. If not, a run-time error occurs. • To specify the desired DATA statement location where the READ statement should start reading data, you use the RESTORE statement.
Chapter 14. Statement Reference ____________________________________________________________________ Declarative statement REM Declares the rest of a program line to be remarks or comments. ____________________________________________________________________ Syntax: Syntax 1: REM comment Syntax 2: ’ comment Description: REM causes the rest of a program line to be treated as a programmer’s remark or comment for the sake of the program readability and future program maintenance.
____________________________________________________________________ I/O statement RESTORE Specifies a DATA statement location where the READ statement should start reading data. ____________________________________________________________________ Syntax: RESTORE [label] Description: RESTORE specifies a DATA statement location where the READ statement should start reading data, according to label designating the DATA statement. • You can specify DATA statements in included files.
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.
RunRun-time errors: Error code 14h Reference: Statements: Functions: Meaning RESUME without error (RESUME statement occurs outside of an error-handling routine.
Chapter 14. Statement Reference ____________________________________________________________________ Flow control statement RETURN Returns control from a subroutine or an event-handling routine (for keystroke interrupt). ____________________________________________________________________ Syntax: RETURN Description: RETURN statement in a subroutine returns control to the statement immediately following the GOSUB that called the subroutine.
____________________________________________________________________ I/O statement SCREEN Sets the display mode (screen mode, and font size) and character attributes (character enlargement and font reverse attributes). ____________________________________________________________________ Syntax: Syntax 1: SCREEN displaymode[,charaattribute] Syntax 2: SCREEN ,charaattribute Parameter: displaymode and charaattribute A numeric expression which returns a value from 0 to 3.
Chapter 14. Statement Reference • At the start of program execution, the following settings apply: Screen mode ANK mode Font size Standard-size Character enlargement attribute Regular Font reverse attribute Normal • If displaymode or charaattribute parameter is omitted, the associated parameter value will not change. • In the two-byte Kanji mode, characters can be displayed in either the full-width (16 dots wide by 16 dots high) or the half-width (8 dots wide by 16 dots high).
____________________________________________________________________ Flow control statement SELECT…CASE…END SELECT Conditionally executes one of statement blocks depending upon the value of an expression. ____________________________________________________________________ Syntax: SELECT conditionalexpression CASE test1 [statementblock] [CASE test2 [statementblock]]... [CASE ELSE [statementblock]] END SELECT Parameter: conditionalexpression, test1, and test2 A numeric or string expression.
Chapter 14. Statement Reference • You can nest the SELECT…CASE…END SELECT statements to a maximum of 10 levels. SELECT a CASE 1 SELECT b CASE 3 PRINT "a=1,b=3" END SELECT CASE 2 PRINT "a=2" END SELECT • When using the SELECT statement block together with block-structured statements (DEF FN ..END DEF, FOR ..NEXT, FUNCTION ..END FUNCTION,IF ..THEN ..ELSE ..END IF, SELECT ..CASE ..END SELECT, SUB ..END SUB and WHILE ..WEND), you can nest them to a maximum of 30 levels.
____________________________________________________________________ User-defined function statement SUB…END SUB Names and defines user-defined function SUB. ____________________________________________________________________ Syntax: Syntax 1 (Defining a numeric function): SUB subname [(dummyparameter[,dummyparameter]...
Chapter 14. Statement Reference Description: Creating a user-defined function SUB...END SUB creates a user-defined function. The function definition block between SUB and END SUB is a set of some statements and functions. • You cannot make double definition to a same function name. • This statement block should not be defined in the block-structured statements (DEF FN ..END DEF, FOR ..NEXT, FUNCTION ..END FUNCTION, IF ..THEN ...ELSE ..END IF, SELECT ..CASE ..END SELECT, SUB ..END SUB, and WHILE ..
Syntax errors: When defining a user function Error code and message error 64: Function redefinition Meaning You made double definition to a same function name. error 71: Syntax error • The string length is out of the range. • The string length is not an integer constant. error 92: Incorrect use of SUB, EXIT SUB or END SUB • The EXIT SUB statement is specified outside the function definition block. • The END SUB statement is specified outside the function definition block.
Chapter 14. Statement Reference RunRun-time errors: Error code 07h Meaning Insufficient memory space (You nested SUB statements to more than 10 levels.) 0Fh String length out of the range (The returned value of the string length exceeds the allowable range.
____________________________________________________________________ I/O statement WAIT Pauses program execution until a designated input port presents a given bit pattern. ____________________________________________________________________ Syntax: WAIT portnumber,ANDbyte[,XORbyte] Parameter: portnumber A numeric expression. ANDbyte and XORbyte A numeric expression which returns a value from 0 to 255.
Chapter 14. Statement Reference Syntax errors: Error code and message error 71: Syntax error Meaning • portnumber is missing. • ANDbyte is missing. RunRun-time errors: Error code Meaning 05h Parameter out of the range Example: WAIT 0,&H03 The above statement suspends a user program until any data is inputted from the keyboard or the bar code reader.
____________________________________________________________________ Flow control statement WHILE…WEND Continues to execute a statement block as long as the conditional expression is true. ____________________________________________________________________ Syntax: WHILE conditionalexpression [statementblock] WEND Description: A WHILE ..WEND continues to execute statementblock as long as the conditionalexpression is true (not zero) according to the steps below.
Chapter 14. Statement Reference Syntax errors: Error code and message error 26 : Meaning Too deep nesting. error 57: Incorrect use of WHILE ..WEND WEND appears outside of the WHILE statement block. error 58: Incomplete control structure No WEND corresponds to WHILE. Reference: Statements: FOR..
____________________________________________________________________ I/O statement XFILE Transmits a designated file according to the specified communications protocol. ____________________________________________________________________ Syntax: XFILE "[drivename:]filename"[,"protocolspec"] Parameter: "[drivename:]filename" and "protocolspec" String expressions.
Chapter 14. Statement Reference - Transmission direction Parameter omitted (default) Transmits a file from the BHT. R or r Receives a file from the host computer or any other BHT. Example: XFILE "d2.dat","R" "filename" cannot be omitted even in file reception. - Serial number Parameter omitted (default) No serial number setting. S or s Adds a serial number to every transmission block. Example: XFILE "d2.
- Timeout length when a link will be established Specify the timeout length by 1 to 9. Set value Downloading 1 30 sec. Uploading BHT-protocol BHT-Ir protocol Retries of ENQ, 10 times Retries of ENQ, 60 times 2 60 sec. Retries of ENQ, 20 times Retries of ENQ, 120 times 3 90 sec. Retries of ENQ, 30 times Retries of ENQ, 180 times 4 120 sec. Retries of ENQ, 40 times Retries of ENQ, 240 times 5 150 sec. Retries of ENQ, 50 times Retries of ENQ, 300 times 6 180 sec.
Chapter 14. Statement Reference • A communications device file should be opened before execution of the XFILE statement. (For the file opening, refer to the OPEN "COM:" statement.) • The XFILE statement uses the interface specified by the OPEN "COM:" statement. • A data file to be transmitted should be closed beforehand. • To transfer a file by using the BHT-Ir protocol , set the BHT's ID to any of 1 to FFFFh. Specifying zero (0) to the ID will result in a run-time error.
RunRun-time errors: Error code 02h 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 07h 32h 33h 35h Bad file name or number (You specified filename of an unopened file.) File not found 37h File already open 38h The file name is different from that in the receive header.
Chapter 14. Statement Reference ____________________________________________________________________ File I/O statement $INCLUDE Specifies an included file. ____________________________________________________________________ Syntax: Syntax 1: REM $INCLUDE:’filename’ Syntax 2: ’$INCLUDE:’filename’ Description: $INCLUDE reads a source program specified by ’filename’ into the program line immediately following the $INCLUDE line in compilation.
Fatal Error: Error code and message fatal error 30: Cannot find include file "XXX" Meaning No included file is found. fatal error 31: Included files are nested.
Chapter 14. Statement Reference Additional Explanation for Statements Effective range of labels Labels are effective only in a file. Definition of common variables (by COMMON statement) In an object to be executed first (that is, in a main object), you should define all common variables to be accessed. In any other objects, declare common variables required only in each object.
Chapter 15 Function Reference CONTENTS INT ......................................................... 328 LEFT$ .................................................... 329 LEN ........................................................ 330 LOC........................................................ 331 LOF ........................................................ 333 MARK$................................................... 334 MID$ ...................................................... 335 POS ....................
Chapter 15. Function Reference ____________________________________________________________________ ABSolute Numeric function ABS Returns the absolute value of a numeric expression. ____________________________________________________________________ Syntax: ABS(numericexpression) Description: ABS returns the absolute value of numericexpression. The absolute value is the magnitude of numericexpression without regard to sign. For example, both ABS (-12.34) and ABS (12.34) are equal to 12.34.
____________________________________________________________________ ASCii code String function ASC Returns the ASCII code value of a given character. ____________________________________________________________________ Syntax: ASC(stringexpression) Description: ASC returns the ASCII code value of the first character of stringexpression, which is an integer from 0 to 255. (For the ASCII character codes, refer to Appendix C, "Character Sets.
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.
RunRun-time errors: Error code 05h Meaning Parameter out of the range (checktype is out of the range.
Chapter 15. Function Reference ____________________________________________________________________ CHecK DiGiT String function CHKDGT$ Returns a check digit of bar code data. ____________________________________________________________________ Syntax: CHKDGT$(barcodedata,CDtype) Parameter: barcodedata and CDtype String expressions. Description: CHKDGT$ calculates a check digit (CD) of barcodedata according to the calculation method specified by CDtype, and then returns it as one-character string.
Sample coding 1: CD.Data$=CHKDGT$("a123Qa","N") "Q" is a CD position character, so CHKDGT$ calculates the correct CD and CD.Data$ will become "-." When CDtype is A (EAN or UPC), CHKDGT$ identifies the EAN or UPC of barcodedata depending upon the data length (number of digits) as listed below. Data length of barcodedata Universal Product Codes 13 digits EAN-13 or UPC-A 8 digits EAN-8 7 digits UPC-E If the data length is a value other than 13, 8, and 7, this function returns a null string.
Chapter 15. Function Reference When CDtype is I (ITF), the length of barcodedata must be an even number of two or more digits. If not, CHKDGT$ returns a null string. - To check that the CD is correct: Pass a CD-suffixed barcodedata to a CHKDGT$ as shown below. If the returned value is equal to the CD, the CD data is suitable for the barcodedata. Sample coding: IF CHKDGT$("123457","I")="7" THEN ... - To add a CD to barcode data: Pass barcodedata followed by a dummy character to a CHKDGT$ as shown below.
When CDtype is N (Codabar), the length of barcodedata must be three digits or more including start and stop characters. If not, CHKDGT$ returns a null string. - To check that the CD is correct: Pass a CD-suffixed barcodedata to a CHKDGT$ as shown below. If the returned value is equal to the CD, the CD data is suitable for the barcodedata. Sample coding: IF CHKDGT$("a0123-a","N")="-" THEN ...
Chapter 15. Function Reference ____________________________________________________________________ CHaRacter code String function CHR$ Returns the character corresponding to a given ASCII code. ____________________________________________________________________ Syntax: CHR$(characode) Parameter: characode A numeric expression which returns a value from 0 to 255. Description: CHR$ converts a numerical ASCII code specified by characode into the equivalent single-byte character.
• To display a Kanji code, use a shift JIS code as shown below. The shift JIS code for 漢 is 8ABFh.
Chapter 15. Function Reference ____________________________________________________________________ COUNTRY I/O function COUNTRY$ Sets a national character set or returns a current country code. ____________________________________________________________________ Syntax: Syntax 1 (Setting a national character set): COUNTRY$="countrycode" Syntax 2 (Returning a country code): COUNTRY$ Parameter: countrycode A string expression which returns any of A, D, E, F, G, I, J, N, S, and W.
• After setting a national character set, you may display national characters assigned to 32 (20h) to 127 (7Fh), on the LCD. • "countrycode" set by this function remains effective in the programs chained by CHAIN statements. • If "countrycode" has more than one character, only the first one takes effect. • If "countrycode" is an invalid letter other than those listed above, the function is ignored. • "countrycode" may be in lowercase.
Chapter 15. Function Reference ____________________________________________________________________ CurSoR LINe I/O function CSRLIN Returns the current row number of the cursor. ____________________________________________________________________ Syntax: CSRLIN Description: CSRLIN returns the current row number of the cursor as an integer in the current display mode specified by a SCREEN statement.
____________________________________________________________________ DATE I/O function DATE$ Returns the current system date or sets a specified system date. ____________________________________________________________________ Syntax: Syntax 1 (Retrieving the current system date): DATE$ Syntax 2 (Setting the current system date): DATE$="date" Parameter: date A string expression. Description: Syntax 1 DATE$ returns the current system date as an 8-byte string. The string has the format below.
Chapter 15. Function Reference RunRun-time errors: Error code 05h Reference: Functions: Meaning Parameter out of the range (date is out of the range.
____________________________________________________________________ End Of File File I/O function EOF Tests whether the end of a device I/O file has been reached. ____________________________________________________________________ Syntax: EOF([#]filenumber) Parameter: Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: EOF tests for an end of a device I/O file designated by filenumber.
Chapter 15. Function Reference ____________________________________________________________________ ERror Line Error-handling function ERL Returns the current statement location of the program where a run-time error occurred. ____________________________________________________________________ Syntax: ERL Description: ERL returns the current statement location of the program where a run-time error occurred most recently. • The ERL function works only with line numbers and not with labels.
____________________________________________________________________ ERRor code Error-handling function ERR Returns the error code of the most recent run-time error. ____________________________________________________________________ Syntax: ERR Description: ERR returns the code of a run-time error that invoked the error-handling routine.
Chapter 15. Function Reference ____________________________________________________________________ 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.
____________________________________________________________________ FREe area Memory management function FRE Returns the number of bytes available in a specified area of the memory. ____________________________________________________________________ Syntax: FRE(areaspec) Parameter: areaspec A numeric expression which returns a value from 0 to 3. Description: FRE returns the number of bytes left unused in a memory area specified by areaspec listed below.
Chapter 15. Function Reference ____________________________________________________________________ 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.
____________________________________________________________________ INput KEYboard I/O function INKEY$ Returns a character read from the keyboard. ____________________________________________________________________ Syntax: INKEY$ Description: INKEY$ reads from the keyboard to see whether a key has been pressed, and returns one character read. If no key has been pressed, INKEY$ returns a null string. (For the character codes, refer to Appendix C. For the key number assignment, refer to Appendix E.
Chapter 15. Function Reference ____________________________________________________________________ INPort data I/O function INP Returns a byte read from a specified input port. ____________________________________________________________________ Syntax: INP(portnumber) Parameter: portnumber A numeric expression which returns a value from 0 to 32767. Description: INP reads one-byte data from an input port specified by portnumber and returns the value.
____________________________________________________________________ INPUT File I/O function INPUT$ Returns a specified number of characters read from the keyboard or from a device file. ____________________________________________________________________ Syntax: 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.
Chapter 15. Function Reference RunRun-time errors: Error code 05h Meaning Parameter out of the range (numcharas is out of the range.) 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a data file.
____________________________________________________________________ IN STRing String function INSTR Searches a specified target string for a specified search string, and then returns the position where the search string is found. ____________________________________________________________________ Syntax: INSTR([startposition,]targetstring,searchstring) Parameter: startposition A numeric expression which returns a value from 1 to 32767. targetstring and searchstring A string expression.
Chapter 15. Function Reference • A returned value of INSTR is a decimal number from 0 to 255, depending upon the conditions as listed below. Conditions If searchstring is found within targetstring: Returned value First character position of the search string first found. If startposition is greater than the length of targetstring or 255: 0 If targetstring is a null string: 0 If searchstring is not found: 0 If searchstring is a null string: Value of startposition. 1 if startposition option omitted.
____________________________________________________________________ INTeger Numeric operation function INT Returns the largest whole number less than or equal to the value of a given numeric expression ____________________________________________________________________ Syntax: INT(numericexpression) Parameter: numericexpression A real expression. Description: INT returns the largest whole number less than or equal to the value of numericexpression by stripping off the fractional part.
Chapter 15. Function Reference ____________________________________________________________________ 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.
____________________________________________________________________ LENgth String function LEN Returns the length (number of bytes) of a given string. ____________________________________________________________________ Syntax: LEN(stringexpression) Description: LEN returns the length of stringexpression, that is, the number of bytes in the range from 0 to 255. • If stringexpression is a null string, LEN returns the value 0. • LEN counts a full-width Kanji (in the two-byte code mode) as two characters.
Chapter 15. Function Reference ____________________________________________________________________ LOcation Counter of file File I/O function LOC Returns the current position within a specified file. ____________________________________________________________________ Syntax: LOC([#]filenumber) Parameter: filenumber A numeric expression which returns a value from 1 to 16.
RunRun-time errors: Error code 34h Meaning Bad file name or number (You specified filenumber of an unopened file.) 3Ah File number out of the range 3Eh A PUT or GET statement executed without a FIELD statement. (No FIELD statement is found.
Chapter 15. Function Reference ____________________________________________________________________ Location Of File File I/O function LOF Returns the length of a specified file. ____________________________________________________________________ Syntax: LOF([#]filenumber) Parameter: filenumber A numeric expression which returns a value from 1 to 16. Description: LOF returns the length of a data file or communications device file specified by filenumber.
____________________________________________________________________ code MARK I/O function MARK$ Returns the bar code type and the number of digits of a read bar code. ____________________________________________________________________ Syntax: MARK$ Description: MARK$ returns a 3-byte string which consists of the first one byte representing the bar code type and the remaining two bytes indicating the number of digits of a read bar code.
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.
RunRun-time errors: Error code Meaning 05h Parameter out of the range Reference: Functions: LEFT$, LEN, and RIGHT$ 336
Chapter 15. Function Reference ____________________________________________________________________ POSition I/O function POS Returns the current column number of the cursor. ____________________________________________________________________ Syntax: POS(0) Description: POS returns the current column number of the cursor in the current display mode selected by a SCREEN statement, as an integer.
____________________________________________________________________ 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.
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.
RunRun-time errors: Error code 05h Meaning Parameter out of the range 34h Bad file name or number (You specified filenumber of an unopened file.) 36h Improper file type (You specified filenumber of a file other than data files.) 3Ah File number out of the range 3Eh A PUT or GET statement executed without a FIELD statement. (No FIELD statement is found.
Chapter 15. Function Reference ____________________________________________________________________ Start Of Heading I/O function SOH$ Modifies the value of a header (SOH) for the BHT-protocol; also returns the current value of a header.
____________________________________________________________________ STRing String function STR$ Converts the value of a numeric expression into a string. ____________________________________________________________________ Syntax: STR$(numericexpression) Parameter: numericexpression A numeric expression. Description: STR$ converts the value of numericexpression into a string. • If numericexpression is 0 or positive, then STR$ automatically adds a leading space (meaning + sign) as shown below.
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.
____________________________________________________________________ TIME I/O function TIME$ Returns the current system time or wakeup time, or sets a specified system time or wakeup time. ____________________________________________________________________ Syntax: Syntax 1 (Retrieving the current system time or wakeup time): TIME$ Syntax 2 (Setting the current system time or wakeup time): TIME$="time" Parameter: time A string expression.
Chapter 15. Function Reference Syntax 2 Setting the system time TIME$ sets the system time specified by "time." The format of "time" is the same as that in syntax 1. Example: TIME$="13:35:45" Setting the wakeup time TIME$ sets the wakeup time specified by "time." The format of "time" is the same as that in syntax 1. • The calendar clock is backed up by the battery. (For the system date, refer to the DATE$ function.
____________________________________________________________________ TIMER-A/TIMER-B/TIMER-C I/O function TIMEA/TIMEB/TIMEC Returns the current value of a specified timer or sets a specified timer. ____________________________________________________________________ Syntax: Syntax 1 (Retrieving the current value of a specified timer): TIMEA TIMEB TIMEC Syntax 2 (Setting a specified timer): TIMEA=count TIMEB=count TIMEC=count Parameter: count A numeric expression which returns a value from 0 to 32767.
Chapter 15. Function Reference ____________________________________________________________________ VALue String function VAL Converts a string into a numeric value. ____________________________________________________________________ Syntax: VAL(stringexpression) Parameter: stringexpression A string expression which represents a decimal number. Description: VAL converts the string specified by stringexpression into a numeric value. • If stringexpression is nonnumeric, VAL returns the value 0.
Chapter 16 Extended Functions CONTENTS 16.1 Overview.............................................................................................................. 349 16.2 Reading or writing system settings from/to the memory (SYSTEM.FN3) ............ 350 16.2.1 Function Number List of SYSTEM.FN3 ..................................................... 350 16.2.2 Detailed Function Specifications................................................................ 351 16.3 Controlling system files(SYSMDFY.FN3).....
Chapter 16. Extended Functions 16.1 Overview In addition to the BHT-BASIC statements and functions, the BHT-8000 series supports the following extended functions which can be invoked by the CALL statement. Extended functions SYSTEM.FN3 SYSMDFY.FN3 CRC.FN3 SOCKET.FN3 FTP.FN3 BT.FN3 Used to: Remarks Read or write system settings from/to the memory. Reconfigure BHT system or get/set system reconfig file information. Calculate a CRC.
16.2 Reading or writing system settings from/to the memory (SYSTEM.FN3) 16.2.1 Function Number List of SYSTEM.FN3 The SYSTEM.FN3 may read or write system settings depending upon the function number specified, as listed below. Function number 1 .fcSysIGet 2 .fcSysISet 3 .fcSysSGet 4 .fcSysSSet 5 .
Chapter 16. Extended Functions 16.2.2 Detailed Function Specifications .fcSysIGet(=1) Syntax: Description: Read numeric data from System Mode settings CALL "SYSTEM.FN3" .fcSysIGet PARA%,DATA% This function reads numeric data (DATA%) from the system menu item specified by PARA%. Parameter: PARA% Item number of the system menu Returned value: DATA% Numeric data read from the specified system menu item System menu items list: .syM1key 2 Assignment to M1 key R/W .syM2key 3 R/W .
Item number (PARA%) .syCmifApl 12 .syCmifSys 13 .syTrSpdOp 14 - 15 - 16 - 17 .syTrSpdCn 18 .syVPrtyCn 19 .syDatLnCn 20 .syStpLnCn 21 .
Chapter 16. Extended Functions Item number (PARA%) .syHPrtyOp 23 .syLnkTmOp 24 .syFldSpOp 25 .sySNoCn 26 .syHPrtyCn 27 .syLnkTmCn 28 .syFldSpCn 29 .syCmPrtcl 30 .syResm 31 .syRamSize .syRomSize .syClstSize 32 33 34 35 36 37 Trailing spaces in a data field for IrDA interface Serial numbers for direct-connect interface R/W DATA%, numeric data of the system menu item .syHPtyOff 0 No parity (OFF) .syHPtyOn 1 Add (ON) .syLnkT0 0 No timeout .syLnkT30 1 30 sec .syLnkT60 2 60 sec .
.fcSysISet(=2) Syntax: Description: Write numeric data to System Mode settings CALL "SYSTEM.FN3" .fcSysISet PARA%,DATA% This function writes numeric data (DATA%) to the system menu item specified by PARA%. Parameter: PARA% Item number of the system menu DATA% Numeric data to be specified (See the system menu items list given in Function #1.) Returned value: (None) System menu items list: Refer to the System menu items list given in Function #1. .
Chapter 16. Extended Functions .fcSysSSet(=4) Syntax: Description: Write string data to System Mode settings CALL "SYSTEM.FN3" .fcSysSSet PARA%,DATA$ This function writes string data (DATA$) to the system menu item specified by PARA%. Parameter: PARA% Item number of the system menu DATA% String data to be specified (See the System menu items list given in Function #3.) Returned value: (None) System menu items list: Refer to the System menu items list given in Function #3. .
16.3 Controlling system files(SYSMDFY.FN3) 16.3.1 Function Number List of SYSMDFY.FN3 The SYSMDFY.FN3 may reconfigure the BHT system , as well as getting/setting system reconfig file information, depending upon the function number specified, as listed below. Function number 1 .fcMdBVGet 2 .fcMdBDo 3 .fcMdBNGet 4 .fcMdBNSet Used to: Get version of BHT system reconfig file Reconfigure BHT system Get filename of BHT system reconfig file Set filename of BHT system reconfig file 16.3.
Chapter 16. Extended Functions .fcMdBDo(=2) Syntax: Description: Reconfigure BHT system CALL "SYSMDFY.FN3" .fcMdBDo FILE$, OPT% This function automatically reconfigures the BHT system by using the BHT system reconfig file specified by FILE$. Parameter: FILE$ Filename OPT% Task after system reconfiguration .smPwOff Power off 0 .smReset Reset the system software 1 Returned value: (None) RunRun-time errors: Error code 32h .fcMdBNGet(=3) Syntax: Description: Parameter: Returned value: .
16.4 Calculating a CRC (CRC.FN3) 16.4.1 Function Number List of CRC.FN3 The CRC.FN3 may calculate a CRC depending upon the function number specified, as listed below. Function number 2 .fcCcitt 3 .fcCrc16 Used to: Calculate a CRC-CCITT. Calculate a CRC-16. 16.4.2 Detailed Function Specifications .fcCcitt(=2) Syntax: Description: Calculate a CRC-CCITT CALL "CRC.FN3" .fcCcitt STRING1$, [ STRING2$, [...,]] CRC$ This function calculates a CRC of character strings specified by STRING1$, STRING2$, ...
Chapter 17 TCP/IP (BHTs with Bluetooth communications device) CONTENTS 17.1 Two Sides ............................................................................................................ 361 17.1.1 BHT ........................................................................................................... 361 17.1.2 Hosts ......................................................................................................... 361 17.2 Programming Procedure........................................
17.5 Socket Library (SOCKET.FN3)............................................................................. 386 17.5.1 Overview ................................................................................................... 386 17.5.2 Detailed Function Specifications................................................................ 389 17.6 FTP Library (FTP.FN3)........................................................................................ 424 17.6.1 Overview ...................................
Chapter 17. TCP/IP 17.1 Two Sides 17.1.1 BHT The BHT equipped with a spread spectrum communications device or IrDA communications device includes two built-in libraries providing BHT-BASIC programs with access to a subset of the TCP/IP family of protocols over the spread spectrum communication system or IrDA communication system, respectively. SOCKET.FN3: This library implements a subset of the BSD4.4 socket application program interface (API). FTP.
17.2 Programming Procedure 17.2.1 Bluetooth Communication System The following is the procedure for using TCP/IP over a Bluetooth communications device. For programming details, refer to the sample source program separately provided. [ 1 ] Open Bluetooth Communications Device Connect to modem with Bluetooth device and establish data link using the modem. For further details, refer to Section Chapter 18 "Bluetooth (BHTs with Bluetooth communications device)," Subsection 18.2.3.3.
Chapter 17. TCP/IP [ 2 ] Configure TCP/IP System To connect to the TCP/IP pathway, specify the following system settings by using the extension library SOCKET.FN3 in a user program: • IP address • Subnet mask • Default gateway • PPP authentication procedure • User name for PPP authentication • Password for PPP authentication These settings will be used in [ 4 .] For the details of the SOCKET.FN3, refer to Section 17.5 "Socket Library (SOCKET.FN3)." Given below is a setting example with SOCKET.FN3: my.
[ 3 ] Declare TCP/IP Communications Pathway Specify the following system settings by using the socket library (SOCKET.FN3): • Communications device: • Link layer: Bluetooth communications device PPP For the setting procedure with the SOCKET.FN3, refer to Section 17.5 "Socket Library (SOCKET.FN3)." Given below is a setting example using SOCKET.FN3: iftype% = .soDvCOM4 layermode% = .soLyPPP 'Specify Bluetooth communications device 'Specify PPP as a link layer call "socket.fn3" .
Chapter 17. TCP/IP [ 4 ] Connect to TCP/IP Communications Pathway Use the extension library SOCKET.FN3. Connecting to the TCP/IP communications pathway requires the following settings (specified in [ 2 ]): • IP address • Subnet mask • Default gateway • PPP authentication procedure • User name for PPP authentication • Password for PPP authentication There are two ways to specify these parameters. (a) Use the system settings with the extension library SOCKET.FN3. Refer to Section 17.
[ 5 ] Transfer Data or File via Socket Interface To transfer data via the socket interface, use the extension library SOCKET.FN3. Refer to 17.3, "Socket API" and Section 17.5 "Socket Library (SOCKET.FN3)." To transfer file via the socket interface, refer to Section 17.4.3, "Using FTP Client." [ 6 ] Disconnect TCP/IP Communications Pathway Use the extension library SOCKET.FN3. Refer to Section 17.5 "Socket Library (SOCKET.FN3)." Given below is an example using SOCKET.FN3. call "socket.fn3" .
Chapter 17. TCP/IP 17.3 Socket API 17.3.1 Overview The SOCKET.FN3 library implements a subset of the BSD4.4 socket application program interface (API). The following flowcharts show the BSD4.4 socket API calls for the two communications protocols required for the TCP/IP transport layer: transmission control protocol (TCP) for streams and user datagram protocol (UDP) for datagrams.
■ User Datagram Protocol (UDP) 368
Chapter 17. TCP/IP 17.3.2 Programming Notes for Socket API [ 1 ] Programming Notes for TCP (a) Avoid retransmission control in application programs (recommended) The TCP has flow control and retransmission control, so incorporating retransmission control into communication programs using the TCP socket may cause send data to be double sent or unintended data to be received. When using the TCP socket, therefore, do not incorporate retransmission control in applications.
[ 2 ] Programming Notes for UDP The user datagram protocol (UDP) has no flow control, so send/receive data may go missing due to poor line conditions or difference of communications capabilities between wireless and Ethernet. To prevent data missing, be sure to incorporate some flow control process into user programs at both the BHT and host. Given below are message transmission examples that support retransmission controls at each of the BHT and host.
Chapter 17. TCP/IP Host's retransmission control 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.
[ 3 ] Programming Notes for Socket API If TCP/IP communication becomes no longer possible during data transmission, extended functions SOCKET.FN3 and FTP.FN3 will return any of the following run-time errors will be returned. For details about those extended functions, refer to Sections 17.5, "Socket Library (SOCKET.FN3)" and 17.6, "FTP Library (FTP.FN3):" RunRun-time time errors: Error code Meaning 105h Power-off detected. (The BHT has been turned off during data transmission and then turned on.
Chapter 17. TCP/IP (Example) STATUS% = 0 ON ERROR GOTO TCP.ERR 'Prepare for error interrupt (To TCP.ERR 'at the time of error occurrence) DEV.OPEN: '<<<<< Open communications device processing (OPEN "COM1" / OPEN "COM3:") >>>>> STATUS% = 1 TCP.CONNECT: '<<<<< Connect to TCP/IP Communications pathway processing >>>>> '<<<<< (CALL “SOCKET.FN3” 41 / 42) >>>>> STATUS% = 2 TCP.SOCKET: '<<<<< Create socket processing (CALL “SOCKET.
IF STATUS% > 2 THEN '<<<<< Close the socket processing (CALL “SOCKET.FN3 28) >>>>> IF (WERR<>&h105) AND (WERR<>&h106) AND (WERR<>&h108) THEN STATUS% = 2 GOTO TCP.SOCKET ENDIF ENDIF IF STATUS% > 1 THEN '<<<<< Disconnect TCP/IP communications pathway processing >>>>> '<<<<< (CALL “SOCKET.FN3 43) >>>>> IF (WERR<>&h105) THEN STATUS% = 1 GOTO TCP.CONNECT ENDIF ENDIF IF STATUS% > 0 THEN '<<<<< Close communications device processing (CLOSE) >>>>> STATUS% = 0 GOTO DEV.
Chapter 17. TCP/IP Note for runrun-time error 105h Socket close processing (SOCKET.FN3, Function #28) following occurrence of run-time error 105h would not complete immediately. This is because a FIN packet will be transmitted repeatedly in the socket close processing until the communications device receives any response from the server independent of the power on/off state of the communications device.
17.4 FTP Client 17.4.1 Overview The FTP.FN3 library implements FTP client services for file transfers to and from FTP servers. Note that there are no server capabilities. This FTP client transfers files between operating systems in image (binary) format. The only translation support is for line delimiter conversion. Note that this FTP client does not convert between such double-byte character encodings as Shift JIS and EUC.
Chapter 17. TCP/IP 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). Aside: To conserve memory and boost performance, the BHT packs a pair of ASCII bytes into a single byte by converting each byte into a 4-bit hexadecimal number.
[ 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. 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 130 less the number of bytes in the last record.
Chapter 17. TCP/IP Aside: When downloading extension libraries, the BHT uses 128 bytes out of 130 bytes of record length (the remaining 2 bytes will be used for checking data). To conserve memory and boost performance, the BHT packs a pair of ASCII bytes into a single byte by converting each byte into a 4-bit hexadecimal number.
[ 3 ] Data Files The FTP client treats files with extensions other than .PD3, .FN3, and .EX3 as data files. Data file records consist of fields separated with line delimiters. An EOF (1Ah) at the end of the data file is optional. Data files are not limited to ASCII characters. They can use all bytes codes from 00h to FFh. There can be 1 to 16 fields, each 1 to 254 bytes long. The sum of the field lengths and the number of fields, however, must not exceed 255.
Chapter 17. TCP/IP The treatment of short records is under application control. The default is to delete any trailing spaces (20h). Alternatively, the FTP client can pad such short records to the specified record length with spaces (20h).
Line delimiters inside data records The FTP client can send and receive all codes from 00h to FFh as described above. The treatment of line delimiters (CR-LF, CR, or LF) inside downloaded data records is under application control. The default is to split the incoming stream into short records. Alternatively, the FTP client can ignore any line delimiters inside downloaded data records, treating them as data.
Chapter 17. TCP/IP 17.4.3 Using FTP Client [ 1 ] Basic Procedure First, set up for using the FTP client, as necessary, with the following steps. All three are optional, but the last two are highly recommended for downloads. (1) Configure the FTP client with the extension library FTP.FN3. (2) Use the FRE function to check whether there is sufficient free memory available to hold the downloaded file. (3) Use a BHT-BASIC OUT statement to optimize the drive.
[ 3 ] Calculating Memory Requirements The FTP protocol specifications do not provide for checking the amount of BHT memory available during downloads. If the BHT runs out of memory during a download, the FTP client cancels the transfer and deletes the partially downloaded file. The user application program must, therefore, check availability with the FRE function or equivalent method and compare the result with the BHT file size (BFS) before using the download function.
Chapter 17. TCP/IP ■ Data Files Determine MEM from the field lengths and number of records. BPR = bytes per record = (number of fields) + (sum of field lengths) RPB = records per block = ROUND_DOWN (4096 ÷ BPR) MEM = ROUND_UP (records ÷ RPB) × 4096 Example: File with 1000 records with four fields of lengths 13, 12, 6, and 1 BPR = 4 + (13 + 12 + 6 + 1) = 36 RPB = ROUND_DOWN (4096 ÷ 36) = ROUND_DOWN (113.778) = 113 MEM = ROUND_UP (1000 ÷ 113) × 4096 = ROUND_UP (8.
17.5 Socket Library (SOCKET.FN3) 17.5.1 Overview ■ String Variables The following are the string variables used by this library together with their memory requirements. Description ■ Variable name Size in bytes Internet address IPADDRESS$ min. 15 Subnet mask SUBNETMASK$ min. 15 Default gateway GATEWAY$ min. 15 Receive buffer RECVBUFF$ 1 to 255 Transmit buffer SENDBUFF$ 1 to 255 Socket identifier set SOCKFDSET$ READFDSET$ WRITEFDSET$ EXCEPTFDSET$ min. 41 min. 41 min. 41 min.
Chapter 17. TCP/IP ■ Function Number List Number Used to: Corresponding Socket API Function .fcAccept 1* –– accept() .fcBind 2 Assign address to socket bind() .fcConnect 3 Connect socket connect() .fcGPName 4* –– getpeername() .fcGSName 5* –– getsockname() .fcGSckOpt 6 Get socket option getsockopt() .fcHToNL 7 Convert host long (4 bytes) to network byte order htonl() .fcHToNS 8 Convert host short (2 bytes) to network byte order htons() .
Number Used to: Corresponding Socket API Function .fcSocket 26 Create socket socket() .fcWritev 27* –– writev() .fcClose 28 Close socket close() .fcTSetup 40 Specify TCP/IP communications pathway Unique to BHT .fcTCnnSys 41 Connect TCP/IP communications pathway with system settings Unique to BHT .fcTCnnUsr 42 Connect TCP/IP communications pathway with user settings Unique to BHT .fcTDiscnn 43 Disconnect TCP/IP communications pathway Unique to BHT .
Chapter 17. TCP/IP 17.5.2 Detailed Function Specifications Function #2 .fcBind Assign address to socket Syntax: CALL "SOCKET.FN3" .fcBind SOCKFD%, FAMILY%, PORT%, address where address is ADDRESS or IPADDRESS$ Description: This function assigns an address to the specified socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API bind() function.
Function #3 .fcConnect Connect socket Syntax: CALL "SOCKET.FN3" .fcConnect SOCKFD%, FAMILY%, PORT%, address where address is ADDRESS or IPADDRESS$ Description: This function connects the specified socket identifier to another socket. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API connect() function.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 201h Cannot connect to socket 209h Socket identifier is invalid. 216h A parameter is invalid. 229h The specified socket does not match the connection target socket.
Function #6 Syntax: .fcGSckOpt Get socket option CALL "SOCKET.FN3" .fcGSckOpt SOCKFD%, OPTNAME%, option where option is OPTION% or OPTION Description: This function gets the specified option setting for the specified socket. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API getsockopt() function.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 105h Power-off detected. 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 209h Socket identifier is invalid. 216h A parameter is invalid.
Function #7 .fcHToNL Convert host long (4 bytes) to network byte order Syntax: CALL "SOCKET.FN3" .fcHToNL HOSTLONG, NETLONG Description: This function converts a (4-byte) long from host byte order to network byte order. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API htonl() function. Parameters: HOSTLONG Long in host byte order Return value: NETLONG Long in network byte order Function #8 .
Chapter 17. TCP/IP Function #11.fcNToHL Convert network long (4 bytes) to host byte order Syntax: CALL "SOCKET.FN3" .fcNToHL NETLONG, HOSTLONG Description: This function converts a (4-byte) long from network byte to host byte order. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API ntohl() function. Parameters: NETLONG Long in network byte order Return value: HOSTLONG Long in host byte order Function #12.
Function #14.fcRecv Receive data sent to the specified TCP socket Syntax: CALL "SOCKET.FN3" .fcRecv SOCKFD%, RECVBUFF$[()], Description: This function receives data from the IP address and port number connected to the specified socket identifier into the specified buffer. RECVLEN%, RECVMODE%, RECVSIZE% [,RECVFLAG%] BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API recv() function.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 209h Socket identifier is invalid. 216h A parameter is invalid. 228h The maximum number of bytes to receive is too small. 236h An RST from the opposite end has forced disconnection.
Example: Append operation Incoming data: 1024 bytes ("0123456789..........
Chapter 17. TCP/IP Example: Overwrite operation Incoming data: 1024 bytes ("0123456789..........
Function #15.fcRcvfrom Receive data sent to the specified UDP socket Syntax: CALL "SOCKET.FN3" .fcRcvfrom SOCKFD%, RECVBUFF$[()], RECVLEN%, RECVMODE%, FAMILY%, PORT%, address, RECVSIZE% [,RECVFLAG%] where address is ADDRESS or IPADDRESS$ Description: This function receives data sent to the UDP socket specified by the socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API recvfrom() function.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 209h Socket identifier is invalid. 216h A parameter is invalid. 228h The maximum number of bytes to receive is too small. 229h TCP is the wrong protocol here.
Function #17.fcSelect Monitor socket requests 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.
Chapter 17. TCP/IP Function #18.fcFDZERO Initialize socket identifier set Syntax: CALL "SOCKET.FN3" .fcFDZERO SOCKFDSET$ Description: This function initializes the specified socket identifier set. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API FD_ZERO macro. Parameters: Return value: SOCKFDSET$ Socket identifier set (None) Function #19.fcFDSET Add socket identifier to socket identifier set Syntax: CALL "SOCKET.FN3" .
Parameters: Return value: SOCKFD% Socket identifier SOCKFDSET$ Socket identifier set (None) 404
Chapter 17. TCP/IP Function #21.fcFDISSET Get socket identifier status from socket identifier set Syntax: CALL "SOCKET.FN3" .fcFDISSET SOCKFD%, SOCKFDSET$, FDISSET% Description: This function gets the status of the specified socket identifier in the specified socket identifier set. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API FD_ISSET macro.
Function #22.fcSend Send message to another TCP socket Syntax: CALL "SOCKET.FN3" .fcSend SOCKFD%, SENDBUFF$[()], SENDLEN%, SENDMODE%, SENDSIZE% Description: This function transmits data from the specified buffer to the IP address and port number connected to the specified socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API sendto() function.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 209h Socket identifier is invalid. 216h A parameter is invalid. 228h The maximum number of bytes to receive is too small. 237h There is insufficient system area memory.
Function #23.fcSendto Send message to another UDP socket Syntax: CALL "SOCKET.FN3" .fcSendto SOCKFD%, SENDBUFF$[()], SENDLEN%, SENDMODE%, FAMILY%, PORT%, address, SENDSIZE% where address is ADDRESS or IPADDRESS$ Description: This function transmits data from the specified buffer to the IP address and port number connected to the specified socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API sendto() function.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 105h Power-off detected 209h Socket identifier is invalid. 216h A parameter is invalid. 228h The maximum number of bytes to receive is too small. 229h TCP is the wrong protocol here. 237h There is insufficient system area memory. 241h There is no connection pathway to the host.
Function #24.fcSSckOpt Set socket options Syntax: CALL "SOCKET.FN3" .fcSSckOpt SOCKFD%, OPTNAME%, option where option is OPTION% or OPTION Description: This function sets the specified option for the specified socket to the new value. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API setsockopt() function.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 105h Power-off detected. 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 201h Cannot set option after connection established 209h Socket identifier is invalid. 216h A parameter is invalid.
Function #25.fcShutdwn Shut down socket Syntax: CALL "SOCKET.FN3" .fcShutdwn SOCKFD%, HOWTO% Description: This function shuts down socket transfers in the specified direction. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API shutdown() function. Parameters: SOCKFD% Socket identifier HOWTO% Direction specification The direction specification (HOWTO%) must be one of the following values: Return value: .soSdRecv 0 Receive .soSdSend 1 Transmit .
Chapter 17. TCP/IP Function #26.fcSocket Create socket 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.
Run-time errors: Error code Meaning 105h Power-off detected. 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated. 108h The memory for the TCP/IP module has became insufficient during data transmission. 218h Too many sockets 22Bh This protocol family does not support the specified protocol type and protocol. 237h There is insufficient system area memory.
Chapter 17. TCP/IP Function #28.fcClose Close socket Syntax: CALL "SOCKET.FN3" .fcClose SOCKFD% Description: This function closes the specified socket identifier. BSD4.4 socket API equivalent: This function is equivalent to the BSD4.4 socket API close() function. Parameters: SOCKFD% Return value: (None) Socket identifier Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission.
Function #40.fcTSetup Specify TCP/IP communications pathway Syntax: CALL "SOCKET.FN3" .fcTSetup IFTYPE%, LAYERMODE%, Description: This function specifies the TCP/IP communications pathway from the specified communications device and link layer. Parameters: IFTYPE% LAYERMODE% INTERFACE% Communications device Link layer The communications device (IFTYPE%) must be one of the following values: - 0 (Reserved for system) - 2 (Reserved for system) .
Chapter 17. TCP/IP Function #41.fcTCnnSys Connect TCP/IP communications pathway with system settings Syntax: CALL "SOCKET.FN3" .fcTCnnSys INTERFACE% Description: This function connects the TCP/IP communications pathway based on the system settings.
Function #42.fcTCnnUsr Connect TCP/IP communications pathway with user settings Syntax: CALL "SOCKET.FN3" .fcTCnnUsr INTERFACE%, IPADDRESS$, SUBNETMASK$, GATEWAY$, PPPMODE%, USERNAME$, PASSWORD$ Description: This function connects the TCP/IP communications pathway based on the supplied user settings.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 34h Communications device file not open 101h Cannot connect to communications pathway 102h Communications pathway not specified 103h Communications pathway already connected 105h Power-off detected 216h A parameter is invalid.
Function #43.fcTDiscnn Disconnect TCP/IP communications pathway Syntax: CALL "SOCKET.FN3" .fcTDiscnn INTERFACE% Description: This function disconnects the specified TCP/IP communications pathway. Parameters: INTERFACE% Return value: Communications pathway (None) Run-time errors: Error code Meaning 104h Communications pathway already disconnected 105h Power-off detected 216h A parameter is invalid.
Chapter 17. TCP/IP Function #44.fcTSysGet Get TCP/IP system settings Syntax: CALL "SOCKET.FN3" .fcTSysGet PARA%, data where data is DATA% or DATA$ Description: This function gets the current setting for the specified TCP/IP system settings. Parameters: PARA% Item number Return value: data Current setting for TCP/IP system settings (DATA%/DATA$) Correspondence tables: Item number (PARA%) .soPPPAuth .soDvGet .
Function #45.fcTSysSet Set TCP/IP system settings Syntax: CALL "SOCKET.FN3" .fcTSysSet PARA%, data where data is DATA% or DATA$ Description: This function sets the specified TCP/IP system settings to the new value. Parameters: PARA% Item number data New setting for TCP/IP system settings (DATA%/DATA$) Return value: (None) Correspondence tables: Refer to Table under function #44.
Chapter 17. TCP/IP Function #46.fcTStsGet Get TCP socket status Syntax: CALL "SOCKET.FN3" .fcTStsGet SOCKFD%, PATTERN%, Description: This function waits until the specified TCP socket is in the specified state or the specified time elapsed.
17.6 FTP Library (FTP.FN3) 17.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 Server IP address SERV.IP 15 Login user name USERNAME$ 0 to 16 Login password PASSWORD$ 0 to 16 Directory names CURDIR$ NEWDIR$ 0 to 255 0 to 255 File names SERV.FNAME$ CLNT. FNAME$ OLD.FNAME$ NEW.FNAME$ 0 to 12 0 to 12 0 to 12 0 to 12 Field lengths FLD$ 1 to 64 (48) FTP parameter FTP.
Chapter 17. TCP/IP ■ Reply Codes The messages that FTP servers send during and after FTP operations vary, but servers all use the same reply codes. (Refer to Table.) All function numbers therefore supply these as their return value (REPLY%). Reply Codes Description 110 Restart marker replay. 120 Service ready in nnn minutes. 125 Data connection already open; transfer starting. 150 File status okay; about to open data connection. 200 Command okay.
Reply Codes Description 426 Connection closed; transfer aborted. 450 Requested file action not taken. File unavailable (e.g., file busy). 451 Requested action aborted: local error in processing. 452 Requested action not taken. Insufficient storage space in system. 500 Syntax error, command unrecognized. This may include errors such as command line too long. 501 Syntax error in parameters or arguments. 502 Command not implemented. 503 Bad sequence of commands.
Chapter 17. TCP/IP 17.6.2 Detailed Function Specifications Function #1 .fcFTPOpnS Open FTP client session with system settings Syntax: CALL "FTP.FN3" .fcFTPOpnS FTPHANDLE%, REPLY% Description: This function opens an FTP client session using the system settings.
Function #2 .fcFTPOpnU Open FTP client session with user settings Syntax: CALL "FTP.FN3" .fcFTPOpnU FTPHANDLE%, SERV.IP$, Description: This function opens an FTP client session based on the supplied user settings. Parameters: SERV.
Chapter 17. TCP/IP Function #3 .fcFTPClos Close FTP client session Syntax: CALL "FTP.FN3" .fcFTPClos FTPHANDLE%, REPLY% Description: This function closes the specified FTP client session. Parameters: FTPHANDLE% FTP client handle Return value: REPLY% Server response to FTP command Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission. 107h The TCP/IP module has not been initiated.
Function #4 .fcPWD Get current directory on FTP server Syntax: CALL "FTP.FN3" .fcPWD FTPHANDLE%, CURDIR$, REPLY% Description: This function gets the current directory on the FTP server. Parameters: FTPHANDLE% FTP client handle Return value: CURDIR$ REPLY% FTP server current directory Server response to FTP command Run-time errors: Error code Note: Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission.
Chapter 17. TCP/IP Function #5 .fcCWD Change current directory on FTP server 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 REPLY% Server response to FTP command Return value: Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission.
Function #6 .fcRETR Download file from FTP server Syntax: CALL "FTP.FN3" .fcRETR FTPHANDLE%, SERV.FNAME$, CLNT.FNAME$, CRLF.TYPE%, CRLF.MODE%, REPLY% [,FLD$] [,DISP.MODE%] Description: This function downloads, from the current directory on the FTP server to the BHT, the specified file using the specified parameters. Parameters: FTPHANDLE% FTP client handle SERV.FNAME$ Name of file to download from FTP server CLNT.FNAME$ Name for file on handy terminal.
Chapter 17. TCP/IP .ftRcdData 1 Treat line delimiters in records as DATA. TRIM trailing spaces in fields. .ftLspDel 10 Treat line delimiters in records as SEPARATORS. RETAIN trailing spaces in fields. .ftLspData 11 Treat line delimiters in records as DATA. RETAIN trailing spaces in fields. FLD$ Field lengths in bytes. Delimit the field length specifications with commas (,) or semicolons (;). (This parameter applies only to downloaded data files.) " [,,...
CRLF.MODE% = .ftRcdSepa 'Data composition: Will be ignored for 'files except data files DISP.MODE% = .ftDisp 'Enable progress display CALL "FTP.FN3" .fcRETR FTPHANDLE%, SERV.FNAME$, CLNT.FNAME$, CRLF.TYPE%, _ CRLF.MODE%, REPLY%, DISP.
Chapter 17. TCP/IP Run-time errors: Error code Meaning 02h Syntax error (Incorrect file name) 05h Number of field items or number of digits in a field out of the range 07h Insufficient memory space 32h Wrong file type 33h Invalid text received 37h File already open 39h Too many files 3Ch Record exceeds 255 bytes. 3Dh Field mismatch error 41h File damaged 47h User break with cancel (C) key 49h Invalid program file received (Invalid program size.
Function #7 .fcSTOR Upload file to FTP server Syntax: CALL "FTP.FN3" .fcSTOR FTPHANDLE%, SERV.FNAME$, Description: This function uploads, from the BHT to the current directory on the FTP server, the specified file using the specified parameters. Parameters: FTPHANDLE% SERV.FNAME$ CLNT.FNAME$, CRLF.TYPE%, UP.MODE%, REPLY% [,DISP.MODE%] CLNT.FNAME$ CRLF.TYPE% UP.MODE% FTP client handle Name for file on FTP server. Leaving this unspecified ("") uses the name in CLNT.FNAME$ instead.
Chapter 17. TCP/IP Example: Uploading program file, with progress display CLNT.FNAME$ = "SAMPLE.PD3" 'Name of file on BHT SERV.FNAME$ = "" 'Name on server CRLF.TYPE% = .ftCRLF 'Server line delimiter: CR-LF combination UP.MODE% = .ftUpSTOR 'Upload mode: Overwrite DISP.MODE% = .ftDisp 'Enable progress display 'Same as on BHT CALL "FTP.FN3" .fcSTOR FTPHANDLE%, SERV.FNAME$, CLNT.FNAME$, CRLF.TYPE%, _ UP.MODE%, REPLY%, DISP.
Function #8 .fcFSysGet Get FTP system settings Syntax: CALL "FTP.FN3" .fcFSysGet PARA%, ftp.para where ftp.para is FTP.PARA% or FTP.PARA$ Description: This function gets the current setting for the specified FTP system settings. Parameters: PARA% Item number Return value: ftp.para Current setting for FTP system settings of type integer/string (FTP.PARA%/FTP.PARA$) Correspondence tables: Item number (PARA%) Values for Setting (FTP.PARA%) Description .
Chapter 17. TCP/IP Function #9 .fcFSysSet Change FTP system settings Syntax: CALL "FTP.FN3" .fcFSysSet PARA%, ftp.para where ftp.para is FTP.PARA% or FTP.PARA$ Description: This function changes the specified FTP system settings to the new value. Parameters: PARA% ftp.para Return value: (None) Item number New setting for FTP system settings of type integer/string (FTP.PARA%/FTP.PARA$) Correspondence tables: Refer to Table under .fcFSysGet.
Function #10.fcRNFR Change file name on FTP server Syntax: CALL "FTP.FN3" .fcRNFR FTPHANDLE%, OLD.FNAME$, Description: This function changes the name of a file in the current directory on the FTP server. Parameters: FTPHANDLE% OLD.FNAME$ NEW.FNAME$ FTP client handle Name before change Name after change Return value: REPLY% Server response to FTP command NEW.
Chapter 17. TCP/IP Function #11.fcPORT Set port number for file transfer Syntax: CALL "FTP.FN3" .fcPORT FTPHANDLE%, PORT% Description: This function sets a port number specified by PORT% for file transfer. Parameters: FTPHANDLE% PORT% FTP client handle Port number When specifying the value greater than 32767, describe in hexadecimal notation.
Function #12.fcDELE Delete file from FTP server Syntax: CALL "FTP.FN3" .fcDELE FTPHANDLE%, SERV.FNAME$, REPLY% Description: This function deletes a file specified by SERV.FNAME$ from the FTP server. Parameters: FTPHANDLE% SERV.FNAME$ FTP client handle File name to be deleted Return value: REPLY% Server response to FTP command Run-time errors: Error code Meaning 105h Power-off detected 106h An internal error has occurred in the TCP/IP module during data transmission.
Chapter 18 Bluetooth (BHTs with Bluetooth communications device) CONTENTS 18.1 Bluetooth Communications.................................................................................. 444 18.1.1 Introduction................................................................................................ 444 18.1.2 System Components ................................................................................. 445 18.2 Programming Overview ...............................................................
18.1 Bluetooth Communications 18.1.1 Introduction The BHT supports the following profiles based on the Bluetooth TM Specification Ver.1.1.
Chapter 18. Bluetooth 18.1.2 System Components The following figures give examples of Bluetooth networks using the BHT. For further details, refer to the BHT User's Manual.
• The BHT does not support multiple simultaneous links (Piconet.) As master, the BHT supports only one slave at a time. BHT (master) BHT (master) Slave Slave Available Not Available • As a slave, however, the BHT can connect to a master supporting multiple simultaneous links (Piconet.
Chapter 18. Bluetooth 18.2 Programming Overview 18.2.1 Software Components The BHT system consists of the BHT main system and Bluetooth communications device. The former executes user programs and the latter performs Bluetooth communications. User programs use the logical communications device file "COM4" to control the Bluetooth communications device. BHT main system User program in BHT-BASIC BHT-BASIC statements and functions Communications OPEN,CLOSE, PRINT #, etc. Settings BT.
18.2.2 Statements and Functions Used Bluetooth communications uses the following statements and functions. (1) Statements and functions Refer to Section 18.3, "Bluetooth Statements and Functions." (2) Bluetooth communications device control extended function (BT.FN3) Refer to Section 18.4, "Bluetooth Extended Functions (BT.FN3)." (3) Socket library for TCP/IP data transfer (SOCKET.FN3) Refer to Section 17.5, "Socket Library (SOCKET.FN3)." (4) FTP library for file transfer (FTP.FN3) Refer to Section 17.
Chapter 18. Bluetooth 18.2.3 Programming Procedures 18.2.3.1 Discovering Accessible Remote Devices in the Vicinity (Inquiry) The BHT supports the Generic Access Profile for discovering accessible Bluetooth devices in the vicinity. Connecting to a remote device as master requires specifying the Bluetooth device address for that device. If that address is unknown, the BHT must first determine the addresses of accessible Bluetooth devices in the vicinity.
There are two ways to specify the above parameters. • Use the system settings • Specify them in the OPEN statement The user modifies the system settings with the system menu; the user program, with extended function BT.FN3 function numbers .fcBTSetVal. For further details on the system menu, refer to the BHT User's Manual. Specifying a parameter in the OPEN statement does not affect the system settings. Given below are examples discovering accessible remote devices in the vicinity.
Chapter 18. Bluetooth 18.2.3.2 Serial Link with Remote Device The BHT supports the Serial Port Profile for RS232 (or similar) serial cable emulation through a virtual serial port. The BHT establishes a connection to an emulated serial port (or equivalent) in a remote device for serial communications. After connection, the interface is similar to the IrDA and direct-connect interfaces, using, for example, BHT-BASIC PRINT # statements for output and INPUT$ function calls for input.
to the specified slave device. Otherwise, the Bluetooth communications device waits for a call from a master before connecting. For further details on parameters, refer to the BHT User's Manual. There are two ways to specify the above parameters. • Use the system settings • Specify them in the OPEN statement The user modifies the system settings with the system menu; the user program, with extended function BT.FN3 function numbers .fcBTSetVal and .fcBTSetStr.
Chapter 18. Bluetooth OPEN "COM4:M,SPP,112233AABBCC" AS #4 ' Address for remote device: ' 11:22:33:AA:BB:CC" ' Use serial communications facilities PRINT #4,sendbuff$; ' ' Transmit data Read data received ' For details about reading data received, ' refer to Section 18.2.4.2 "Reading data received in serial communications.
18.2.3.3 Dial-Up Networking via Remote Device The BHT supports the Dial-up Networking Profile for accessing the Internet via a modem or other device supporting dial-up access. The BHT uses a Bluetooth connection to control dial-up Internet access by the modem inside a cell phone, base station, or other suitably equipped device. The following is the procedure for connecting to the Internet with such a modem and using TCP/IP communications.
Chapter 18. Bluetooth Disconnect TCP/IP communications pathway (PPP layer) Extended function SOCKET.FN3 function number .fcTDiscnn Use modem to break data link PRINT # statement, INPUT$ function, etc. Break Bluetooth connection to modem CLOSE statement Close Bluetooth communications device file Dial-up networking connections have the following parameters.
OPEN "COM4:M,DUN" AS #4 (b) Specifying parameters in the OPEN statement OPEN "COM4:M,DUN,112233AABBCC,BHT,30,2" AS #4 ' Address for remote device: ' 11:22:33:AA:BB:CC" ' Bluetooth passkey: BHT ' Connection timeout: 30 seconds ' Security mode: service level For further details on OPEN "COM4:" statement, refer to Section 18.3 "Bluetooth Statements and Functions." (Example) Connect to the Internet using a cell phone and transfer data and files over socket interface.
Chapter 18. Bluetooth auh% = .soPPPPAP ' PPP authentication procedure: PAP usr$ = "USER" ' User name for PPP authentication psw$ = "PASSWORD" ' Password for PPP authentication CALL "SOCKET.FN3" .fcTCnnUsr Interface%,ip$,msk$,gw$,auh%,usr$,psw$ ' Data and file transfers over socket interface 'Omitted ' Disconnect TCP/IP communications pathway CALL "SOCKET.FN3" .
18.2.3.4 Service Discovery The BHT supports the Service Discovery Application Profile for querying and browsing for services offered by another Bluetooth device. The following is the procedure. Open Bluetooth communications device file OPEN "COM4:M,SDAP" statement Query and browse for services by specified remote device Extended function BT.FN3 number .
Chapter 18. Bluetooth (a) Using the system settings OPEN "COM4:M,SDAP" as #4 (b) Specifying parameters in the OPEN statement OPEN "COM4:M,SDAP,112233AABBCC,BHT,60" as #4 ' Address for remote device: ' 11:22:33:AA:BB:CC" ' Bluetooth passkey: BHT ' Service discovery timeout: 60 seconds For further details on the OPEN "COM4:" statement and BT.FN3 extended function, refer to Sections 18.3 "Bluetooth Statements and Functions" and 18.4 "Bluetooth Extended Functions (BT.FN3)," respectively.
18.2.4 Programming Notes 18.2.4.1 Retransmission control in serial communications Any system design using wireless communications must assume data losses due to line quality deterioration and data duplication due to delays during transmission. If the user program does not use the BHT protocol, the BHT-Ir protocol, or TCP/IP, it must implement its own protocol providing retransmission and flow control. The following gives an example of such retransmission control for a user program.
Chapter 18. Bluetooth 18.2.4.2 Reading data received in serial communications We recommend that user programs always follow the approach shown below, setting a timeout and only reading data with INPUT$ functions and the like when there is actual data in the receive buffer because there is every possibility of the direct approach hanging, waiting for data, due to disconnection of the remote device or motion out of communications range. Note that extended function BT.FN3 function number .
Do not use INPUT# or LINE INPUT# statement for reading data received. The INPUT# or LINE INPUT# statement waits for reception of CR (0Dh) or comma (,), so it cannot terminate in the case of data missing due to communications line error or disconnection of the communications line.
Chapter 18. Bluetooth 18.2.4.3 Resume Operation Bluetooth communications does not support resume operation. If the BHT shuts itself down due to low battery, etc, when the Bluetooth communications device file is opened, the results of Bluetooth-related statements and functions executed during shutdown are not assured so that coincidence between transmitted and received data is not assured. The solution is to use the BHT-protocol, BHT-Ir protocol, or TCP/IP or create protocols in user programs.
18.2.4.4 Power Supply Control Power supply control of Bluetooth communications device Closing the Bluetooth communications device file or switching to the power-saving mode while the Bluetooth communications device is not in use reduces the power consumption and extends the time that the BHT can be used between recharges.
Chapter 18. Bluetooth User Program Request for shift to power-saving mode Data transfer Request to leave power-saving mode HOLD mode interval BHT buffers transmit data in HOLD mode. BHT sends data at the end of the current HOLD mode interval Power-saving mode operation • Power-saving mode introduces delays. For operations involving real-time communications, we recommend that the power-saving mode be disabled. For operations using protocols for file transfer, etc.
18.3 Bluetooth Statements and Functions 18.3.1 Overview The following statements and functions are available for use with the Bluetooth communications device.
Chapter 18.
18.3.2 Detailed Specifications OPEN "COM4:I" Open the Bluetooth communications device file in inquiry mode, discovering accessible remote devices in the vicinity Syntax: OPEN "COM4:I[, [discoverytime][,[ no.of.devices]]]" AS [#]filenumber Parameter: discoverytime Integer from 0 to 255. no.of.devices Integer from 0 to 8. filenumber A numeric expression which returns a value from 1 to 16.
Chapter 18. Bluetooth ■ COM4 This indicates the Bluetooth interface. Note that the BHT cannot open this communications device file concurrently with the IrDA interface or direct-connect interface. ■ I This specifies opening in inquiry mode. ■ discoverytime This specifies the maximum interval to wait for responses from accessible remote devices. The unit is seconds; the range, 0 to 255. Note, however, that any value above 62 is rounded downward to produce a maximum discovery time of 62 seconds.
RunRun-time errors: Error code Meaning 105h Power-off detected 600h Failed to open a Bluetooth communications device file. For error codes other than the above, refer to Chapter 14 "Statement Reference.
Chapter 18. Bluetooth OPEN "COM4:M" Open the Bluetooth communications device file with the BHT as master and connect to a slave Syntax: OPEN "COM4:M, serviceprofile [, [deviceaddress][, [passkey][, [timeout][, [securitymode]]]]]" AS [#]filenumber Parameter: serviceprofile SDAP, SPP, or DUN. deviceaddress String of 12 hexadecimal digits. passkey Character string, Max. 16 bytes. timeout Integer from 1 to 255. securitymode Integer from 1 to 3.
■ COM4 This indicates the Bluetooth interface. Note that the BHT cannot open this communications device file concurrently with the IrDA interface or direct-connect interface. ■ M This specifies opening in master mode. ■ serviceprofile This specifies the service profile for the Bluetooth interface connection. SDAP Service Discovery Application Profile The extended function BT.FN3 then provides access to the discovery results.
Chapter 18. Bluetooth ■ timeout This specifies a time limit for completing the operation. The unit is seconds; the range, 1 to 255. Leaving this parameter blank specifies the use of the system setting. Specifying a parameter does not affect the system setting. ■ securitymode This specifies the security mode for the connection, one of the following values.
RunRun-time errors: Error code Meaning 47h Abnormal end of communications communications by the Clear key 105h Power-off detected 600h Failed to open a Bluetooth communications device file. 601h Failed to connect. 602h Connection timed out. 630h No services found. 631h Service discovery timed out. or termination of For error codes other than the above, refer to Chapter 14, "Statement Reference.
Chapter 18. Bluetooth OPEN "COM4:S" Open the Bluetooth communications device file with the BHT as a slave and wait for a master Syntax: OPEN "COM4:S, serviceprofile [, [passkey][, [timeout][, [securitymode]]]]" AS [#]filenumber Parameter: serviceprofile SPP passkey Character string, Max. 16 bytes. timeout Integer from 1 to 255. securitymode Integer from 1 to 3. filenumber A numeric expression which returns a value from 1 to 16.
■ COM4 This indicates the Bluetooth interface. Note that the BHT cannot open this communications device file concurrently with the IrDA interface or direct-connect interface. ■ S This specifies opening in slave mode. ■ serviceprofile This specifies the service profile for the Bluetooth interface connection. SPP Serial Port Profile ■ passkey This specifies the Bluetooth passkey (Bluetooth PIN), character string, Max. 16 bytes, for authentication between Bluetooth devices.
Chapter 18. Bluetooth Leaving this parameter blank specifies the use of the system setting. Specifying a parameter does not affect the system setting. For further details on Bluetooth device address, Bluetooth passkey, and security mode, refer to the BHT User's Manual. Pressing the clear key aborts the operation with run-time error 47h. Syntax errors: Refer to Chapter 14, "Statement Reference.
Close the Bluetooth communications device file CLOSE Refer to Chapter 14, "Statement Reference." INPUT # Read data from the Bluetooth communications device file into specified variables Refer to Chapter 14, "Statement Reference." LINE INPUT #Read data from the Bluetooth communications device file into a string variable Refer to Chapter 14, "Statement Reference.
Chapter 18. Bluetooth Write data to the Bluetooth communications device file PRINT # Syntax: Refer to Chapter 14, "Statement Reference." Parameter: Refer to Chapter 14, "Statement Reference." Description: Refer to Chapter 14, "Statement Reference." A PRINT # statement ends with the write of the data to the Bluetooth communications device file. It provides no guarantee that the data actually reached the other end. The user program must use either extended function BT.FN3 function number .
WAIT Wait for a change in Bluetooth communications device file receive buffer status Refer to Chapter 14, "Statement Reference." XFILE Transfer file using the specified communications protocol Refer to Chapter 14, "Statement Reference." EOF Read whether there is data in the Bluetooth communications device file receive buffer Refer to Chapter 14, "Statement Reference." LOC Read the number of bytes in the Bluetooth communications device file receive buffer Refer to Chapter 14, "Statement Reference.
Chapter 18. Bluetooth 18.4 Bluetooth Extended Functions (BT.FN3) 18.4.1 Overview The Bluetooth extended functions (BT.FN3) used in a BHT-BASIC CALL statement reads or writes Bluetooth parameters and controls operation. If Bluetooth communications device becomes no longer possible, a run-time error 105h may occur. In such a case, close the device file and then open again. ■ Function Number List of BT.FN3 Function number Used to: .fcBTGetVal 1 Read Bluetooth integer setting .
18.4.2 Detailed Specifications Function #1 .fcBTGetVal Read Bluetooth integer setting Syntax: CALL "BT.FN3" .fcBTGetVal PARA%,DATA% Description: This function reads the specified Bluetooth setting into the specified integer variable. Parameters: PARA% Item number Returned value: DATA% Integer read from the specified Bluetooth setting Correspondence table: Item number (PARA%) Attribute parameter *1 Parameter value (DATA%) Initial value .
Chapter 18. Bluetooth Function #2 .fcBTSetVal Write Bluetooth integer setting Syntax: CALL "BT.FN3" .fcBTSetVal PARA%,DATA% Description: This function writes the specified value to the specified Bluetooth integer setting. Parameters: PARA% Item number DATA% New setting Returned value: (None) Correspondence table: Refer to the correspondence table given in Function .fcBTGetVal. Note: The new setting takes effect the next time that the Bluetooth communications device file is opened.
Function #3 .fcBTGetStr Read Bluetooth string setting Syntax: CALL "BT.FN3" .fcBTGetStr PARA%,DATA$ Description: This function reads the specified Bluetooth string setting into the specified string variable. Parameters: PARA% Item number Returned value: DATA$ String read from the specified Bluetooth setting Correspondence table: Item number (PARA%) Attribute parameter *1 Parameter value (DATA$) Initial value .btLocNam 1 Bluetooth device name WO Character string, Max.
Chapter 18.
Function #4 .fcBTSetStr Write Bluetooth string setting Syntax: CALL "BT.FN3" .fcBTSetStr PARA%,DATA$ Description: This function writes the specified value to the specified Bluetooth string setting. Parameters: PARA% Item number DATA$ New setting Returned value: (None) Correspondence table: Refer to the correspondence table given in Function .fcBTGetStr. Note: The new setting takes effect the next time that the Bluetooth communications device file is opened.
Chapter 18. Bluetooth Function #7 .fcBTSysVer Read Bluetooth system version Syntax: CALL "BT.FN3" .fcBTSysVer BTSYSVER$ Description: This function reads the Bluetooth system version. Parameters: (None) Returned value: BTSYSVER$ Bluetooth system version (fixed at 4 characters) The user program must allocate at least 4 bytes to BTSYSVER$.
Function #8 .fcBTDevInf Read Bluetooth device information Syntax: CALL "BT.FN3" .fcBTDevInf PARA%,DATA$ Description: This function reads Bluetooth device information. Parameters: PARA% Item number Returned value: DATA$ Current Bluetooth information setting Correspondence table: Item number (PARA%) Attribute parameter *1 Parameter value (DATA$) .btFWVer 1 Bluetooth device firmware version RO Character string, Max. 9 bytes .
Chapter 18. Bluetooth Run-time errors: Error code Meaning 05h Parameter out of the range 34h Bad file name or number. (The Bluetooth communications device file is not opened) F0h Mismatch parameter number F1h Mismatch parameter type F2h Out of string variable space 105h Power-off detected. 622h No response from Bluetooth interface Example: Read and display Bluetooth device address. OPEN "COM4:I,0" AS #4 ' Open Bluetooth communications device file PARA% = .btDevAdr CALL "BT.FN3" .
Function #9 .fcBTRmtNam Get remote device name Syntax: CALL "BT.FN3" .fcBTRmtNam BDADDR$,BDNAME$ Description: This function gets the Bluetooth device name for the remote device at the specified Bluetooth address. Parameters: BDADDR$ Bluetooth device address (string of 12 hexadecimal digits) Returned value: BDNAME$ Device name (character string, Max. 248 bytes) If the name is longer than the string length of BDADDR$, the interface discards the excess bytes.
Chapter 18. Bluetooth Run-time errors: Error code Meaning 05h Parameter out of the range 34h Bad file name or number. (The Bluetooth communications device file is not opened) F0h Mismatch parameter number F1h Mismatch parameter type F2h Out of string variable space 105h Power-off detected. 621h Failed to get remote device name. 622h No response from Bluetooth interface Example: Get and display remote device name.
Function #10 .fcBTInqRes Read remote device discovery results Syntax: CALL "BT.FN3" .fcBTInqRes NUM%,BDADDR$[()] Description: This function reads results of remote device discovery with a OPEN "COM4:I" statement. Parameters: (NONE) Returned value: NUM% Number of remote devices discovered (0 to 8) BDADDR$[()] Bluetooth device addresses (strings of 12 hexadecimal digits each) for remote device discovered. NUM% gives the number of valid addresses in the array BDADDR$.
Chapter 18. Bluetooth Run-time errors: Error code Meaning 05h Parameter out of the range 34h Bad file name or number. (The Bluetooth communications device file is not opened) F0h Mismatch parameter number F1h Mismatch parameter type F2h Out of string variable space 105h Power-off detected.
Function #11 .fcBTRmtInf Get Bluetooth device address for remote device Syntax: CALL "BT.FN3" .fcBTRmtInf BDADDR$ Description: This function gets the Bluetooth device address for the connected remote device. Parameters: (None) Returned value: BDADDR$ Bluetooth device address (string of 12 hexadecimal digits) for connected remote device The user program must allocate at least 12 bytes to BDADDR$. Note: The function should be executed after execution of OPEN "COM4:M" or OPEN "COM4:S" statement.
Chapter 18. Bluetooth Function #12 .fcBTGetStt Read connection status Syntax: CALL "BT.FN3" .fcBTGetStt STATUS% Description: This function reads the current connection status. Parameters: (None) Returned value: STATUS% Note: Current connection status STATUS% Current Connection Status 0 Not connected. 1 Not connected. Connection broken by the other end. 2 Connected. 3 Connected (in power-saving mode.) 4 Not connected. BHT power off.
Function #13 .fcBTGetLnk Read authenticated Bluetooth device addresses Syntax: CALL "BT.FN3" .fcBTGetLnk NUM%,BDADDR$[()] Description: This function reads the Bluetooth device addresses of authenticated remote devices. Parameters: (NONE) Returned value: NUM% Number of authenticated remote devices (0 to 3) BDADDR$[()] Bluetooth device addresses (strings of 12 hexadecimal digits each) for authenticated remote devices. NUM% gives the number of valid addresses in the array BDADDR$.
Chapter 18. Bluetooth Function #14 .fcBTClrLnk Erase authenticated Bluetooth device addresses Syntax: CALL "BT.FN3" .fcBTClrLnk [BDADDR$] Description: This function erases the Bluetooth device addresses of authenticated remote devices. Parameters: BDADDR$[()] Authenticated Bluetooth device addresses (strings of 12 hexadecimal digits each) to erase. Omitting the BDADDR$ parameter erases the entire list.
Function #15 .fcBTHold Control power-saving mode Syntax: CALL "BT.FN3" .fcBTHold INTERVAL% Description: This function shifts into the power-saving mode or disable it. For further details on the power-saving mode, refer to Section 18.2.4.4 "Power Supply Control." Parameters: INTERVAL% HOLD mode interval (0, 1 to 128 (unit: 100 ms)) Setting INTERVAL% to 0 disables the use of the power-saving mode.
Chapter 18. Bluetooth Run-time errors: Error code Meaning 05h Parameter out of the range 34h Bad file name or number. (The Bluetooth communications device file is not opened) F0h Mismatch parameter number F1h Mismatch parameter type 105h Power-off detected.
Function #20 .fcBTChkSnd Check data transmit result Syntax: CALL "BT.FN3" .fcBTChkSnd STATUS% Description: This function checks whether all transmit data has been transmitted to the remote device. Parameters: (None) Returned value: STATUS% Note: Status STATUS% Current Connection Status 0 Transmission complete 1 Transmission not complete The function should be executed after execution of OPEN "COM4:M" or OPEN "COM4:S" statement.
Chapter 18. Bluetooth Example: Transmit a message and wait for completion of the transmission PRINT #4, "1234567890" ' Transmit data TIMEA = 50 ' Transmission timeout: 5 seconds SLOOP% = 1 WHILE TIMEA<>0 AND SLOOP% = 1 ' Wait for transmission completion ' or timeout CALL "BT.FN3" .
Function #21 .fcBTGetSvc Read service discovery results Syntax: CALL "BT.FN3" .fcBTGetSvc NUM%,SCLASS%[()],SNAME$[()] Description: This function reads results from service discovery with an OPEN "COM4:M,SDAP" statement.
Chapter 18. Bluetooth SNAME$ entries, the interface stops when the arrays are full. If the service name is longer than the string length of SNAME$, the interface discards the excess bytes. Note: The function should be executed after execution of OPEN "COM4:M,SDAP" statement. Run-time errors: Error code Meaning 34h Bad file name or number. (The Bluetooth communications device file is not opened) F0h Mismatch parameter number F1h Mismatch parameter type 105h Power-off detected.
Appendices CONTENTS Appendix A Error Codes and Error Messages ....................................................... 505 A1. Run-time Errors.......................................................................................... 505 A2. Compilation Errors ..................................................................................... 509 Appendix B Reserved Words ................................................................................ 517 Appendix C Character Sets ........................
Appendices Appendix A Error Codes and Error Messages A1. RunRun-time Errors Error code 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch 0Dh 0Fh 10h 14h 1Fh 32h 33h 34h 35h Meaning Internal system error NEXT without FOR Syntax error RETURN without GOSUB Out of DATA (No DATA values remain to be read by the READ statement.) Parameter out of the range The operation result is out of the allowable range. Insufficient memory space (Too deep nesting, etc.
Error code 36h 37h 38h 39h 3Ah 3Bh 3Ch 3Dh 3Eh 3Fh 40h 41h 42h 43h 45h 46h 47h 48h 49h F0h F1h F2h 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 (An 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 value.
Appendices Error code 100h 101h 102h 103h 104h 105h 106h 107h 108h 110h 111h 201h 209h 20Dh 216h 218h 224h 225h 228h 229h 22Ah 22Bh 22Fh 230h 231h 236h 237h 238h 239h 23Ah 23Ch 23Dh 241h Meaning Cannot specify communications pathway Cannot connect to communications pathway Communications pathway not specified Communications pathway already connected Communications pathway already disconnected Power-off detected An internal error has occurred in the TCP/IP module during data transmission.
Error code 293h 295h 600h 601h 602h 610h 620h 621h 622h 630h 631h 640h 641h Meaning The problem occurred on the communication pathway. There is no user for login request. Failed to open a Bluetooth communications device file. Failed to connect. Connection timed out. Bluetooth data link already disconnected. Not connected to a remote device. Failed to get remote device name. No response from Bluetooth interface. No services found. Service discovery timed out. Failed to shift to power-saving mode.
Appendices A2.
Syntax Errors Error code & Message error 1: Improper label format error 2: Improper label name (redefinition, variable name, or reserved word used) error 3: ’"’missing error 4: Improper expression error 5: Variable name redefinition (common variable already defined as label name or variable name) error 6: Variable name redefinition (register variable already defined as label name or variable name) error 7: Variable name redefinition (variable already defined as label name, non-array string work variable, re
Appendices 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 variable (work integer array, two-dimensional) error 27: Too many variables (work float array, two-dimensional) error 28: Too many variables (work string array, two-dimensional) error 29: Too many varia
Error code & Message error 46: error 47: error 48: error 49: error 50: Incorrect use of IF...THEN...ELSE...ENDIF error 51: Incomplete control structure (IF...THEN...ELSE...ENDIF) error 52: Incorrect use of FOR...NEXT error 53: Incomplete control structure (FOR...NEXT) error 54: Incorrect FOR index variable error 55: Incorrect use of SELECT...CASE...END SELECT error 56: Incomplete control structure (SELECT...CASE...END SELECT) error 57: Incorrect use of WHILE...
Appendices Error code & Message error 77: Initial string too long error 78: Array symbols exceed 30 for one DIM, GLOBAL, or PRIVATE statement error 79: Record number out of range (1 to 32767) error 80: Label undefined error 81: Must be DATA statement label (in RESTORE statement) error 82: ’(’ missing error 83: ’)’ missing error 84: ’]’ missing error 85: ’,’ missing error 86: ’;’ missing error 87: ’DEF’ missing error 88: ’TO’ missing error 89: ’INPUT’ missing error 90: ’{’ missing error 91: Improper initial
Linking Errors Error Message PRC area size different Out of space in RFG area Out of space in PRD area Cannot open project file Cannot open object file [object name] Cannot open MAP file Cannot open PD3 file [PD3 filename] Cannot close PD3 file [PD3 filename] Write error to PD3 file [PD3 filename] Seek error: Cannot move to the filename position Seek error: Cannot move to the head of the block Filename area too large Symbolname area too large Too many records in symbol table Too many modules Too many librar
Appendices Error Message Non-array integer register variable area overflow Non-array float register variable area overflow Register memory pool area overflow Failed to set up initial setting of register data * To the [Variable type], any of the following character strings applies: • Non-array integer common variable • Non-array float common variable • Non-array string common variable • Non-array integer work variable • Non-array float work variable • Non-array string work variable • Non-array integer regis
Library Errors Error Message Cannot find object to be deleted [objectname] Designated object already existing [objectname] Cannot find object to be updated [objectname] Module already defined [modulename] Filename area too large Too many block information pieces Cannot open library file Seek error: Cannot move to the filename position Seek error: Cannot move to the head of the block NOTE No error code precedes any linking error or library 516
Appendices 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.
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: NOTE 2: ] NOTE 3: NOTE 4: NOTE 5: NOTE 6: You can assign user-defined fonts to codes from 80h to 9Fh with APLOAD state-ment. (Refer to APLOAD statement in Chapter 14.) Characters assigned to codes 20h to 7Fh are default national characters when the English message version is selected on the menu screen* in System Mode.
Appendices C2. National Character Sets You may switch characters assigned to codes 20h to 7Fh of the character set table listed in Appendix C1 to one of the national character sets by using the COUNTRY$ function. The default national character set is America (code A) or Japan (code J) depending upon the English or Japanese message version selected on the menu screen in System Mode, respectively. Listed below are national characters which are different from the defaults.
Appendix D I/O Ports Input Ports A user program can monitor the hardware status through the input ports by using the WAIT statement or INP function. BHT-BASIC defines each of these ports as a byte. The table below lists the input ports and their monitoring function in the BHT. Port No. .
Appendices Port No. .pnWupCtrl 8 Bit assignment 0 Wakeup function 1 Initiation of BHT *5 Monitors the following: .pvWupOn .pvWupTmSt 1 .pvWupTmOn .pvSysOff .pvsysOn 0-255 0 1 0 1 Deactivated Activated Initiated by the power key Initiated by the wakeup function System time selected Wakeup time selected Not set Set OFF ON 0 1 OFF ON 0 Rechargeable battery cartridge Dry cells .pvWupPwOn 2 .pnSysSts .pnBarRrd .pnBtVolt .
Port No. .pnMKey 6040h Bit assignment 0 Magic key 1 1 Magic key 2 2 Magic key 3 3 Magic key 4 Monitors the following: .pnCmPrtcl 6060h 7-0 .pnBHTIDL 6061h 7-0 .pnBHTIDH 6062h 7-0 6080h 0 6090h 0 Communicatio ns protocol *9 ID (lower byte) *10 ID (lower byte) *10 Display font size Beeper 1 Vibrator .pnFont .pnBprVib .pnKeyEnt 60B0h 0 Key entry system .pnKeyMd 60B1h 0 .pnBprVolm 60C0h 1-0 .pnDfrgSzL 60E0h 7-0 .
Appendices .pnRwuCtrl 60F0h Bit assignment 0 .pnRwuSpd 60F1h 2-0 .pnRwuHost 60F2h 0 Port No. 1 60F4h .pnRwuEfT 7-0 Monitors the following: Remote wakeup function *13 Transmission speed for remote wakeup *14 Execution record of remote wakeup *15 Termination of remote wakeup *16 Effective time for remote wakeup *17 .pvRwuOff .pvRwuOn .pvRwu96 .pvRwu192 .pvRwu384 .pvRwu576 .pvRwu1152 0 1 001 010 011 100 101 .pvRwuRgst 1 Woken up remotely .
*8 A user program returns the A/D converted value (0 to 255) of the battery voltage level (0 to 7V). The returned value is an instantaneous value when data on the input port is read. The voltage level varies depending upon the BHT operation and it is not in proportion to the battery capacity, so use this voltage level as a reference value. *9 A user program returns the communications protocol type used for file transmission with the XFILE statement.
Appendices Output Ports A user program can control the hardware through the output ports by using the OUT statement. BHT-BASIC defines each of these ports as a byte. The table below lists the output ports and their controlling function in the BHT. Port No. .pnLEDCtrl 1 Bit assignment 0 1 .pnLCDCnt 3 2-0 .pnMgLng 4 0 .pnSlpTime .
Port No. .pnTmPOff Controls the following: .pnCmPrtcl 6060h 1-0 .pnBHTIDL 6061h 7-0 .pnBHTIDH 6062h 7-0 6080h 0 Effective held-down time of power key *10 Communications protocol *11 ID (lower byte) *12 ID (upper byte) *12 Display font size 6090h 0 Beeper *13 1 Vibrator *13 .pnFont .pnBprVib 6030h Bit assignment 7-0 .pnKeyEnt 60B0h 0 Key entry system .pnKeyMd 60B1h 0 Key entry mode .pnBprVolm 60C0h 1-0 .pnDfrgSzL 60E0h 7-0 .pnDfrgSzH 60E1h 7-0 .
Appendices *1 The indicator LED is controllable only when the bar code device file is closed. If the file is opened, the OUT statement will be ignored. If you have set the indicator LED to OFF in the OPEN "BAR:" statement, then a user program can control the indicator LED although the bar code device file is opened. *2 *3 *4 *5 Lower three bits (bit 2 to bit 0) in this byte control the contrast level of the LCD in 000 to 111 in binary notation or in 0 to 7 in decimal notation.
*11 You can set the communications protocol type for transmitting files with the XFILE statement. *12 You may set the BHT’s ID number to be used for the BHT-Ir protocol. The ID number is expressed by two bytes: lower byte on port 6061h and upper byte on port 6062h. The setting range is from 1 to FFFFh.
Appendices 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 35 30 Shift mode 31 37 36 33 38 34 17 18 19 21 22 23 25 26 27 28 29 1 2 3 4 9 10 11 12 5 6 7 8 13 14 15 16 24 20 Default Data Assignment The default data assignment is shown below. Non-shift mode Shift mode TRG TRG TRG TRG 7 8 9 Q R S 4 5 6 U V W 1 2 3 Y Z + CR - , 0 .
Appendix F Memory Area Memory Map The memory maps are shown below. ROM 4MB, RAM 512KB Type System work area (512KB) RAM System program area (1536KB) Font area JIS Level 1 font,16-dot (120 KB) JIS Level 2 font,16-dot (112 KB) JIS Level 1 font,12-dot (88 KB) JIS Level 2 font,12-dot (84 KB) This area may be used as a user area if you delete these fonts.
Appendices ROM 8MB, RAM 512KB Type (except BHT8048DB) System work area (512KB) RAM System program area (1728KB) Font area JIS Level 1 font,16-dot (120 KB) JIS Level 2 font,16-dot (112 KB) JIS Level 1 font,12-dot (88 KB) JIS Level 2 font,12-dot (84 KB) This area may be used as a user area if you delete these fonts.
Memory Management The BHT manages the user area of the memory for user programs and data files by a unit of segment called "cluster." The cluster size is usually 4 kilobytes. The maximum allowable size for a single user program is 64 kilobytes excluding register variables. Battery Backup of Memory The BHT backs up the memory with a battery cartridge. Therefore, data stored in the memory will not be lost if the BHT power is turned off.
Appendices Appendix G Handling Space Characters in Downloading Space characters used as padding characters A data file can be downloaded with System Mode or an XFILE statement according to the communications protocol which is designed to eliminate trailing spaces padded in the tail of each data field. The BHT has a new feature which can handle trailing spaces in a data field as data. The figure below shows the process in which the spaces used as padding characters are eliminated.
To handle space characters as data To handle trailing spaces in a data field as data (not as padding characters), you must take special considerations in programming. If you want to search for a field data containing spaces in its tail by using a SEARCH function, for instance, use any of the following methods: After downloading a data file, fill the unused spaces in each field with spaces and then search for the target field data.
Appendices Example 3 When specifying a field data to be searched, do not include trailing spaces in a data field. A B C A B C Receive data Data to be searched ] C ] A B Send data ] C ] A B Search data to be specified denotes a space character.
To make the BHT handle space characters as data You can specify the handling of trailing spaces in a data field with System Mode or an XFILE statement. System Mode: To handle trailing spaces as data, select "Data" in FIELD SPACE item on the SET PROTOCOL screen of the SET SYSTEM menu. XFILE statement: To handle trailing spaces as data, specify T to "protocolspec" in the XFILE statement. XFILE "d2.
Appendices Appendix H Programming Notes Program file named APLINT.PD3 If a program file named APLINT.PD3 is stored in the BHT, the System Mode initiation sequence (by pressing the PW key with the SF and 1 keys held down) will not start System Mode but execute that user program. Making a program file named APLINT.PD3 allows you to: - enter an ID number at the start of System Mode and - set the condensed System Mode which is used for maintenance of user programs. To terminate the APLINT.
Appendix I Program Samples Writing the function for receiving both bar code entry and key entry Feature: This function receives earlier one of either bar code entry or key entry. If bar code reading is completed, the function returns the scanned bar code data; if key entry comes first, the function inhibits bar code reading and echoes back the key entry data, then returns the key entry data when the ENT key is pressed.
Appendices .kb$ = input$(1) while .kb$<>"" if instr(esc$, .kb$) then'Key designated in esc$? fnbarkey$ = .kb$ 'Then, return the character. exit def endif select .kb$ case chr$(13) fnbarkey$ = .rt$ exit def case chr$(8) 'BS key. if len(.rt$) then print chr$(8);'Erase one character. .rt$ = left$(.rt$, len(.rt$)-1) endif case chr$(24)'Clear key. while len(.rt$)'Erase all characters entered. print chr$(8); .rt$ = left$(.rt$, len(.rt$)-1) wend case else if len(.
Testing the written function while 1 'Infinite loop a$ = fnbarkey$ (1, "A", 15, "DL")'F4 and SFT/F4 as escape characters.
Appendices Appendix J Quick Reference for Statements and Functi Functions ons Controlling program flow Statements CALL Calls an FN3 or SUB function. CHAIN Transfers control to another program. END Terminates program execution. FOR...NEXT GOSUB Defines a loop containing statements to be executed a specified number of times. Branches to a subroutine. GOTO Branches to a specified label. IF...THEN...ELSE...E ND IF Conditionally executes specified depending upon the evaluation expression. ON...
Handling errors Statements ON ERROR GOTO Enables error trapping. RESUME Causes program execution to resume at a specified location after control is transferred to an error-handling routine. Functions ERL ERR Returns the current statement location of the program where a run-time error occurred. Returns the error code of the most recent run-time error. Defining and allocating variables Statements COMMON CONST Declares common variables for sharing between user programs.
Appendices Controlling the LCD screen Statements APLOAD Loads a user-defined font in the single-byte ANK mode. CLS Clears the LCD screen. CURSOR Turns the cursor on or off. KEY PRINT 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 battery voltage display key. Loads a user-defined Kanji font in the two-byte Kanji mode.
Controlling the keyboard input Statements INPUT KEY Reads input from the keyboard into a variable. KEY ON 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 battery voltage display key. Enables keystroke trapping for a specified function key. KEY OFF Disables keystroke trapping for a specified function key.
Appendices Communicating with I/Os Statements OUT Sends a data byte to an output port. POWER Controls the automatic power-off facility. WAIT Pauses program execution until a designated input port presents a given bit pattern. Functions FRE INP Returns the number of bytes available in a speci-fied area of the memory. Returns a byte read from a specified input port. Communicating with the barcode device Statements CLOSE Closes file(s).
Manipulating data files and user program files Statements CLFILE Erases the data stored in a data file. CLOSE Closes file(s). FIELD Allocates string variables as field variables. GET Reads a record from a data file. KILL Deletes a specified file from the memory. OPEN Opens a data file for I/O activities. PUT Writes a record from a field variable to a data file. Functions LOC Returns the current position within a specified file. LOF Returns the length of a specified file.
Appendices Functions BCC$ EOF Returns a block check character (BCC) of a data block. LOC Tests whether the end of a device I/O file has been reached. Modifies the value of a terminator (ETX) for the BHT-protocol; also returns the current value of a terminator. Returns a specified number of characters read from the keyboard or from a device file. Returns the current position within a specified file. LOF Returns the length of a specified file.
Manipulating string data Functions ASC CHR$ HEX$ INSTR LEFT$ LEN MID$ Returns the ASCII code value of a given character. Returns the character corresponding to a given ASCII code. Converts a decimal number into the equivalent hexadecimal string. Searches a specified target string for a specified search string, and then returns the position where the search string is found. Returns the specified number of leftmost characters from a given string expression.
Appendices Appendix K Unsupported Statements and Functions BHT-BASIC does not support the following MS-BASIC statements and functions: - For handling sequential data files CVD CVI CVS LSET - For RS-232C interface operation PRINT #USING WRITE # - For interrupt handling COM OFF COM ON COM STOP ON STCOM GOSUB - For graphics and color control CIRCLE COLOR CONSOLE CSRLIN - For I/O control DEFUSR PEEK MKD$ MKI$ MKS$ PRINT # ON STOP GOSUB STOP OFF STOP ON DRAW LINE POINT PSET WIDTH WINDOW POKE VARPTR - For
Supplement CONTENTS Supplement A What's different from the BHT-5000?............................................. 551 A.1 Communication.......................................................................................... 551 A.2 Bar code reading ....................................................................................... 552 A.3 Screen display ........................................................................................... 553 A.4 Keyboard .........................................
Supplement Suuplement A What's different from the BHTBHT-5000? A.
• Switching time between sending and receiving on the IrDA interface For IrDA communication with the BHT-8000, the IrDA interface should satisfy the following requirements in switching between sending and receiving: a) Within 10 ms from completion of sending, the IrDA interface should become ready to receive. b) After 10 ms or more from completion of receiving, the IrDA interface should start sending.
Supplement A.
A.4 Keyboard Item BHT-5000 1 Magic keys * M1 and M2 keys Default trigger switch Dedicated trigger switch Key number assignment range 1 to 34 Available in models only 2 Alphabet entry * BHT-8000 M1, M2, M3, and M4 keys M3 (left-hand) and M4 (right-hand) keys 1 to 31 and 33 to 38 (32 ignored) 32-keypad Available (Alphabet entry mode added) 1 For definition of magic keys, refer to the KEY statement in Chapter 14 "Statement Reference.
Supplement A.6 Files Item File device(s) BHT-5000 storage RAM (Drive A) Flash ROM (Drive B) Max. number files loadable Cluster size BHT-8000 Flash ROM (The RAM is used to run programs efficiently.
A.8 A.8 Beeper & vibrator control Item BHT-5000 Beeper volume adjustment in user programs Not available Beeper and vibrator switching & control in user Not available programs Drive the vibrator with BEEP statement Not available BHT-8000 Available Available Available Low:1015 Hz Frequencies by the special beeper effects in Medium:2042 Hz BEEP statement High:4200 Hz Low: 698 Hz Medium:1396 Hz High:2793 Hz Frequency range that drives no beeper in BEEP 3 to 260 Hz statement 3 to 61 Hz A.
Supplement Supplement B What's different from the BHTBHT-6000? B.1 Communication Item BHT-6000 Receive file with File transmission the name given by Not possible with XFILE the sender statement Receive file with Not possible different name Specify the output pulse width of IR beam * Possible BHT-8000 Possible Possible Not possible * Ignored if specified by the OUT statement. B.
B.
Supplement B.4 Keyboard Item 1 BHT-6000 Magic keys * M1 and M2 keys Default trigger switch M1 and M2 keys Key number assignment range 1 to 31, 33, and 34 2 Alphabet entry * BHT-8000 M1, M2, M3, and M4 keys M3 (left-hand) and M4 (right-hand) keys 1 to 31 and 33 to 38 (32 ignored) Available (entry procedure Available (entry procedure exclusively designed) exclusively designed) 1 For definition of magic keys, refer to the KEY statement in Chapter 14 "Statement Reference.
B.6 Files Item File device(s) BHT-6000 storage RAM (Drive A) Flash ROM (Drive B) Max. number files loadable Cluster size User area Defragment drive BHT-8000 Flash ROM (The RAM is used to run programs efficiently.) of RAM (Drive A): 40 Flash ROM (Drive B): 40 4 KB 8 KB (BHT-6049 only) RAM (Drive A) 468 KB Flash memory (Drive B) 64 KB (BHT-6045) 568 KB (BHT-6047) 1584 KB (BHT-6049) (If font files are deleted) 320 KB (BHT-6045) 828 KB (BHT-6047) 1840 KB (BHT-6049) the 80 4 KB Max.
Supplement B.8 Beeper & vibrator control Item BHT-6000 Beeper volume adjustment in user programs Not available Beeper and vibrator switching & control in user Not available programs BHT-8000 Available Drive the vibrator with BEEP statement Available Not available Low: Frequencies by the special beeper effects in Medium: BEEP statement High: Available 1033 Hz Low: 2168 Hz Medium: 4337 Hz High: 698 Hz 1396 Hz 2793 Hz B.9 Extended functions and extension library Item BHT-6000 BHT-8000 SYSTEM.
Supplement C What's different from the BHTBHT-7000? C.1 Files Item Drive defragmentation will be initiated: BHT-7000 BHT-8000 - Specified by the user in the OUT statement. Specified by the user in the OUT statement. - When updating or adding files is performed with insufficient free space of the user area. - When updating or adding files is performed with insufficient free space of the user area. When the auto power-off function turns off the BHT.
Supplement C.3 Monitor the CU state Item Get the CU state BHT-7000 BHT-8000 Can get the following three Can get the following state only: states: CU without BHT CU with BHT placed - CU without BHT - CU loaded with dry battery cartridge C.4 Scanning range marker Item BHT-7000 Scanning range marker Possible control in user programs BHT-8000 Not possible (No scanning range marker is provided.) C.
C.7 Remote wakeup Item BHT-7000 When the rechargeable Available battery cartridge is loaded BHT-8000 Available When the dry cells are loaded Not available Available Effective period in which the When the BHT is placed on Within the specified period BHT is ready to receive the CU after turned off.
Index array register variable, 186 _ _(underline, underscore), 433, 436 1 array string type, 34 array string variable, 16, 65, 156, 170, 190, 192, 225, 358 arraystringvariable, 185, 186 ASCII code, 250, 302, 309, 518, 548 12-dot font, 87 auto-off mode, 136, 243, 245 16-dot font, 87 auto-repeat, 106 A ACK, 143, 144, 309 B backlight, iii, 136, 140, 150, 151, 214, address-source list, 30, 33, 36, 39, 317 215, 216, 217, 218, 527, 543, 544, alternate switching mode, 136, 243, 554, 559 245 AND, iv, 5
BEEP, 85, 107, 129, 152, 157, 158, 159, 517, 544, 556, 561, 563 447, 448, 450, 451, 452, 453, 456, 457, 459, 461, 463, 464, 466, 467, beeper, ii, iii, 107, 121, 136, 140, 157, 468, 469, 470, 471, 474, 475, 477, 158, 191, 242, 245, 249, 524, 528, 478, 479, 480, 481, 483, 486, 489, 544, 545, 556, 561, 563 491, 493, 494, 495, 499, 500, 503, BHT-BASIC, i, ii, iii, iv, v, 1, 3, 4, 5, 6, 508 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, Bluetooth Communications, 444 19, 29, 32, 33, 37, 38, 39, 40, 41, 43,
170, 171, 223, 312, 517, 541 chained, 50, 67, 147, 153, 154, 164, 170, 223, 312 170, 192, 193, 299, 510, 512, 515, 532, 542, 550, 555, 560 communications device, 111, 136, 212, chaining, ii, 50 230, 240, 241, 243, 251, 252, 253, charaattribute, 88, 169, 280, 281 255, 258, 262, 263, 295, 309, 324, character attribute, 88, 260, 280, 543 331, 333, 361, 362, 369, 372, 373, character code, 84, 126, 153, 154, 215, 374, 375, 385, 416, 447, 452, 464, 222, 302, 303, 322 character enlargement, 173, 210, 229
counter, 216, 258, 259 declarative statement, 50, 54, 175 country code, 246, 311, 312, 543 DECLARE, 6, 7, 48, 72, 75, 152, 162, countrycode, 311, 312, 519 CRC-16, 303, 358 163, 175, 176, 199, 200, 287, 542 DEF FN, 47, 48, 57, 60, 68, 83, 152, cross reference, 5, 30, 39, 51, 297, 509 176, 177, 178, 179, 180, 181, 182, CU, v, vi, 11, 122, 126, 142, 144, 416, 183, 184, 196, 198, 205, 206, 207, 550, 551, 556, 561, 563, 564 cursor, 89, 94, 95, 97, 103, 153, 154, 208, 236, 238, 283, 285, 290, 505, 512,
469, 472, 476, 523 directories, 27 ERASE, 67, 152, 154, 190, 192, 223, 517, 542 directory, 27, 37, 41, 43, 114, 115, 166, error trapping, 79, 128, 131, 235, 542 220, 376, 385, 424, 426, 430, 431, error-/event-handling routine, 47 432, 436, 438, 440 error-handling routine, 47, 128, 131, directory, directories, 376, 385, 424, 132, 176, 178, 182, 198, 235, 277, 425, 426, 430, 431, 432, 436, 438, 278, 285, 317, 318, 372, 375, 542 440 ERRORLEVEL, 10, 29, 40 double-touch reading, 118 Ethernet, 370
FD_ISSET, 387, 405 FTP, iii, 349, 359, 360, 361, 366, 372, FD_SET, 387, 403 376, 377, 378, 380, 381, 382, 383, FD_ZERO, 387, 403 384, 385, 424, 425, 427, 428, 429, field, 113, 115, 124, 193, 194, 201, 266, 430, 431, 432, 433, 434, 435, 436, 271, 292, 293, 295, 339, 353, 380, 437, 438, 439, 440, 441, 442, 448, 385, 432, 433, 435, 506, 533, 534, 507 535, 536, 546 FTP client, iii, 349, 361, 376, 377, 378, FIELD, 55, 58, 113, 114, 115, 152, 167, 380, 381, 382, 383, 384, 385, 424, 193, 194, 201,
239, 275, 279, 505, 517, 541, 549 209, 210, 211, 212, 213, 215, 218, GOTO, 16, 47, 49, 53, 129, 152, 205, 228, 229, 230, 231, 300, 316, 322, 206, 208, 236, 237, 275, 374, 517, 324, 325, 333, 451, 461, 462, 466, 541, 549 467, 478, 480, 513, 517, 544, 545, 546, 547 H header, 32, 124, 296, 341, 343, 506, 547 INPUT #, 152, 212, 213, 230, 231, 466, 478, 545, 546 input port, 101, 254, 288, 323, 520, 523, 524, 545 heading text, 341 HOLD mode, 464, 465, 498 htonl, 387, 394 integer constant, 63, 160, 175,
239, 279, 322, 517, 527, 543, 544, 234, 260, 261, 296, 313, 322, 324, 554, 559, 562 325, 337, 517, 543, 553, 558 KEY OFF, 152, 217, 218, 238, 239, 322, 544 logical operation, 70, 81 logical operator, 69, 81 KEY ON, 133, 152, 217, 218, 238, 239, LSB, 100, 155 322, 544 M keyboard buffer, 109, 215 keystroke trapping, 133, 134, 218, 238, 322, 324, 544 KILL, 115, 117, 152, 220, 221, 517, 546 KPLOAD, 94, 98, 103, 152, 156, 164, 165, 173, 222, 223, 225, 226, 517, 543, 553, 558 M1 key, 150, 216, 217, 351,
Multi-statements, 54 N O object program, v, 3, 5, 6, 13, 14, 18, 31, 33, 41, 50, 164 national character, 103, 311, 312, 518, 519, 543 non-array integer variable, 66, 170, 175, 177, 197, 284 non-array real variable, 66, 170, 175, 177, 197, 284 non-array register variable, 67 non-array string variable, 16, 65, 66, 170, 175, 177, 190, 192, 193, 197, 284, 339, 358 non-arraystringvariable, 185, 186 NOT, 69, 70, 76, 78, 81, 129, 517 ntohl, 387, 395 ntohs, 387, 395 null character, 67 null character string, 67 n
461, 517 261, 264, 265, 266, 267, 543, 549 OUT, 6, 85, 87, 96, 97, 99, 100, 101, 102, 104, 105, 108, 116, 121, 125, 136, 146, 150, 151, 152, 158, 245, PRINT#, 15, 55, 116, 517 PRIVATE, 6, 7, 71, 72, 73, 152, 198, 204, 268, 269, 285, 513, 542 256, 257, 281, 289, 323, 345, 383, profile, 444, 472, 473, 476 385, 517, 525, 527, 528, 545, 553, program file, 43, 72, 73, 296, 320, 376, 557, 562 377, 378, 384, 433, 435, 437, 506, output port, 121, 256, 525, 527, 545 537 program file name, 537 P parity, 1
register variable, 6, 7, 30, 34, 35, 36, 39, 67, 71, 136, 138, 185, 186, 187, 192, 193, 203, 268, 299, 510, 512, 515, 532, 542 337, 517, 543 screen mode, 87, 89, 173, 210, 229, 280, 324, 337, 543 secondary station, 124, 125 Relational operations, 78 relational operator, 80, 81 REM, 16, 32, 51, 54, 152, 174, 275, 297, 517, 547, 548 security mode, 451, 455, 473, 476, 477, 482, 497 SELECT...CASE...
440, 441, 442, 456, 457, 507 227, 228, 229, 230, 231, 240, 242, socket API, 367, 369, 387, 388, 389, 260, 262, 264, 265, 266, 271, 273, 390, 392, 394, 395, 396, 400, 402, 274, 282, 284, 286, 287, 302, 303, 403, 405, 406, 408, 410, 412, 413, 305, 306, 307, 308, 309, 311, 314, 415 319, 320, 321, 322, 324, 326, 327, socket application program interface, 329, 330, 334, 335, 338, 339, 341, iii, 349, 361, 367 342, 343, 344, 347, 350, 354, 355, socket library, 364 386, 396, 400, 406, 408, 421, 424,
286, 548 254, 294, 295, 296, 353, 402, 423, subnet mask, 363 449, 450, 451, 452, 455, 456, 458, Subnet mask, 363, 365, 386, 418, 421 459, 461, 471, 473, 475, 476, 482, subroutine, 47, 205, 206, 279, 541 501, 506, 524, 528 subscript, 57, 65, 66, 185, 187, 189, 190, 203, 204, 268, 269, 505 SUM, 303 timer, ii, 107, 136, 148, 346, 369, 392, 410, 423, 461, 525, 527, 544 Transfer Utility, vi, 10, 12, 13, 14, 44, supplemental code, 246 symbol table, 14, 30, 39, 514 System Mode, 3, 45, 50, 106, 124, 125,
447, 449, 450, 452, 455, 458, 460, 461, 463, 464, 479, 487, 492, 494, VRAM, vi, 85, 99, 101, 102, 169, 521, 523, 525, 527, 558 496, 520, 523, 524, 525, 527, 532, W 537, 542, 546, 556, 561, 563 user-defined font, 98, 153, 154, 223, 518, 543, 553, 558 user-defined function, 6, 7, 31, 33, 34, 36, 48, 57, 68, 77, 131, 162, 163, 175, 176, 177, 178, 179, 181, 182, 183, 184, 197, 198, 199, 200, 284, 285, 286, 297, 320, 542, 548 V variable, iv, v, 7, 30, 31, 33, 34, 35, 50, 57, 61, 65, 66, 67, 69, 70, 71, 72, 7
BHT-BASIC (BHT-8000 series) Programmer’s Manual 3rd Edition, June 2003 DENSO WAVE INCORPORATED The purpose of this manual is to provide accurate information in the development of application programs in BHT-BASIC. Please feel free to send your comments regarding any errors or omissions you may have found, or any suggestions you may have for generally improving the manual.