Working with barcode

Post Reply
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Working with barcode

Post by TimStone »

I have a dialog that contains a get field and an array browse.

I'm trying to capture a scanned code ( UPC : Universal Part Code ) into the Get, as keyboard input followed by a CRLF.

Then, the code is added to the array that is displayed in the browse.

No problem doing this. However, I then want the GET field to be blank and put back into focus.

I can use a VALID to execute everything except putting the cursor back in the single GET field. Right now I can do the scan, which puts the code into the GET, and the CRLF makes it add to the browse list, and a refresh clears the data. However I then have to click on the GET field for it to be in focus.

Code: Select all

METHOD BuildBarCodeList() CLASS tWorkorder

    LOCAL aBrowseCodes := {}, lAddItems := .f., cBarCode := SPACE(30)

    // Display dialog
    DEFINE DIALOG oBCdlg1 RESOURCE "WOBARCODE" TRANSPARENT OF oWnd TITLE "Input from barcode reader"

    REDEFINE GET oBC1 VAR cBarCode  ID 200 OF oBCdlg1 UPDATE ;
        VALID ( AADD( aBrowseCodes, cBarCode),;
        oLbc1:update(),;
        cBarCode := SPACE(30),;
        oBCdlg1:update(), .t.) 
        [b]// Trying to add oBC1:setfocus() to the valid causes a compile syntax error[/b]

    // Create the list control
    REDEFINE  XBROWSE oLbc1 ;
    DATASOURCE aBrowseCodes ;
    ID 300 OF oBCdlg1 ;
    HEADERS " Partnumber " ;
    COLUMNS 1 ;
    AUTOSORT UPDATE 

        // Provide the header gradient
        oLbc1:bClrGrad := aPubGrad 
        // Set the styles
        oLbc1:nMarqueeStyle := MARQSTYLE_HIGHLROW
        oLbc1:nColDividerStyle := LINESTYLE_RAISED
        oLbc1:nRowDividerStyle := LINESTYLE_RAISED
        oLbc1:nHeadStrAligns  := AL_CENTER
        oLbc1:nStretchCol := STRETCHCOL_LAST
        
        REDEFINE BUTTONBAR oBCBarA ID 100 SIZE 60,60 OF oBCdlg1 2015
            oBCBarA:bClrGrad := aPubGrad

        DEFINE BUTTON oBtnBC1 OF oBCBarA RESOURCE "HRADD"  PROMPT "Add" TOOLTIP "Add parts to the workorder" ;
          ACTION ( lAddItems := .t., oBCdlg1:end( ) )
        DEFINE BUTTON oBtnBC2 OF oBCBarA RESOURCE "HREXIT" PROMPT "Exit" TOOLTIP "Exit the without adding" ;
          ACTION oBCdlg1:end( ) 
    
        // Activate the dialog screen
        ACTIVATE DIALOG oBCdlg1 CENTERED

RETURN nil
 
Any thoughts on how to resolve this ?
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: Working with barcode

Post by Gale FORd »

Maybe add oBC1:oJump := oBC1 to valid

Code: Select all

    REDEFINE GET oBC1 VAR cBarCode  ID 200 OF oBCdlg1 UPDATE ;
        VALID ( AADD( aBrowseCodes, cBarCode),;
        oLbc1:update(),;
        cBarCode := SPACE(30),;
        oBCdlg1:update(), ;
        oBC1:oJump := oBC1,;  // This might work here
        .t.)
        [b]// Trying to add oBC1:setfocus() to the valid causes a compile syntax error[/b]

 
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Working with barcode

Post by TimStone »

Thanks, Gale, but it doesn't work. Yes it moves it to the right position, but it also prevents the dialog from being closed by the button controls. In addition, it seems to be adding blank arrays.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Working with barcode

Post by nageswaragunupudi »

Code: Select all

      VALID ( AAdd( aBrowseCodes, cBarCode   ), ;
              oLbc1:Refresh(), ;
              cBarCode     := Space( 30 ), ;
              oBC1:Refresh(), .f. )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Working with barcode

Post by TimStone »

Thanks ... I should have thought of that.

Now, there is another problem. Here is the existing Method:

Code: Select all

METHOD BuildBarCodeList() CLASS tWorkorder

    LOCAL aBrowseCodes := {}, cBarCode := SPACE(30), oLbc1, oBCdlg1, oBC1

    // Display dialog
    DEFINE DIALOG oBCdlg1 RESOURCE "WOBARCODE" TRANSPARENT OF oWnd TITLE "Input from barcode reader"

    REDEFINE GET oBC1 VAR cBarCode  ID 200 OF oBCdlg1 UPDATE ;
        VALID  ( AADD( aBrowseCodes, cBarCode), ;
        oLbc1:refresh(), ;
        cBarCode := SPACE(30), ;
        oBC1:refresh(), ;
        .f. )

    // Create the dialog box
    REDEFINE  XBROWSE oLbc1 ;
    DATASOURCE aBrowseCodes ;
    ID 300 OF oBCdlg1 ;
    HEADERS " Partnumber " ;
    COLUMNS 1 ;
    AUTOSORT EDITABLE UPDATE 

        // Provide the header gradient
        oLbc1:bClrGrad := aPubGrad 
        // Set the styles
        oLbc1:nMarqueeStyle := MARQSTYLE_HIGHLROW
        oLbc1:nColDividerStyle := LINESTYLE_RAISED
        oLbc1:nRowDividerStyle := LINESTYLE_RAISED
        oLbc1:nHeadStrAligns  := AL_CENTER
        oLbc1:nStretchCol := STRETCHCOL_LAST
        
        REDEFINE BUTTONBAR oBCBarA ID 100 SIZE 60,60 OF oBCdlg1 2015
            oBCBarA:bClrGrad := aPubGrad

        DEFINE BUTTON oBtnBC1 OF oBCBarA RESOURCE "HRADD"  PROMPT "Add" TOOLTIP "Add parts to the workorder" ;
          ACTION ( lAddItems := .t., oBCdlg1:end( ) )
        DEFINE BUTTON oBtnBC2 OF oBCBarA RESOURCE "HREXIT" PROMPT "Exit" TOOLTIP "Exit the without adding" ;
          ACTION oBCdlg1:end( ) 
    
        // Activate the dialog screen
        ACTIVATE DIALOG oBCdlg1 CENTERED
    

RETURN nil

 
It correctly adds the UPC to the array and displays it. Now, however, oBtnBC2, instead of closing the dialog, simply adds a blank element to the array. Keep clicking it, and it keeps adding the blank lines.

Thoughts on this ?
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Working with barcode

Post by nageswaragunupudi »

Please add this line after defining oBtnBC2

Code: Select all

oBtnBC2:lCancel := .t.
This solves your problem.

It is any way desirable to make the valid clause safer:

Code: Select all

      VALID ( If( Empty( cBarCode ), nil, AAdd( aBrowseCodes, cBarCode   ) ), ;
              oLbc1:Refresh(), ;
              cBarCode     := Space( 30 ), ;
              oBC1:Refresh(), .f. )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Working with barcode

Post by TimStone »

Thank you. It is now working perfectly.

In case someone wants to add this type of capability to their program, with the small hand held barcode readers, and use of UPCs, any type of inventory or sales work is simplified. Some of the small readers can now be remotely used up to 300 meters from the computer.

In this program, the idea is that a person can select the Barcode button, then walk around the stock room and scan the parts pulled to use on the service. At the computer, the parts will be on a list. At the time of the scan, the program will actually look at the inventory and get the other data on each part and add it to the array. When finished, the person can edit the data in the browse if desired, then push a button to add the whole list to the invoice. This makes it quite quick to do this work.

These new barcode readers work with bluetooth or a USB dongle. It's also possible to pair them with a small handheld tablet and use them for inventory control work in the stock room. The possibilities are many.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: Working with barcode

Post by Marc Venken »

TimStone wrote:Thank you. It is now working perfectly.

