FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour To Mr Rao: Problem with old array
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
To Mr Rao: Problem with old array
Posted: Thu Feb 12, 2015 11:05 AM
Dear Mr Rao,
Do you remember the timetable I made on 2012

where I show the teachers timetable

I saw there is an error
When it create the array the procedure insert a record have the field GG_ORA empty
the procedure must not show ( insert ) that record have gg_Ora empty

I punt a condition

if (!Empty(OR->gg_ora))
for sample the procedure insert on array also the record have the field CLASS = 1DIS but these record have gg_ora empty

WHY ?


Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xBrowse.ch"

REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO

Function Small()
Local aDataDay[60][61]
Local aTeachers:= {}
Local nOre := 0
Local aOre:= [60][1]
Local nShow := 1
Local cDocCogn,cDocNom,nDocente,nOra

 RddSetDefault( "DBFCDX" )
 SetHandleCount( 100 )

SELECT 1
   USE docenti  ALIAS DO via "DBFCDX"

SELECT 2
   USE orario  ALIAS OR via "DBFCDX"
    INDEX ON str(OR->PROF,3) TAG ORARIO1 TO TABELLO

SELECT 1

    DO->(DbGoTop())

 DO WHILE ! DO->(EoF())
     cDocCogn:=ALLTRIM(DO->Cognome)
     cDocNom:=ALLTRIM(DO->nome)
     nDocente:=DO->(recno())
     AAdd( aTeachers, cDocCogn+" "+cDocNom )

                         SELECT OR
                         OR->(DbSetOrder(1))
                         OR->(DbSetFilter( {|| OR->PROF=nDOCENTE },  ))
                         OR->(DbGoTop())

                                  if (!Empty(OR->gg_ora))

                                       Do while ! OR->(eof())
                                          nOra:=val(OR->gg_ora)-9
                                              aDataDay[ndocente][nOra] := alltrim(OR->CLASSE)
                                              OR->(dbskip())
                                          enddo


                                           ENDIF

                                      select DO
                                      DO->(DbGoto(nDocente))
                                  DO->(dbskip())
                   enddo
  AEval( aTeachers, { |c,i| aDataDay[ i ][ 1 ] := c } )
  xbrowser adataday
return nil





I COMPILED THE TEST WITH W2 ES2
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: To Mr Rao: Problem with old array
Posted: Thu Feb 12, 2015 11:04 PM
Silvio,

Here you are only checking the first record for !empty(OR->gg_ora):
Code (fw): Select all Collapse
if (!Empty(OR->gg_ora))
   Do while ! OR->(eof())
      nOra:=val(OR->gg_ora)-g
      aDataDay[ndocente][nOra] := alltrim(OR->CLASSE)
      or->(dbskip())
   enddo
ENDIF


You need to do it this way:

Code (fw): Select all Collapse
   Do while ! OR->(eof())
      if ! empty(OR->gg_ora)
         nOra:=val(OR->gg_ora)-g
         aDataDay[ndocente][nOra] := alltrim(OR->CLASSE)
      endif
      or->(dbskip())
   enddo


James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Mr Rao: Problem with old array
Posted: Fri Feb 13, 2015 11:20 AM
thanks james,
Now I have a strange error

When I make an index to Docenti.dbf
INDEX ON UPPER(COGNOME)+UPPER(NOME) TAG DOCNOM TO DOCENTI
....
DO->(DbSetOrder(1))
DO->(DbGoTop())

I would like to order by alphabetical order

and the table has error because I see a data instead of the right why ?

it seems wrong this commands ...or it not run ok

OR->(DbSetFilter( {|| OR->PROF=nDOCENTE }, ))
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: To Mr Rao: Problem with old array
Posted: Fri Feb 13, 2015 03:13 PM

Silvio,

Please send me a copy of docenti.dbf so I can try it here.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Mr Rao: Problem with old array
Posted: Fri Feb 13, 2015 06:28 PM

sent

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: To Mr Rao: Problem with old array
Posted: Fri Feb 13, 2015 08:26 PM
Silvio,

Code (fw): Select all Collapse
INDEX ON UPPER(COGNOME)+UPPER(NOME) TAG DOCNOM TO DOCENTI


Well, it looks OK to me. Can you give me an example of what is wrong with the sort?

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: To Mr Rao: Problem with old array
Posted: Fri Feb 13, 2015 08:31 PM
Silvio,

Code (fw): Select all Collapse
Function Main()
nDocente:= 2
use orario shared alias "OR"

OR->(DbSetFilter( {|| OR->PROF=nDOCENTE }, ))
go top

browse()

Return nil


This code seems to work fine for me.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Mr Rao: Problem with old array
Posted: Fri Feb 13, 2015 09:15 PM

james,
when the procedure create the array aDataDay[ndocente][nOra] and the docenti are index on order alphabetic it make error ... there are teachers have different data
When I not use alphabetic order and I use none indexes it run ok
But I wish have the teachers on alphabetic ( upper(cognome) order to print the tableau

I hope you understood

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: To Mr Rao: Problem with old array
Posted: Fri Feb 13, 2015 11:32 PM

Silvio,

I don't see that array in or_crea.prg and that is the only PRG you have sent me. Is there another?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Mr Rao: Problem with old array
Posted: Sat Feb 14, 2015 09:08 AM

james,
see the first message of this topic

or_crea.prg is another problem

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion