Working with barcode

Working with barcode

Postby TimStone » Wed Feb 14, 2018 8:44 pm

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  Expand view

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Working with barcode

Postby Gale FORd » Wed Feb 14, 2018 10:07 pm

Maybe add oBC1:oJump := oBC1 to valid

Code: Select all  Expand view

    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]

 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Working with barcode

Postby TimStone » Thu Feb 15, 2018 1:32 am

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Working with barcode

Postby nageswaragunupudi » Thu Feb 15, 2018 2:09 am

Code: Select all  Expand view
     VALID ( AAdd( aBrowseCodes, cBarCode   ), ;
              oLbc1:Refresh(), ;
              cBarCode     := Space( 30 ), ;
              oBC1:Refresh(), .f. )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Working with barcode

Postby TimStone » Thu Feb 15, 2018 5:49 am

Thanks ... I should have thought of that.

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

Code: Select all  Expand view

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Working with barcode

Postby nageswaragunupudi » Thu Feb 15, 2018 11:21 am

Please add this line after defining oBtnBC2
Code: Select all  Expand view
oBtnBC2:lCancel := .t.

This solves your problem.

It is any way desirable to make the valid clause safer:
Code: Select all  Expand view
     VALID ( If( Empty( cBarCode ), nil, AAdd( aBrowseCodes, cBarCode   ) ), ;
              oLbc1:Refresh(), ;
              cBarCode     := Space( 30 ), ;
              oBC1:Refresh(), .f. )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Working with barcode

Postby TimStone » Thu Feb 15, 2018 5:22 pm

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Working with barcode

Postby Marc Venken » Fri Jun 29, 2018 1:08 pm

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 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Working with barcode

Postby TimStone » Fri Jun 29, 2018 10:34 pm

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  Expand view

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Working with barcode

Postby Marc Venken » Mon Jul 02, 2018 7:16 am

Thanks. Will look into it.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests