FieldSoftware
Home

PrinterCE SDK
   General Info
   Download
   Purchase & Pricing

Developer Info
   eVC MFC
   eVC C/C++
   eVB

Special Features
   AsciiCE
   PrintDC
   BarcodeCE

Documentation
   PrinterCE SDK
   AsciiCE
   PrintDC
   BarcodeCE

Special Topics
  Supported Printers
  Bluetooth Printing
  Network Printing

.Net CF C# or VB.Net:
  PrinterCE.NetCF SDK

-----------------------------

Software Developers
  PrinterCE SDK
 
PrinterCE.NetCF SDK
  PocketHTMLprint SDK

Printing Utilities
  SmartPhonePrint
  PrintPocketCE
  PIEprint
  PocketPixPrint
  PocketShot
 
PocketClipPrint

 Arcade Games
  SockOut
  MazeCraze

Contact Info

AsciiCE2 Developer's Guide
Library Name : AsciiCE2
DLL Name : PrEngineCE.dll
Control Name: PrEngineCE.AsciiCE2  

Download Word Doc copy of this Developer's Guide

The AsciiCE2 control is included with PrinterCE SDK and provides for sending and receiving ASCII text strings and blocks of data or control functions between printers and Windows CE / Pocket PC devices. When used with certain printers that also feature magnetic card readers or smart card readers, the AsciiCE2 control provides methods to read the data from those readers.

AsciiCE2 provides basic high-speed text output to ASCII printers, direct printer control and reading data sent from the printer, but loses the sophisticated graphics, TrueType font, object drawing and barcode printing capabilities of PrinterCE. AsciiCE2 and PrinterCE can be used simultaneously to a limited degree. AsciiCE2 functions can be accessed from eVB, MFC/CE and C++.

Note: AsciiCE2 extends PrinterCE's  original AsciiCE control. AsciiCE will continue to be found in PrinterCE unchanged, so all existing applications using AsciiCE will work as before. However AsciiCE2 provides every method and property of AsciiCE plus many more.

AsciiCE2 Information and Code Samples

Important Note for MFC Developers:: There is a known bug in MFC when inserting components using the Components and Controls Gallery that causes incorrect "wrapper classes" to be generated for methods that pass BYTE or BYTE* parameters (see MSDN Q241862). Two AsciiCE2 methods ("Read" and "Write") pass blocks of data through BYTE arrays. If your application uses these methods, click on the following links to download corrected "asciice2.h" and "asciice2.cpp" files and copy these into your MFC app's directory, overwriting the files that MFC created for you.   [Download asciice.h]       [Download asciice.cpp]

 

AsciiCE2 Methods & Properties

About
[AsciiCE2]

READ-ONLY property returns string describing this version of PrinterCE/AsciiCE2/BarcodeCE.

MFC Syntax: Cstring str =AsciiCE2a.GetAbout();

C++ Syntax: AsciiCE2a.get_About(BSTR* str);

eVB Syntax: str=AsciiCE2a.About

 

Returns

String describing this version of PrinterCE - including information on WinCE platform (Pocket PC, HPC/Pro and 2000), processor type and version. This string can be used in a MsgBox() to display the information.  

Capabilities
[AsciiCE2 & AsciiCE]

READ-ONLY property returns bit-values that identify all the capabilities in the current control.  

MFC Syntax:   long bitvals =AsciiCE2a.GetCapabilities();

C++ Syntax:    AsciiCE2a.get_Capabilities(long * bitvals);

eVB Syntax: bitvals = AsciiCE2a.Capabilities

Returns

Bit values that identify the capabilities of the current control:

Constant

Setting

Description

CAPS_STD

01h

PrinterCE Standard capabilities

CAPS_PLUS

02h

PrinterCE SDK

CAPS_ASCII

04h

AsciiCE

CAPS_BARCODE

08h

BarcodeCE

Char
[AsciiCE2 & AsciiCE]

This method sends single character byte value to the printer.

MFC Syntax:     AsciiCE2a.Char(long ch);

C++ Syntax:     AsciiCE2a.Char(long ch);

eVB Syntax:  AsciiCE2a.Char ch

Parameters

ch - character to be sent to printer  

ClosePort
[AsciiCE2 & AsciiCE]

Closes printer connection used by AsciiCE. This should be called at the end of each Ascii print job.

MFC Syntax:    AsciiCE2a.ClosePort();

C++ Syntax:     AsciiCE2a.ClosePort();

eVB Syntax:  AsciiCE2a.ClosePort  

CrLf
[AsciiCE2 & AsciiCE]

This method sends CR (carriage return Ascii 13) and LF (linefeed Ascii 10) commands to the printer. Some Ascii printers are set up to automatically insert a LF with any CR... in this case, just use Char() operation to send a LF command (ie. Ascii.Char(13))

MFC Syntax:   AsciiCE2a.CrLf();

C++ Syntax:  AsciiCE2a.CrLf();

eVB Syntax: AsciiCE2a.CrLf  

FormFeed
[AsciiCE2 & AsciiCE]

This method sends a FF (formfeed Ascii 12) to the printer to print everything sent for this page and eject the page. If FormFeed is not called at the end of a print job, the printed page will often be left half printed in the printer.

MFC Syntax:            AsciiCE2a.FormFeed();

C++ Syntax:            AsciiCE2a.FormFeed();

eVB Syntax:            AsciiCE2a.FormFeed  

GetVersion
[AsciiCE2]

READ-ONLY Property - Returns an integer value representing the version of the control

MFC Syntax: long value =AsciiCE2a.GetGetVersion();

C++ Syntax:  AsciiCE2a.get_GetVersion(long * value);

eVB Syntax: value = AsciiCE2a.GetVersion

Returns

value - Integer representation of version = (Major * 1000) + Minor.
Example: version 1700 would return value of 1700.

Init
[AsciiCE2 & AsciiCE]

This method registers AsciiCE with the application's RegID string to verify that the app is licensed to use the printer functions.This is identical to PrinterCE's Init() method. Once either Init method has been invoked by either PrinterCE or AsciiCE it is not necessary to call either one again during this use of the control.

MFC Syntax: long retval=AsciiCE2a.Init(BSTR regidstring);

C++ Syntax:  AsciiCE2a.Init(BSTR regidstring,long* retval);

eVB Syntax: AsciiCE2a.Init regidstring

Parameters

regidstring - the 10 digit registration id provided when the PrinterCE/AsciiCE license is purchased. This will identify which version of PrinterCE is licensed and permit all licensed functions to work.

retval - a boolean return value - True if registration was successful, false otherwise.

Remarks

If Init() is not called or is not successful, then the registry is queried to see if the user has registered a single-use license. If not, then an "evaluation" version (30-day time limit) allows the user to continue printing.

Peek
[AsciiCE2]

Returns number of data bytes currently available for reading from the printer port.

MFC Syntax:    long retval=AsciiCE2a.GetPeek();

C++ Syntax:    AsciiCE2a.get_Peek(long* retval);

eVB Syntax: retval=AsciiCE2a.Peek

Parameters

retval - number of data bytes available. 

PrDialogBox
[AsciiCE2]

This method controls action of the "Printing in progress" dialog box (which allows the user to cancel the print operation).

MFC Syntax:    long retval=AsciiCE2a.PrDialogBox(long operation);

C++ Syntax:    AsciiCE2a. PrDialogBox(long operation,long* retval);

eVB Syntax: retval=AsciiCE2a. PrDialogBox operation

Parameters

operation – One of the following values:

Constant

Setting

Description

vbDlgBoxDebugOn

-1

Uses "in progress" dialog box to show details about internal mode of PrinterCE during printing. 
(Off by default).

vbDlgBoxDebugOff

-2

Turns off Debug mode. 

vbDlgBoxUp

0

Display "in progress" dialog box

vbDlgBoxDown

1

Take down dialog box

vbDlgBoxDisable

2

