Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 18 of 37

JANUS PSK for Basic, Version 2.1 Reference Manual, pages 171 to 180

Pages 171 to 180 of 362

The original document is the PDF (601 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Intermec J2020, Intermec J2010 and Intermec J2050

Page 171

Visual Basic Library

3

Setting Timeout Values Many of the Visual Basic functions pass a Timeout parameter. In each case, Timeout is an integer and must be less than 32,768. Your application may require larger values up to the maximum of 65,536. To use a timeout value greater than 32,767 1. Convert the number to a negative number (nnnnn - 65536) and declare a constant for this negative value. CONST im40000 = 40000 - 65536 2. Use the constant in the parameter list. The result is passed correctly to the function in IM20_BAS.LIB. status% = imStandbyWait(im40000)

Handling Bar Code Scanner Input When the JANUS reader operates in Wedge mode (the default mode), data from the scanner is placed in the keyboard buffer. However, a Visual Basic form waits for a keyboard event before checking the keyboard buffer for data. Scanned data remains in the buffer until a key is pressed or until another event triggers Visual Basic to inspect the keyboard buffer. Additionally, if your form has more than one control, your application can simulate pressing Tab to move to the next control in the form.

Simulating Pressing a Key One method of getting past the key press limitation is to put a timer in the form and set the time interval to 100 ms. In Example 1 below, the sample timer routine toggles the Num Lock key twice. Visual Basic interprets the toggle as a key press and retrieves the scanned data from the keyboard buffer. In the timer routine, there are two tests to determine if there is data in the keyboard buffer. First, the keyboard buffer status is checked by calling INTERRUPT &H16. If there is data in the keyboard buffer, the output register flag Z is not set. The sample segment performs a logical AND with the register flags to test for data. If data is present, then outregs.flags does not contain 40H and the result is zero (0).

3-5

Page 172

JANUS PSK for Basic Reference Manual

Next, the program checks to see if the focus is a text box. If it is, then the Num Lock key is toggled twice.

Example 1: Checking for Scanned Input and Power Management SUB Timer1_Timer () ’* Checking for Scanned Input and Power Management ’* This subroutine checks the keyboard buffer status to activate power management ’* and to check for scanned data. The Power Management software requires checking ’* the status 4 times. ’* If there is data in keyboard buffer, check to see if a text box has focus. inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs

’Check extended keyboard status register inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs

’Check ext keyboard status register inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs

’Check ext keyboard status register inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs

’Check ext keyboard status register charAvailable% = outregs.flags AND &H40

’Bitwise AND checks Status in Z flag

’set = no key press or no data in buffer IF charAvailable% = 0 THEN

’If data present, is focus on text box?

IF TYPEOF SCREEN.ActiveControl IS TextBox THEN DEF SEG = 0

’Set segment to low memory

POKE &H417, PEEK(&H417) XOR &H20

’Toggle Num Lock active

DEF SEG

’Restore segment inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs

’Check extended keyboard status

DEF SEG = 0

’Set segment to low memory

POKE &H417, PEEK(&H417) XOR &H20

’Restore Num Lock to what it was

DEF SEG

’Restore segment inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs END IF ENDIF END SUB

3-6

’Check ext keyboard status

Page 173

Visual Basic Library

3

The next sample program demonstrates how to move the focus from the active text box to another text box when a carriage return is scanned or when the Enter key is pressed. If any other data is scanned or another key is pressed, the data is changed to all uppercase.

Example 2: Moving to the Next Text Box After Receiving a Carriage Return SUB txtText1_KeyPress (KeyAscii) IF KeyAscii = 13 THEN txtText2.SETFOCUS ELSE C$ = CHR$(KeyAscii) KeyAscii = ASC(UCASE$(C$)) END IF END SUB

’Convert ASCII keycode to character ’Convert character to uppercase

Simulating Pressing the Tab Key Visual Basic moves the focus from one control to the next when the Tab key is pressed. When you are scanning bar code labels, you can configure the reader to add a Tab character <HT> to the end of the data to automatically move to the next control. You must also configure the reader to send the correct key code for <HT>. By default, the reader interprets the <HT> character as Ctrl-I (1709 hex), but Visual Basic requires 0F09 hex for the Tab key. Use this method and the timer routine from “Simulating Pressing a Key” to use the scanner with your Visual Basic applications. To configure the postamble 1. Use the Postamble configuration command (AE) to set the postamble to a single horizontal tab character <HT>. For more information, see your JANUS user’s manual. 2. Modify the keycode lookup table entry for the horizontal tab <HT>.

3-7

Page 174

JANUS PSK for Basic Reference Manual

To temporarily change the Tab keycode • Use the Key Code Look-Up Table configuration command (WM) to change the keycode lookup table. Set the <HT> key to 0F09 hex. This change is temporary. Rebooting the reader resets the look-up table to the default settings. For more information, see your JANUS user’s manual.

To change the Tab keycode and save the setting 1. Use IC.EXE to set the keycode for the horizontal tab <HT>. 2. From the Op menu, select Key Codes. 3. Select Redefine. 4. For the character to redefine, press Ctrl-I. The code <HT> is displayed. 5. For the new key code, type 0f09. The “f” can be uppercase or lowercase. 6. Press Enter. 7. Save the configuration and exit Configuration Manager. For more information, see your JANUS user’s manual.

Providing Power Management Support The JANUS reader power management software monitors keypad activity to determine if the reader can be put into suspend mode. If it detects that the keyboard buffer is being polled on a regular basis, and no other activity is detected, it assumes that the reader is inactive. If the inactive state continues for longer than the configured setting, then the power management software turns off the reader to preserve battery life. The default Configuration Management setting is 1 minute. Because Visual Basic is event-driven, the keyboard buffer is not automatically monitored. The power management software never detects the inactive state, and the reader never shuts off. Your program must check the keyboard buffer status four times to simulate keyboard monitoring. The timer subroutine that follows checks the keyboard buffer status four times. If the keyboard buffer status changes, then the power management software does nothing. If there is no change for the fourth check, then the power management software knows that the reader is inactive.

3-8

Page 175

Visual Basic Library

3

Example 3: Checking Keyboard Status for Power Management SUB Timer1_Timer () ’* This subroutine checks the keyboard buffer status to activate power management ’* and to check for scanned data. The Power Management software requires checking ’* the status 4 times. If there is data in keyboard buffer, process it. inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs,

’Check extended keyboard status register inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs,

’Check extended keyboard status register inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs,

’Check extended keyboard status register inregs.ax = &H1100 INTERRUPT &H16, inregs, outregs,

’Check extended keyboard status register charAvailable% = outregs.flags AND &H40

’Bitwise AND to check Status in Z flag ’set = no key press or no data in buffer

IF charAvailable% = 0 THEN

’If data present, do something

’* ’* Insert your code here. ’* See previous example "Checking for Scanned Input and Power Management" ’* ENDIF END SUB

3-9

Page 176

JANUS PSK for Basic Reference Manual

Building a Program Using Microsoft Visual Basic This section shows you how to write, compile, and link a Visual Basic for DOS program that uses the Visual Basic library functions you installed from the PSK disk. Keep the following tips in mind when you build your Visual Basic programs: • Visual Basic cannot compile and link with external libraries. You must compile and link your program from the DOS command line. • Refer to your Visual Basic user’s guide for information on using BC.EXE and LINK.EXE. • Both C and Visual Basic use the BC.EXE and LINK.EXE commands. If you have C and Visual Basic installed and want to compile and link from the command line, run these commands from the Visual Basic directory or make sure that your Visual Basic directory comes before your C directory in your path. • You must build a standalone executable program. In the following procedure, progname is the name of your program file without an extension. In a short program, your source file (progname.BAS), object file (progname.OBJ), and executable file (progname.EXE) all have the same filename. Most Visual Basic applications use several types of source files: progname.BAS, progname.FRM, progname.BI, progname.MAK, and progname.TXT. Your application may have more than one file of a particular type. For more information, refer to your Visual Basic manual.

3-10

Page 177

3

Visual Basic Library

To build your program using Visual Basic for DOS 1. Start Visual Basic from DOS with the library (/l) switch: vbdos /l 2. Create and edit your program. 3. Exit Visual Basic. 4. At the DOS prompt, change to the directory containing your program source files. 5. Compile each *.BAS and *.FRM module from DOS, one at a time: BC /T /O /C:512 progname.BAS, progname, NUL.LST where: /T /O builds a standalone object file.

/C:512 sets the buffer size for receiving remote data. The maximum size is 32,767 bytes.

progname is your program or module name and the name for the object file, *.OBJ.

6. Create a response file, progname.RSP, for linking. The response file consists of the following four lines: prognam1.OBJ prognam2.OBJ prognam3.OBJ progname (a blank line) C:\INTERMEC\VBDOS\LIB\IM20_BAS.LIB C:\VBDOS\VBDCL10.LIB C:\VBDOS\VBDOS.LIB

+ where: the first line lists all the object files from Step 5 and the im20bas.obj file, including their path. the second line lists only the executable filename with no extension. the third line is left blank. the fourth line lists the library files, including their paths. If any line has more than 255 characters, type a + (plus) to indicate a continuation and continue typing paths and filenames on the next line.

3-11

Page 178

JANUS PSK for Basic Reference Manual

7. Link the program from the DOS prompt using the response file: LINK /NOE @progname.rsp where:

/NOE searches the object files for public symbols that may be redefined in your program.

8. Copy your program, progname.EXE, to your JANUS reader and run the program.

Handling a Linker Error Message You may get a linker error message when you link the Visual Basic program. If you receive the following error message, your program has more segments than the default (128): fatal error L1049:

too many segments

You need to increase the number of segments and link again. To set the number of segments • Enter the following command from the DOS prompt: LINK /SEG:nnn /NOE @progname.RSP where:

3-12 nnn is a number between 1 and 16,375.

Page 179

Visual Basic Library

3

Debugging With JANUS Application Simulator The JANUS Application Simulator is a terminate-and-stay resident (TSR) program that you use to run JANUS applications on a PC. Without the Simulator, you cannot run JANUS applications on your PC. Whenever you start a program that uses PSK library functions, the program checks for a JANUS reader and for the JANUS Simulator. If you attempt to run a JANUS program on a PC without the Simulator, you get an error message. The Simulator captures the JANUS functions and interrupts to make the PC mimic a JANUS reader. For more information on the Simulator, refer to the JANUS Application Simulator User’s Manual, Part No. 062778. To debug a JANUS application with the Simulator 1. Start the Simulator from the DOS prompt by entering this command: janussim 2. Start Visual Basic. 3. Follow the debugging instructions provided with Visual Basic.

3-13

Page 180

JANUS PSK for Basic Reference Manual

Runtime Requirements For some library functions to work properly, you must install and run specific software components at program execution time. For example, if the reader is using a communications port and you want to use Intermec protocols, you must load a protocol handler. Because protocol handlers use a lot of memory, they are not automatically loaded for you. Other functions require the Reader Wedge.

Protocol Handlers You use the Intermec protocol handler (PHIMEC.EXE) when the reader is connected with other Intermec devices. PHIMEC.EXE works with UserDefined, Point-to-Point, Polling Mode D, and Multi-Drop protocols. You use the PC standard protocol handler (PHPCSTD.EXE) when the reader is connected to devices that use PC standard protocol. PHPCSTD.EXE provides low-level communication abilities and protocol services at the DOS level for non-communication software. It also provides byte-by-byte transfer. If your reader is a radio frequency (RF) unit, RFPH.EXE is automatically loaded. For more information on protocol handlers, refer to your JANUS user’s manual. To install a protocol handler on the reader • From the DOS prompt, enter the following command:

handler n where: handler is either PHIMEC or PHPCSTD. n is the number of the communications port. When your application is finished, the protocol handler TSR continues to run and can prevent other applications from running due to lack of memory. You can unload the protocol handler TSR by adding the unload command as the last line of the batch file that launches your application.

3-14