Listbox displays incorrect data

Listbox displays incorrect data

Postby cdmmaui » Sat Jul 28, 2018 8:38 pm

Hello Everyone,

We have a problem with a specific LISTBOX. For some reason, the listbox is displaying incorrect details, specifically when no key is found. The associated DBF has an index related to the specific key. What would cause this problem?

I have checked the DBF for corruption and I have deleted the index and rebuilt

//
//
// Source
DEFINE DIALOG oDlgEvent RESOURCE "EVENT" TITLE cEtitle

REDEFINE COMBOBOX aGet[01] VAR cEvent ID 101 ITEMS aEvent OF oDlgEvent
REDEFINE GET aGet[02] VAR dDate ID 102 OF oDlgEvent PICTURE "@D"
REDEFINE GET aGet[03] VAR cTime ID 103 OF oDlgEvent PICTURE "99:99"
REDEFINE GET aGet[04] VAR cBy ID 104 OF oDlgEvent PICTURE "@!"
REDEFINE GET aGet[05] VAR cNotes ID 105 MEMO OF oDlgEvent

REDEFINE CHECKBOX aGet[06] VAR lCts ID 106 OF oDlgEvent

REDEFINE CHECKBOX aGet[07] VAR lEmship ID 107 OF oDlgEvent ;
VALID( _GetRef( aGet ), .T. )
REDEFINE GET aGet[08] VAR cShipem ID 108 OF oDlgEvent WHEN lEmship

REDEFINE CHECKBOX aGet[09] VAR lEmcons ID 109 OF oDlgEvent ;
VALID( _GetRef( aGet ), .T. )
REDEFINE GET aGet[10] VAR cConsem ID 110 OF oDlgEvent WHEN lEmcons

REDEFINE CHECKBOX aGet[11] VAR lEmothr ID 111 OF oDlgEvent ;
VALID( _GetRef( aGet ), .T. )
REDEFINE GET aGet[12] VAR cOthrem ID 112 OF oDlgEvent WHEN lEmothr

// Event...
SELECT event
SET ORDER TO TAG S3
GO TOP
SEEK cFileNumber
REDEFINE LISTBOX oLbx2 FIELDS _EventDescription( event->event, aEvent ) , ;
ALLTRIM( event->notes ) , ;
DTOC(event->date) , ;
event->time , ;
event->by , ;
event->file ;
ID 6000 ;
HEADERS "Event", "Location/Notes", "Date", "Time", "By", "." ;
FIELDSIZES 350 , 350 , 85 , 50 , 200 , 99 ;
SELECT file FOR cFileNumber ;
ON DBLCLICK _EventDet() ;
OF oDlgEvent

REDEFINE BUTTON ID 202 OF oDlgEvent ACTION ( _EventUpd( @nRecId, @aEvent, @cEvent, @dDate, @cTime, @cBy, @cNotes, @lCts, @lEmShip, @cShipEm, @lEmCons, @cConsEm, @lEmothr, @cOthrEm ), _GetRef( aGet ), Sysrefresh() )
REDEFINE BUTTON ID 203 OF oDlgEvent ACTION _EventDel( oLbx2, cFileNumber ) WHEN lAdmin

REDEFINE BUTTON ID 200 OF oDlgEvent ACTION ( lUpd := .T., oDlgEvent:End() ) WHEN ( ! LEFT( cEvent, 1 ) $ "-" ) .AND. ( ! EMPTY( dDate ) ) .AND. ( ! EMPTY( LEFT(cTime,2) ) )
REDEFINE BUTTON ID 201 OF oDlgEvent ACTION ( lUpd := .F., oDlgEvent:End() )

ACTIVATE DIALOG oDlgEvent CENTERED VALID _EventOk( @lUpd, cEvent, dDate, cTime, cBy )