Prevent dialog box from being used

vbDlgBoxStatus

3

Get status of printing operation

vbDlgBoxUserCancel

4

Return True if user cancelled printing operation

vbDlgBoxAbortError

5

Return True if an error aborted printing operation

Return Value

retval - Current status of operation (see table above). If not user cancel or AbortError, then returns current status of printer dialog box (vbDlgUp, etc).

Remarks

By default, the "Printing in progress" dialog box is displayed with the first call by an application to most PrinterCE or AsciiCE2 operation (such as SelectPort). This dialog box will remain until ClosePort completes the printing job. Calling PrDialogBox(vbDlgDisable) will prevent AsciiCE2 from displaying the dialog box (and will not give the user any chance to cancel).

See PrDialogBoxText() for info on changing the text displayed or language used by this dialog.

PrDialogBoxText
[AsciiCE2]

This method allows changing the text displayed or language used by the "Printing in progress" dialog box.

MFC Syntax:     AsciiCE2a.PrDialogBoxText(BSTR MainStr,BSTR TitleStr,BSTR CancelBtnStr);

C++ Syntax:     AsciiCE2a. PrDialogBoxText(BSTR MainStr,BSTR TitleStr,BSTR CancelBtnStr);

eVB Syntax:  AsciiCE2a. PrDialogBoxText MainStr,TitleStr,CancelBtnStr

Parameters

MainStr - String for main text portion of the "Printing in progress" dialog box.
TitleStr - String for title portion of the "Printing in progress" dialog box.
CancelBtnStr - String for Cancel Button portion of the "Printing in progress" dialog box 

Remarks

The text of this dialog box may be changed at any time… if the dialog box is already displayed, it will be taken down, the new text added, and then the dialog box will be redisplayed. If the dialog box is not currently displayed, it will remain down until a call to PrDialogBox() or until the AsciiCE2 automatically displays it.  

ReadChar
[AsciiCE2]

Reads a single character from the printer port. If no data is available, then returns -1.

MFC Syntax: short bval=AsciiCE2a.ReadChar();
C++ Syntax: AsciiCE2a.ReadChar(short* bval);
eVB Syntax: bval=AsciiCE2a.ReadChar

Parameters

bval - Data byte read. If no data available, returns -1.

Read
[AsciiCE2]

Reads a block of data from the printer port. This can be useful for special-purpose printers, such as combination printer & magnetic card reader or smart card reader devices (see printer selections). Note that AsciiCE2 supports infrared devices via IrLPT connections and will only read data if the printer can send it using the IrLPT protocol.

Note: Generally, the application will use AsciiCE2's Write, WriteVar or Text methods to send commands to the printer that enables the data-gathering portion of that device to collect and send the data to be read.

MFC Syntax: AsciiCE2a.Read(long MaxBytes, long LastChar, long ModeFlags, long TimeToWait,
                             long* ResultFlags,long* BytesRead,BYTE* buffer);
C++ Syntax: AsciiCE2a.Read(long MaxBytes, long LastChar, long ModeFlags, long TimeToWait,
                             long* ResultFlags,long* BytesRead,BYTE* buffer);
eVB Syntax: None (see ReadVar method). 

Parameters

MaxBytes - Maximum number of bytes to read.
LastChar - Optional - read data stream until this byte value is found, then return all data read.
ModeFlags - Defines following modes:
    READMODE_NORMAL = 0 - Reads all data into buffer
    READMODE_FLUSHZEROS = 1 - Ignores zero value bytes - all other data is read into buffer
TimeToWait - Maximum number of microseconds to wait for data from the printer. If 0, don't time out.

ResultFlags - Returns results of block read:
     READRESULT_ERR = 0 - Error trying to read (such as loss of infrared connection)
     READRESULT_OK = 1 - Read was successful
     READRESULT_FULLBUFFER = 2 - Returning because "MaxBytes" bytes were read
     READRESULT_TIMEOUT = 3 - Returning because "TimeToWait" microseconds expired
     READRESULT_USERCANCEL = 4 - User cancelled