In case someone wants to add this type of capability to their program, with the small hand held barcode readers, and use of UPCs, any type of inventory or sales work is simplified. Some of the small readers can now be remotely used up to 300 meters from the computer.

In this program, the idea is that a person can select the Barcode button, then walk around the stock room and scan the parts pulled to use on the service. At the computer, the parts will be on a list. At the time of the scan, the program will actually look at the inventory and get the other data on each part and add it to the array. When finished, the person can edit the data in the browse if desired, then push a button to add the whole list to the invoice. This makes it quite quick to do this work.

These new barcode readers work with bluetooth or a USB dongle. It's also possible to pair them with a small handheld tablet and use them for inventory control work in the stock room. The possibilities are many.
Tim,

This is exactly what i need.

Can you share the final working code please ?
Marc Venken
Using: FWH 20.08 with Harbour
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Working with barcode

Post by TimStone »

This is the core part of the Method. Once the Dialog is exited, then the array is read and the values applied through a lookup scheme, and adding parts to where they apply, ie. inventory, etc. You could also write code to add parts to an invoice, or to store values that are later used to compare your inventory stock value versus the actual count.

Code: Select all

METHOD BuildBarCodeList() CLASS tWorkorder

    LOCAL aBrowseCodes := {}, cBarCode := SPACE(30), oLbc1, oBCdlg1, oBC1, aBarCode
    LOCAL oEditWork := self, lAddItems := .f.

    // Display dialog
    DEFINE DIALOG oBCdlg1 RESOURCE "WOBARCODE" TRANSPARENT OF oWnd TITLE "Input from barcode reader"

    REDEFINE GET oBC1 VAR cBarCode  ID 200 OF oBCdlg1 UPDATE ;
        VALID  ( IIF( Empty( cBarCode ), nil,;
        ( aBarCode := oEditWork:LookupBarCode( cBarCode ), AADD( aBrowseCodes, aBarCode))), ;
        oLbc1:refresh(), ;
        cBarCode := SPACE(30), ;
        oBC1:refresh(), ;
        .f. )

    // Create the dialog box
    REDEFINE  XBROWSE oLbc1 ;
    DATASOURCE aBrowseCodes ;
    ID 300 OF oBCdlg1 ;
    HEADERS " Quantity ", " UPC ", " Partnumber ", " Description " ;
    SIZES 100, 200, 200, 500 ;
    COLUMNS 1, 2, 3, 4 ;
    FASTEDIT UPDATE 

        REDEFINE BUTTONBAR oBCBarA ID 100 SIZE 60,60 OF oBCdlg1 2015
            oBCBarA:bClrGrad := aPubGrad

        DEFINE BUTTON oBtnBC1 OF oBCBarA RESOURCE "HRADD"  PROMPT "Add" TOOLTIP "Add parts to the workorder" ;
          ACTION ( lAddItems := .t., oBCdlg1:end( ) )
            oBtnBC1:lCancel := .t.
        DEFINE BUTTON oBtnBC2 OF oBCBarA RESOURCE "HREXIT" PROMPT "Exit" TOOLTIP "Exit without adding" ;
          ACTION oBCdlg1:end( ) 
          oBtnBC2:lCancel := .t.
    
        // Activate the dialog screen
        ACTIVATE DIALOG oBCdlg1 CENTERED

  // Application code follows that takes the stored values an applies them to various situations.

RETURN NIL

// And in the .rc file:

WOBARCODE DIALOG 0, 0, 660, 410
STYLE WS_POPUP | WS_CAPTION
CAPTION "Barcode Input"
{
    CONTROL                 "", 100, "TBar", 0|WS_CHILD|WS_VISIBLE, 0,0, 660, 30
    LTEXT           "Barcode",-1,15,40,50,13
    EDITTEXT        200,75,40,200,13
    CONTROL         "",300,"TxBrowse",WS_BORDER | WS_VSCROLL | WS_TABSTOP,15,70,630,330
}
 
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: Working with barcode

Post by Marc Venken »

Thanks. Will look into it.
Marc Venken
Using: FWH 20.08 with Harbour
Post Reply