Tech Note 27: Using Symbol Devices

February 27, 2007

Copyright 2007 NS BASIC Corporation

NS Basic/CE works well on devices made by Symbol that are running Windows CE 4.2 or later. If you have an older device, check with Symbol: it may be possible to upgrade it to Windows CE 4.2.

The following code sample shows how to call the Symbol scanner API from a NS Basic application. The pre-requisite for this to work is the Symbol ActiveX installer file which is included in the SMDK v1.0 for the Web . At the time of writing (March 2006) this file is located in the Symbol Developer Zone at http://devzone.symbol.com/content.cfm?item_id=001D9487-052E-4C41-A43AF86CD0C419C0. Note that registration is required for access to this site.

Once the SMDK is installed on a development PC, the required ActiveX support is located in the file Symbol.AXO.all.cab located by default in C:\Program Files\Symbol Mobility Developer Kit for the Web\v1.0\Cabs. Once this CAB is installed, the following NSB application code can be used:

Complete documentation on the Symbol control can be found in the SMDK v1.0.

'Symbol.nsb extract: 
'Complete program is in \Program Files\nbasic\ce\samples.

' NSB Sample application showing how to call Symbol scanner API
' N.B requires that SymbolAXO.arm.cab Is preinstalled on target device 

' add barcode scanner object to form

Execute "AddObject " & Chr(34) & "symbol.barcodereader.1" & Chr(34) & ", " & Chr(34) & "ScanControl1" & Chr(34) & ", 16, 240, 1, 8, Form1_Form"

Sub Form1_Load

' open scanner API
   ScanControl1.OpenScanner
' enable scanning - will allow scanner to be activated by hardware triggers on device
   ScanControl1.EnableScanning True 
End Sub

' this event will fire each time the scanner API decodes a label

Sub ScanControl1_ScanComplete(byval bstrBarCode , ByVal bstrSource , ByVal lStatus , ByVal lLabelType, ByVal lDataLength )
  ' get barcode data
  TextBox1.Text = bstrBarCode
  ' get barcode symbology
  TextBox2.Text = bStrSource
End Sub
This shows very simply how to call the scanner API from NSB . It should work with both laser scanners and imagers from Symbol and can run on either CE or Windows Mobile OS versions. More advanced functionality such as enabling and disabling specific symbologies and setting length checks for the barcodes has not been tested but should work provided the syntax is correct.

If certain devices, such as the MC1000, lose power they will cold boot and reset the registry. There is a facility to merge registry keys on a boot which will restore modified keys but an easier solution is to reinstall the NS Basic CAB file by autorunning it on startup e.g if the cab is located in the \Application folder, you can place a RUN file in \Application\Startup containing the following 2 lines:

\windows\wceload.exe
\application\nsb.cab
This will reinstall NSB following a cold boot.

The above code is provided as is with no warranties expressed or implied and is not supported directly by Symbol Technologies i.e. use at your own risk.