BytesRead - Returns actual number of bytes read into buffer
buffer - data buffer containing the bytes read
 

ReadVar
[AsciiCE2]

Identical to Read() - except that the data read is returned in a VARIANT array. This is the preferred method for eVB to read.

MFC Syntax: VARIANT* buffer=AsciiCE2a.ReadVar(long MaxBytes, long LastChar, long ModeFlags, 
                             long TimeToWait,long* ResultFlags,long* BytesRead);
C++ Syntax: AsciiCE2a.ReadVar(long MaxBytes, long LastChar, long ModeFlags, long TimeToWait,
                             long* ResultFlags,long* BytesRead,VARIANT* buffer);
eVB Syntax: buffer = AsciiCE2a.ReadVar MaxBytes, LastChar, ModeFlags, TimeToWait,
                             ResultFlags,BytesRead

Parameters

MaxBytes - Maximum number of bytes to read.
LastChar - Optional - read data stream until this byte value is found, then return all data read.
ModeFlags - Defines following modes:
    READMODE_NORMAL = 0 - Reads all data into buffer
    READMODE_FLUSHZEROS = 1 - Ignores zero value bytes - all other data is read into buffer
TimeToWait - Maximum number of microseconds to wait for data from the printer. If 0, don't time out.

ResultFlags - Returns results of block read:
     READRESULT_ERR = 0 - Error trying to read (such as loss of infrared connection)
     READRESULT_OK = 1 - Read was successful
     READRESULT_FULLBUFFER = 2 - Returning because "MaxBytes" bytes were read
     READRESULT_TIMEOUT = 3 - Returning because "TimeToWait" microseconds expired
     READRESULT_USERCANCEL = 4 - User cancelled
BytesRead - Returns actual number of bytes read into buffer
buffer - data buffer containing the bytes read - stored as VARIANT array
 

ReadString
[AsciiCE2]

Similar to Read() - but reads a string of text from the printer port. 

MFC Syntax: BSTR string=AsciiCE2a.ReadString(long MaxChars, long LastChar, long ModeFlags, 
                             long TimeToWait,long* ResultFlags,long*
CharsRead);
C++ Syntax: AsciiCE2a.ReadString(long MaxChars, long LastChar, long ModeFlags, long TimeToWait,
                             long* ResultFlags,long*
CharsRead ,BSTR string);
eVB Syntax: None (see ReadVar method). 

Parameters

MaxChars - Maximum number of characters to read.
LastChar - Optional - read data stream until this byte value is found, then return all data read.
ModeFlags - Defines following modes:
    READMODE_NORMAL = 0 - Reads all data into buffer
    READMODE_FLUSHZEROS = 1 - Ignores zero value bytes - all other data is read into buffer
TimeToWait - Maximum number of microseconds to wait for data from the printer. If 0, don't time out.

ResultFlags - Returns results of block read:
     READRESULT_ERR = 0 - Error trying to read (such as loss of infrared connection)
     READRESULT_OK = 1 - Read was successful
     READRESULT_FULLBUFFER = 2 - Returning because "MaxBytes" bytes were read
     READRESULT_TIMEOUT = 3 - Returning because "TimeToWait" microseconds expired
     READRESULT_USERCANCEL = 4 - User cancelled
CharsRead - Returns actual number of characters read into buffer
string - text containing the bytes read
 

ReadStringVar
[AsciiCE2]

Identical to ReadString() - except that the "ResultFlags" and "CharsRead" values are returned as VARIANTS. This is the preferred method for eVB to read text strings.