//
//
// Source RC compiled with Pelles C
EVENT DIALOG DISCARDABLE 49, 49, 600, 350
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION
CAPTION "Event Manager"
FONT 10, "tahoma"
{
CONTROL "Event.........................", -1, "Static", WS_GROUP, 5, 7, 75, 8
CONTROL "", 101, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP, 85, 5, 345, 300
CONTROL "Event Date.................", -1, "Static", WS_GROUP, 5, 21, 75, 8
CONTROL "", 102, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|ES_UPPERCASE|WS_BORDER|WS_TABSTOP, 85, 20, 45, 12
CONTROL "Event Time................", -1, "Static", WS_GROUP, 5, 36, 75, 8
CONTROL "", 103, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|ES_UPPERCASE|WS_BORDER|WS_TABSTOP, 85, 35, 45, 12
CONTROL "Event Name...............", -1, "Static", WS_GROUP, 5, 51, 75, 8
CONTROL "", 104, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|ES_UPPERCASE|WS_BORDER|WS_TABSTOP, 85, 50, 150, 12
CONTROL "Event Notes................", -1, "Static", WS_GROUP, 5, 66, 75, 8
CONTROL "", 105, "Edit", ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN|ES_UPPERCASE|WS_BORDER|WS_TABSTOP, 85, 65, 345, 30
CONTROL "Display on Cargo Tracking System (CTS)", 106, "Button", BS_AUTOCHECKBOX|WS_TABSTOP, 5, 100, 149, 12
CONTROL "E-Mail Shipper", 107, "Button", BS_AUTOCHECKBOX|WS_TABSTOP, 5, 115, 60, 12
CONTROL "", 108, "Edit", WS_BORDER|WS_TABSTOP, 85, 115, 345, 12
CONTROL "E-Mail Consignee", 109, "Button", BS_AUTOCHECKBOX|WS_TABSTOP, 5, 130, 72, 12
CONTROL "", 110, "Edit", WS_BORDER|WS_TABSTOP, 85, 130, 345, 12
CONTROL "E-Mail Other Party", 111, "Button", BS_AUTOCHECKBOX|WS_TABSTOP, 5, 145, 77, 12
CONTROL "", 112, "Edit", WS_BORDER|WS_TABSTOP, 85, 145, 345, 12
CONTROL "OK", 200, "Button", WS_TABSTOP, 540, 5, 50, 14
CONTROL "Cancel", 201, "Button", WS_TABSTOP, 540, 24, 50, 14
CONTROL "Double Click Event below to view details", -1, "Static", SS_CENTER|WS_GROUP, 216, 160, 167, 8
CONTROL "", 6000, "TWBrowse", WS_TABSTOP|0x00b00000, 5, 170, 590, 150
CONTROL "Edit Event", 202, "Button", WS_TABSTOP, 191, 327, 100, 14
CONTROL "Remove Event", 203, "Button", WS_TABSTOP, 309, 327, 100, 14
CONTROL "Military Time", -1, "Static", SS_CENTER|WS_GROUP, 135, 36, 47, 8
}
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Listbox displays incorrect data

Postby Antonio Linares » Tue Jul 31, 2018 4:14 pm

Darrell,

Please post the source code for the function _EventDescription()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Listbox displays incorrect data

Postby cdmmaui » Tue Jul 31, 2018 4:16 pm

Hi Antonio,

Here is the code:

//-----------------------------------------------------------------------------
FUNCTION _EventDescription( cEventCode, aEvent )

local nX1 :=0, nPos := 0, cReturn := "", cEvent := ""

// Init...
cReturn := cEventCode

FOR nX1=1 TO LEN(aEvent)
nPos := AT('-', cEventCode )
IF nPos>0
cEvent := LEFT( cEventCode, nPos-1 )
IF (LEFT(aEvent[nX1],nPos-1)==cEvent)
cReturn := ALLTRIM( SUBSTR( aEvent[nX1], nPos+1 ) )
EXIT
ENDIF
ENDIF
NEXT nX1

RETURN (cReturn)
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Listbox displays incorrect data

Postby Antonio Linares » Tue Jul 31, 2018 5:08 pm

Darrell,

In FWH/samples/gallery/onemany/onemany.prg there is an example of use for LISTBOX ... SELECT ... FOR

An index is created like this:
INDEX ON Facturas->Codigo TO "FacCod"

...

ALIAS "Facturas" ;
SELECT Facturas->Codigo FOR Clientes->Codigo

Basically Clientes->Codigo (clients->code) is searched in Facturas->Codigo (invoices->code) and the browse only shows these results

Please check that your PRG does it the same way
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Listbox displays incorrect data

Postby cdmmaui » Tue Jul 31, 2018 5:47 pm

Dear Antonio,

We added the ALIAS and UPDATE clauses to the LISTBOX.

The only difference we have with index is that we have a TAG S3 instead of leaving it blank.

I will look at removing TAG S3 to see if that makes a difference.

Thank you,
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Listbox displays incorrect data

Postby Antonio Linares » Wed Aug 01, 2018 4:33 am

Darrell,

The index key has to be "file" so the browse can make a search on it for cFileNumber

Please copy here the DBF structure and the INDEX key
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Listbox displays incorrect data

Postby cdmmaui » Wed Aug 01, 2018 10:24 pm

Hi Antonio,

Here is the code we use to create the index, please note that we changed from TAG S1 to TAG S3 when we started having problems.

