Intermec Home

How to Buy | Partner Login


Developers Forum

Showing results for 
Search instead for 
Do you mean 
Reply
Moderator
GeorgeBrown
Posts: 642
Registered: ‎January 28 2009

GRID Examples

Here's a thread where we can post our working GRID examples for others to use.  I'm often able to get the expression I need to do an edit on scanned data, but I never really seem to know how I did it.  I find it much easier to start with a working example so I'd like for the Dev Forum users to contribute as many as we possibly can.  I'll start with some of mine in a series of postings.

 

Please include the tag "GRID" in your postings to make them easy to find.

 

Thanks!

George Brown
Systems Engineer
Moderator
GeorgeBrown
Posts: 642
Registered: ‎January 28 2009

Re: GRID Examples

Here is a GRID that will take a scanned data string and return from it the last two characters.

 

(.*)(.{2})$=>\2

 

If you needed the last 3 characters, you'd replace the {2} with {3} and so on.  The filter in this expression does not distinguish between numbers or letters.  It also doesn't check to see if the scanned data has at least two characters in it.

George Brown
Systems Engineer
Moderator
GeorgeBrown
Posts: 642
Registered: ‎January 28 2009

Re: GRID Examples

This has three filters in it which are evaluated in the order they appear.  The first one states if a string of characters is >= 28 in length, then pass it as is.  The second part states that if the string is from 1 to 26 characters in length, then pass it as is.  If neither case 1 or 2 is true, then the string must be 27 characters long, in which case the third filter is applied. It will divide the 27 character string into the first 3 and last 24 characters, and then will return only the last 24.

In simple terms, this GRID strips off the first 3 characters from a 27 character string.  If the input string is not 27 characters in length, it returns it as is. 

 
(.{28,})=>\0;(.{1,26})=>\0;(.{3})(.{24})=>\2;
George Brown
Systems Engineer
Moderator
GeorgeBrown
Posts: 642
Registered: ‎January 28 2009

Re: GRID Examples

This example shows how to create a filter that applies only to a single barcode symbology. If the scanned data came from an EAN8 barcode, then return only the first five digits.  If it came from any other symbology, then pass it as is.

 

This can be useful in an application where the user is scanning several barcodes, perhaps on a package, each with a different symbology.  The GRID picks out one of the barcodes for manipulation but leaves all the others alone.

 

<SYM:EAN8>([0-9]{5})=>\1;(.*)=>\1;

George Brown
Systems Engineer
Moderator
GeorgeBrown
Posts: 642
Registered: ‎January 28 2009

Re: GRID Examples

The attached PDF is a good introduction to GRID strings and contains some more examples.

George Brown
Systems Engineer
Intermec Expert
hjgode
Posts: 2,267
Registered: ‎January 29 2009

Re: GRID Examples

Not a GRID example, but something to edit and test RegEx as used by GRID editing easier:

 

Windows: FreeWare RegEx Coach

Unix: Kodos (Gnome)

 

Screenshot-Kodos - The Python Regex Debugger.png

.....................Don't be lazy, give KUDOS........................
-------------==========================--------------
See all my tips and tools at hxxp://www.hjgode.de/dev
and the NEW http://www.hjgode.de/wp
code at google com:
http://code.google.com/p/itc-keyboard/
http://code.google.com/p/rdesktop-ce/
http://code.google.com/p/win-mobile-code/source/browse/#svn%2Ftrunk
Intermec Expert
hjgode
Posts: 2,267
Registered: ‎January 29 2009

Re: GRID Examples

Hi

 

attached is another GRID data editing DLL (like the one at this post)

 

The DLL will add a timestamp and a separation sequence in front of the barcode data and a postamble sequence after the barcode data. Separator and Postamble have to be split by a single '@' char. The separator and postamble show how to use the compile function of a GRID DLL.

 

You have to define the following GRID in Intermec Settings:

Generic:

<CDEF>pathname|FilterEdit|Compile|parameter_string
Example:

<CDEF>\path\Grid_TimeStamp.dll|TimeStamp|Compile|separator@postamble
As tested in screenshot below:

<CDEF>\path\Grid_TimeStamp.dll|TimeStamp|Compile|\t123\t@\t456\n

The DLL has two exports: "TimeStamp" and "Compile". The parameterstring for Compile will be unescaped, meaning \t, \r and \n will be converted to 0x09, 0x0D and 0x0A. This is usefull to have the following virtual wedge see these control characters and perfom TABs and ENTER.

 

The attached VS2008 solution (Windows Mobile 5 SDK) has the DLL project and a TestDLL project. The second enables you to test the DLL without a device and using it directly as DataGRID DLL.

 

TestGridApp.jpg

 

And here are some code snippets of the DLL:

#include <windows.h>
#include <string>

#include "ITCCustomFilter.h"
...
ITCFILTER_API Compile( LPCWSTR szInput ){ 
	// The 3rd parameter in the configured filter / edit expression.
	TCHAR* szTemp = new TCHAR[64];
	memset(szTemp, 0, sizeof(TCHAR)*64);

	TCHAR* pszInput = new TCHAR[64];
	memset(pszInput, 0, sizeof(TCHAR)*64);
	
	wcsncpy(pszInput, szInput, 63);
	
	memset(s_szPostamble, 0, sizeof(TCHAR)*64);
	memset(s_szSeparator, 0, sizeof(TCHAR)*64);

	szTemp = stringReplace(L"\\t", L"\t", pszInput);
	wcscpy(pszInput, szTemp);
	szTemp = stringReplace(L"\\r", L"\r", pszInput);
	wcscpy(pszInput, szTemp);
	szTemp = stringReplace(L"\\n", L"\n", pszInput);

	wcscpy(pszInput, szTemp);
	TCHAR* newInput = new TCHAR[64];
	wsprintf(newInput, pszInput);
	memset(szTemp, 0, 64 * sizeof(TCHAR));

	//split string at '@'
	TCHAR* wToken = wcstok(newInput, L"@");
	if(wToken!=NULL){
		wsprintf(s_szSeparator, wToken);
		wToken = wcstok(NULL, L"@");
		if(wToken!=NULL)
			wsprintf(s_szPostamble, wToken);
	}
	//CleanUp
	delete(szTemp);
	delete(pszInput);
	delete(newInput);
	return ITCFILTER_SUCCESS;
}
...
ITCFILTER_API TimeStamp (
	LPCWSTR szInput,        // [in] input data
	DWORD   nInputChars,    // [in] number of input data characters
	LPWSTR  szOutputBuffer, // [out] output data
	PDWORD  pnOutputChars   // number of characters in [in] szOutputBuffer, [out] output data 
	)
	{
		HRESULT hr = S_OK;
		TCHAR* sTimeStamp = new TCHAR[18];
		SYSTEMTIME sysTime;
		GetLocalTime(&sysTime);
		//format datetime to 'YYYYMMDD hh:mm:ss'
		wsprintf(sTimeStamp, L"%04i%02i%02i %02i:%02i:%02i", sysTime.wYear, sysTime.wMonth, sysTime.wDay,
			sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
		DWORD nCharsNeeded = wcslen(sTimeStamp) + wcslen(s_szSeparator) + nInputChars + wcslen(s_szPostamble);
        // First check again to make sure we're provided enough space
        if( nCharsNeeded > *pnOutputChars )
        {
            hr = ITCFILTER_TOO_BIG;
        }
        // Enough space, so do the work
        else
        {
			memset(szOutputBuffer, 0, *pnOutputChars);
			wsprintf(szOutputBuffer, L"%s%s%s%s", sTimeStamp, s_szSeparator, szInput, s_szPostamble);
		}
		*pnOutputChars = nCharsNeeded;
		return hr;
	}
...

 

Very easy, or?

 

.....................Don't be lazy, give KUDOS........................
-------------==========================--------------
See all my tips and tools at hxxp://www.hjgode.de/dev
and the NEW http://www.hjgode.de/wp
code at google com:
http://code.google.com/p/itc-keyboard/
http://code.google.com/p/rdesktop-ce/
http://code.google.com/p/win-mobile-code/source/browse/#svn%2Ftrunk
Intermec Expert
hjgode
Posts: 2,267
Registered: ‎January 29 2009

Re: GRID Examples

Hi

 

I extended Grid_TimeStamp. You now can optionally define a separator to be used between Date and Time. The other change is the usage of the Device's Locale to format Date and Time. Date and Time will be inserted as defined in Locale Settings of device.

 

TestGridApp2.jpg

 

code (VS2008, WM5 SDK) is now hosted at code.google.com/p/gridtimestamp

 

 

 

Have fun

 

Josef

 

 

.....................Don't be lazy, give KUDOS........................
-------------==========================--------------
See all my tips and tools at hxxp://www.hjgode.de/dev
and the NEW http://www.hjgode.de/wp
code at google com:
http://code.google.com/p/itc-keyboard/
http://code.google.com/p/rdesktop-ce/
http://code.google.com/p/win-mobile-code/source/browse/#svn%2Ftrunk
Moderator
GeorgeBrown
Posts: 642
Registered: ‎January 28 2009

Re: GRID Examples

Here is another GRID example. This is a three part data editing scenario.  This came up recently for a customer.  He was scanning three different barcode labels that would contain a four digit number.  If that number was found, he wanted the GRID to return only the following six digits, which were always numeric.  The four digit key sequences were 3201, 3102 and 3202.

 

Part one would look like this.

 

(.*)(3201)([0-9]{6})(.*)=>\3;

 

Part two would look like this.

 

(.*)(3102)([0-9]{6})(.*)=>\3;

 

And, part three like this.

 

(.*)(3202)([0-9]{6})(.*)=>\3;

 

So, putting them together, we get this.

 

(.*)(3201)([0-9]{6})(.*)=>\3;(.*)(3102)([0-9]{6})(.*)=>\3;(.*)(3202)([0-9]{6})(.*)=>\3;

 

When a barcode was scanned that didn't contain any of these, the customer wanted nothing returned.  If, on the other hand, he wanted everything returned instead, one would simply modify the GRID to look like this.

 

(.*)(3201)([0-9]{6})(.*)=>\3;(.*)(3102)([0-9]{6})(.*)=>\3;(.*)(3202)([0-9]{6})(.*)=>\3;(.*)=>\1;

George Brown
Systems Engineer
Intermec Expert
hjgode
Posts: 2,267
Registered: ‎January 29 2009

Re: GRID Examples

Hi

why did you not simply use

(.*)(3[0-2]02)([0-9]{6})(.*)=>\3;

for all three?
.....................Don't be lazy, give KUDOS........................
-------------==========================--------------
See all my tips and tools at hxxp://www.hjgode.de/dev
and the NEW http://www.hjgode.de/wp
code at google com:
http://code.google.com/p/itc-keyboard/
http://code.google.com/p/rdesktop-ce/
http://code.google.com/p/win-mobile-code/source/browse/#svn%2Ftrunk