Seria posible utilizar un control "progress bar" durante un APPEND FROM?
Alguna sugerencia o codigo de alguien que lo haya implementado?
Gracias
George
MsgRun( "Espere, importando ", "Usuario",;
{ || __dbApp( cPath + "\"+cDbf, {},,,,,.F., "DBFCDX") } )
MsgRun(cMsgRun, "Creating Transactions file January 2010 [BETA 0.9]",;
{ || TransaJan2010() })
FUNCTION TransaJan2010()
APPEND FROM "Jan2010.CSV" FOR (nPercent1++, oMtr1:Set(nPercent1), SysRefresh() ) DELIMITED WITH (,)
RETURN (.T.)
FUNCTION TransaJan2010(nPercent1, oMtr1)
APPEND FROM "Jan2010.CSV" WHILE (nPercent1++, oMtr1:Set(nPercent1), IIF( (nPercent1/1000 - int(nPercent1/1000)) = 0 , SysRefresh(), ), TRUE ) DELIMITED WITH (,)
RETURN (.T.)
#include "FIVEWIN.CH"
FUNCTION Main()
LOCAL oDlg, oMeter, nActual := 0
DEFINE BRUSH oBrush COLOR CLR_LGRAY
DEFINE WINDOW oDlg ;
TITLE "Reading CSV file in array";
BRUSH oBrush;
FROM 0,0 TO 20, 80
@ 8, 10 METER oMeter VAR nActual TOTAL 100 OF oDlg SIZE 500, 30
ACTIVATE WINDOW oDlg ON INIT ( oDlg:Center(), ReadCSV(oDlg, oMeter))
FUNCTION ReadCSV(oDlg, oMeter)
LOCAL cMsgRun := "Procedure in execution; please Wait...", cMsgArrayData := "Creating CSV array data; please wait..."
LOCAL nStart := Seconds(), nEnd, aData := {}, cText := "", cMsgMemo := "Reading CSV data source; please wait..."
//===================================================================================================================
// STEP ONE: Read CSV File
//===================================================================================================================
cFileCSV = "your_file.csv"
MsgRun(cMsgMemo, "Main", { | | cText := fCSVMemo(cFileCSV) })
Sysrefresh()
//===================================================================================================================
// STEP TWO: Read each line and save the result in array aData
//===================================================================================================================
MsgRun(cMsgArrayData, "Main", { | | aData := HB_ATokens( cText, Chr(1), .t., .t. ) })
syswait(.05)
Sysrefresh()
? "Total rows in array: ", len(aData), " ", "Delay (secs): ", (Seconds() - nStart)
separate_fields_in_array(aData, oDlg, oMeter)
FUNCTION fCSVMemo(cFileCSV)
cText := StrTran( MemoRead( cFileCSV ), CRLF, Chr(1) )
RETURN (cText)
FUNCTION separate_fields_in_array(aData, oDlg, oMeter)
//=======================================================================================================================
// STEP THREE: Separate fields in each line based in delimiters and save the info in Array
//=======================================================================================================================
nLenData := int(len(aData))
nDivisor := int(nLenData/100)
IIF( nDivisor < 1, nDivisor := 1,)
oMeter:nTotal := nLenData
oMeter:Set(0)
AEval( aData, { |c,i| c := StrTran( c, Chr(1), CRLF ), aData[ i ] := HB_ATokens( c, ",", .t., .t. ), MyProgressBar(i, nDivisor, oMeter, oDlg) } )
nSec4 := Second()
oMeter:Set(nLenData)
syswait(.05)
Sysrefresh()
//================================================================================================================
FUNCTION MyProgressBar(i, nDivisor, oMeter, oDlg)
IIF(i/nDivisor = int(i/nDivisor),;
(oMeter:Set(i),sysrefresh()),)
RETURN (.T.)
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 49 guests