MarcoBoschi wrote:A quick Update,
I have a For NEXT cicle that open a dbf file at a time and than a do while enddo cicle in quch analize every single
record that satisfye some conditions.
FUNCTION CONTA_TELEFONATE()
LOCAL cAmIni := SUBSTR( DTOS( DATE() ) , 1 , 6 )
LOCAL cAmFin := SUBSTR( DTOS( DATE() ) , 1 , 6 )
LOCAL aLista := {}
LOCAL cChiamante := SPACE( 30 )
LOCAL cChiamato := SPACE( 30 )
LOCAL cDbf
LOCAL oExcel , oAs
@ 03 , 11 SAY "Inserire Anno Mese Iniziale " GET cAmIni PICTURE "999999" COLOR "*b/w , *w/b+"
@ 04 , 11 SAY "Inserire Anno Mese Iniziale " GET cAmFin PICTURE "999999" COLOR "*b/w , *w/b+"
@ 05 , 11 SAY "CGPN Calling " GET cChiamante VALID ( cChiamato := cChiamante , .T. ) COLOR "*b/w , *w/b+"
@ 06 , 11 SAY "CDPN Called " GET cChiamato COLOR "*b/w , *w/b+"
READ
cChiamante := ALLTRIM( cChiamante )
cChiamato := ALLTRIM( cChiamato )
IF ALERT( "Confermare conteggio chiamate? " , { "Conferma" , "Abbandona" } , "*b/w , *w/b+" ) = 1
nInizio := SECONDS()
SET AUTOPEN OFF
FOR iTab := VAL( cAmIni ) TO VAL( cAmFin )
cDbf := "n:\inno\I_" + STR( iTab , 6 )
cDbfLoc := "c:\inno\I_" + STR( iTab , 6 )
SELECT 0
USE &cDbf
// copia il file cdx in locale e poi lo apre
// copyfile( cDbf + ".cdx" , cDbfLoc + ".cdx") // this copy in local c:\
// SET INDEX TO &cDbfLoc /// this open the cdx local
SET INDEX TO &cDbf
GO TOP
DO WHILE !EOF()
IF !EMPTY( cChiamante )
IF AT( cChiamante , FIELD->src_cgpn ) > 0
IF field->dir = "out" .AND. field->secondi > 0 .AND. field->event = "B:Rel"
AADD( aLista , { "IN" , field->src_cgpn , SPACE(20) , field->do , field->secondi, field->dst_cdpn } )
ENDIF
ENDIF
ENDIF
IF !EMPTY( cChiamato )
IF AT( cChiamato , FIELD->src_cdpn ) > 0
IF field->dir = "out" .AND. field->secondi > 0 .AND. field->event = "B:Rel"
AADD( aLista , { "OUT" , SPACE( 20 ) , field->src_cdpn , field->do , field->secondi , field->src_cgpn } )
ENDIF
ENDIF
ENDIF
SKIP
ENDDO
USE
FERASE( cDbfLoc + ".cdx" )
NEXT iTAb
oExcel := CREATEOBJECT( "Excel.Application" )
oExcel:Workbooks:Add()
oAs := oExcel:Activesheet()
oAs:name := "Telefonate"
oAs:Range( "A1" ):Value := "DIR"
oAs:Range( "B1" ):Value := "CGPN"
oAs:Range( "C1" ):Value := "CDPN"
oAs:Range( "D1" ):Value := "DATA ORA"
oAs:Range( "E1" ):Value := "SECONDI"
oAs:Range( "F1" ):Value := "MINUTI"
oAs:Range( "G1" ):Value := "INTERNO"
IF LEN( aLista ) > 0
FOR iLista := 1 TO LEN( aLista )
oAs:Range( "A" + ALLTRIM( STR( iLista+ 1 ) ) ):Value := aLista[ iLista , 1 ]
oAs:Range( "B" + ALLTRIM( STR( iLista+ 1 ) ) ):Value := "'" + aLista[ iLista , 2 ]
oAs:Range( "C" + ALLTRIM( STR( iLista+ 1 ) ) ):Value := "'" + aLista[ iLista , 3 ]
oAs:Range( "D" + ALLTRIM( STR( iLista+ 1 ) ) ):Value := "'" + aLista[ iLista , 4 ]
oAs:Range( "E" + ALLTRIM( STR( iLista+ 1 ) ) ):Value := aLista[ iLista , 5 ]
oAs:Range( "F" + ALLTRIM( STR( iLista+ 1 ) ) ):Value := aLista[ iLista , 5 ] / 60
oAs:Range( "G" + ALLTRIM( STR( iLista+ 1 ) ) ):Value := "'" + aLista[ iLista , 6 ]
NEXT iLista
ENDIF
oExcel:visible := .T.
oAS:Columns( "A" ):AutoFit()
oAS:Columns( "B" ):AutoFit()
oAS:Columns( "C" ):AutoFit()
oAS:Columns( "D" ):AutoFit()
oAS:Columns( "E" ):AutoFit()
oAS:Columns( "F" ):AutoFit()
oAs:Range( "F" + ALLTRIM( STR( iLista + 2 ) ) ):Value := "=SOMMA(F2..F" + ALLTRIM( STR( iLista , 4 ) ) + ")"
oAs:Columns( "F" ):NumberFormat = "###.##0,00"
SET AUTOPEN ON
ENDIF
offbox( boxn )
// SET(_SET_AUTOPEN , lAutoOpen )
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 53 guests