//----------------------------------------------------------------------------//
static function BuildEvt( nIndex, pText, lEnd )

oMeter:nTotal = RecCount()
nPercent = 0

DO CASE
CASE nIndex=1
cText := "Removing Deleted Event records"
oText:SetText( cText )
PACK
cText := pText
oText:SetText( cText )
INDEX ON file+DTOS(date)+time TAG S1 TO &Pdd.evtx01 EVAL ( oMeter:Set( RecNo() ), SysRefresh(), ! lEnd ) DESCENDING
DBCLEARINDEX()
SysRefresh()

CASE nIndex=2
cText := pText
oText:SetText( cText )
INDEX ON file+DTOS(date)+time TAG S2 TO &Pdd.evtx01 EVAL ( oMeter:Set( RecNo() ), SysRefresh(), ! lEnd )
DBCLEARINDEX()
SysRefresh()

CASE nIndex=3
cText := pText
oText:SetText( cText )
INDEX ON file TAG S3 TO &Pdd.evtx01 EVAL ( oMeter:Set( RecNo() ), SysRefresh(), ! lEnd ) DESCENDING
DBCLEARINDEX()
SysRefresh()
ENDCASE

RETURN nil
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Listbox displays incorrect data

Postby cdmmaui » Wed Aug 01, 2018 10:28 pm

Hi Antonio,

Here is the structure of the event table.

Image
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Listbox displays incorrect data

Postby Antonio Linares » Thu Aug 02, 2018 4:28 pm

Darrell,

Please add the ALIAS event clause here:

REDEFINE LISTBOX oLbx2 FIELDS _EventDescription( event->event, aEvent ) , ;
ALLTRIM( event->notes ) , ;
DTOC(event->date) , ;
event->time , ;
event->by , ;
event->file ;
ID 6000 ;
HEADERS "Event", "Location/Notes", "Date", "Time", "By", "." ;
FIELDSIZES 350 , 350 , 85 , 50 , 200 , 99 ;
SELECT file FOR cFileNumber ;
ON DBLCLICK _EventDet() ;
OF oDlgEvent ;
ALIAS event
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Listbox displays incorrect data

Postby cdmmaui » Thu Aug 02, 2018 4:34 pm

Antonio,

I did have ALIAS "event", do you want me to change to ALIAS event instead and place at the end of the code?
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Listbox displays incorrect data

Postby cdmmaui » Thu Aug 02, 2018 4:46 pm

Antonio,

We added ALIAS "event" and still did not work

ALIAS event generated error
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Listbox displays incorrect data

Postby Antonio Linares » Thu Aug 02, 2018 4:49 pm

After SEEK cFileNumber please insert this:

MsgInfo( cFileNumber, cFileNumber == event->file )

and please let me know what you get
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Listbox displays incorrect data

Postby Rick Lipkin » Thu Aug 02, 2018 5:53 pm

Darrell

I did not follow your Eval meter part of your index code .. and the macro expansion of the tag name ...
Code: Select all  Expand view  RUN

INDEX ON file+DTOS(date)+time TAG S1 TO &Pdd.evtx01 EVAL ( oMeter:Set( RecNo() ), SysRefresh(), ! lEnd ) DESCENDING
 


Note that I don't doubt if your code works .. this code seems to work for me:

Code: Select all  Expand view  RUN

//------------------------
FUNC INDEX_PROG()

LOCAL cDEFA := SET(7)

FERASE( cDEFA+"\PROGRAM.CDX" )
SELECT 1
IF NETUSE( "PROGRAM.DBF",.T.,5)

   IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildPrg( oMeter, oText, oDlg, @lEnd, 1 ) }     , ;
        ALIAS()+".dbf tag Program " )

   IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildPrg( oMeter, oText, oDlg, @lEnd, 2 ) }     , ;
        ALIAS()+".dbf tag Progname " )

   CLOSE DATABASES
ENDIF

RETURN(NIL)

//-------------------------------------------------------------//
FUNCTION BuildPrg( oMeter, oText, oDlg, lEnd, nTAG )

   oMeter:nTotal := lastrec()

   DO CASE
   CASE nTAG = 1
        INDEX on program TAG program                             ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 2
        INDEX on progname TAG progname                           ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   ENDCASE

RETURN( NIL )
 


Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Listbox displays incorrect data

Postby cdmmaui » Thu Aug 02, 2018 9:55 pm

Hi Rick,

The meter is defined in the dialog box.

That is not the problem as we have had this for running fine for since the beginning.

Thanks for your help.

Sincerely,
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests

cron