MFC Syntax: BSTR* string=AsciiCE2a.ReadStringVar(long MaxChars, long LastChar, 
                             long ModeFlags, long TimeToWait,VARIANT* ResultFlags,VARIANT*
CharsRead);
C++ Syntax: AsciiCE2a.ReadStringVar(long MaxChars, long LastChar, long ModeFlags, 
                             long TimeToWait,VARIANT* ResultFlags,VARIANT*
CharsRead, BSTR* string);
eVB Syntax: buffer = AsciiCE2a.ReadStringVar(MaxChars, LastChar, ModeFlags, TimeToWait,
                             ResultFlags,
CharsRead

Parameters

MaxChars - Maximum number of characters to read.
LastChar - Optional - read data stream until this byte value is found, then return all data read.
ModeFlags - Defines following modes:
    READMODE_NORMAL = 0 - Reads all data into buffer
    READMODE_FLUSHZEROS = 1 - Ignores zero value bytes - all other data is read into buffer
TimeToWait - Maximum number of microseconds to wait for data from the printer. If 0, don't time out.

ResultFlags - Returns results of block read:
     READRESULT_ERR = 0 - Error trying to read (such as loss of infrared connection)
     READRESULT_OK = 1 - Read was successful
     READRESULT_FULLBUFFER = 2 - Returning because "MaxBytes" bytes were read
     READRESULT_TIMEOUT = 3 - Returning because "TimeToWait" microseconds expired
     READRESULT_USERCANCEL = 4 - User cancelled
CharsRead - Returns actual number of characters read into buffer
string - text containing the bytes read
 

RepeatChar
[AsciiCE2 & AsciiCE]

This method sends one or more copies of a character byte value to the printer.

MFC Syntax:    AsciiCE2a.RepeatChar(long ch,long repeatcnt);

C++ Syntax:    AsciiCE2a.RepeatChar(long ch,long repeatcnt);

eVB Syntax: AsciiCE2a.RepeatChar ch, repeatcnt

Parameters

ch - character to be sent to printer
repeatcnt - count of number of copies of "ch" to send to printer.

SelectPort
[AsciiCE2 & AsciiCE]

This method selects the printer connection for an AsciiCE print job. It must precede any Acii printing operations. NOTE: See SelectPortEx() to allow reading data from printer port.

MFC Syntax:  long retval = AsciiCE2a.SelectPort(long Port,long BaudRate,long HandShake);

C++ Syntax:     AsciiCE2a.SelectPort(long Port,long BaudRate,long HandShake,long* retval);

eVB Syntax:  retval = AsciiCE2a.SelectPort(Port, BaudRate, Handshake)

Parameters

Port - Port type: 

Constant

Setting

Description

PORT_COM1

0

Open COM1

PORT_COM2

1

Open COM2

PORT_COM3

4

Open COM3

PORT_COM4

5

Open COM4

PORT_COM5

6

Open COM5

PORT_COM6

7

Open COM6

PORT_COM7

13

Open COM7

PORT_COM8

14

Open COM8

PORT_COM9

17

Open COM9

PORT_LPT

2

Open LPT1

PORT_IR

3

Open IR infrared port

PORT_TOFILE

8

Send all print data to \Output.prn file

PORT_SOCKETCOM

11

Socket PNC Bluetooth card support

PORT_COMPAQ

15

Compaq Bluetooth iPAQ or sleeve

PORT_IPAQ

15

Bluetooth iPAQ or sleeve

PORT_WIDCOMM 16 Device using WIDCOMM Bluetooth stack
PORT_BTQUIKPRINT 18 Special for WIDCOMM, HP iPAQ Bluetooth devices that pop up "Bluetooth Browser" to find/select BT printer at print time: using this flag bypasses the BT browser and uses most recent selected BT printer. To let user discover and select BT printer, use PORT_COMPAQ, PORT_IPAQ, PORT_WIDCOMM

PORT_PRINTERCE

-1

Share PrinterCE port with AsciiCE2. PrinterCE must already be connected to the printer by a successful call to PrinterCE's SelectPrinter() or SetupPrinter(). BaudRate and Handshake values are ignored and the PrinterCE values are used. See "Intermixing PrinterCE and AsciiCE2" for more info.

BaudRate

Constant

Setting

S_4800

0

S_9600

1

S_19200

2

S_38400

3

S_57600

4

S_115200

5

Handshake (plus OR any needed Handshake Bitflags below): 

Constant