Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 8 Jahren, 5 Monaten
Letzter Beitrag:
vor 8 Jahren, 5 Monaten
Beteiligte Autoren:
Toddy Utomo, Al, Jimbo, Marc De Swert

WD-Export Table to DBF

Startbeitrag von Toddy Utomo am 07.07.2009 15:32

Hi

I try to export Table to DBF, but WD only create an empty DBF file, with no records
What wrong with this code:


PROCEDURE SendToDBF(sFullPathFileName)
XB is Data Source

sFullPathIndexName is string = Replace(sFullPathFileName,".dbf",".ndx",IgnoreCase)

HDBDescribeFile ( "SEND2DBF" , "XB" , sFullPathFileName )
HDBDescribeField ( "NUMBER,N,5,0" )
HDBDescribeField ( "ITEMCODE,C,20" )
HDBDescribeField ( "ITEMDESC,C,50" )
HDBDescribeField ( "UNITPRICE,N,10,2" )
HDBDescribeField ( "FIRSTSTOCK,N,15,2" )
HDBDescribeField ( "LASTSTOCK,N,15,2" )
HDBDescribeField ( "QTYSTOCK,N,15,2" )
HDBDescribeField ( "AMOUNT,N,15,2" )
HDBDescribeField ( "TRXDATE,D" )
HDBDescribeIndex ( sFullPathIndexName,"ITEMCODE")
HDBCreation()

WHILE WIN_SEE_STOCK.TABLE_Table3.Column2 ""
XB.NUMBER = WIN_SEE_STOCK.TABLE_Table3.Column1
XB.ITEMCODE = WIN_SEE_STOCK.TABLE_Table3.Column2
XB.ITEMDESC = WIN_SEE_STOCK.TABLE_Table3.Column3
XB.UNITPRICE = WIN_SEE_STOCK.TABLE_Table3.Column4
XB.FIRSTSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column5
XB.LASTSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column6
XB.QTYSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column7
XB.AMOUNT = WIN_SEE_STOCK.TABLE_Table3.Column8
XB.TRXDATE = WIN_SEE_STOCK.TABLE_Table3.Column9
HAdd("SEND2DBF")
END




TIA
Toddy

Antworten:

Hi Toddy,

'WHILE' is not doing an implicit read of the Table, it just checks for values to continue / end a loop.

Depends a lot on the Table, but 'reading' the Table would basically look like this


FOR X = 1 to TableCount(WIN_SEE_STOCK.TABLE_Table3)
XB.NUMBER = WIN_SEE_STOCK.TABLE_Table3.Column1[X]
XB.ITEMCODE = WIN_SEE_STOCK.TABLE_Table3.Column2[X]
XB.ITEMDESC = WIN_SEE_STOCK.TABLE_Table3.Column3[X]
XB.UNITPRICE = WIN_SEE_STOCK.TABLE_Table3.Column4[X]
XB.FIRSTSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column5[X]
XB.LASTSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column6[X]
XB.QTYSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column7[X]
XB.AMOUNT = WIN_SEE_STOCK.TABLE_Table3.Column8[X]
XB.TRXDATE = WIN_SEE_STOCK.TABLE_Table3.Column9[X]
HAdd("SEND2DBF")
END



Of course, you can always insert conditions to select those rows which you'd like to write ..
Guenter



von Jimbo - am 07.07.2009 16:07
Thanks, Guenter
it work!

Regards
Toddy


von Toddy Utomo - am 07.07.2009 16:39
And if you place the TableCount into a variable, it's faster
because you just read1 time the rows


lv_Count is int = TableCount(WIN_SEE_STOCK.TABLE_Table3)

FOR X = 1 to lv_Count
XB.NUMBER = WIN_SEE_STOCK.TABLE_Table3.Column1[X]
XB.ITEMCODE
...


Marc :cool:

von Marc De Swert - am 08.07.2009 08:25
Hello Marc

There are a couple more variations on that theme

You can use:
FOR X = 1 _TO_ tablecount(WIN_SEE_STOCK.TABLE_Table3)
Using _TO_ instead of to indicates that the tablecount() should only be evaluated once

You don't really need tablecount() either. You can use

For each row of WIN_SEE_STOCK.TABLE_Table3

Regards
Al

von Al - am 08.07.2009 11:57
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.