Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Append for few records
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00598952
Message ID:
00599728
Views:
20
Here it is:
********************************************************************
*  Description.......: TestAppend - checks append for few records, 
*                      so user may identify, if table structure needs to be changed
*  Calling Samples...: if TestAppend(m.lcFileName,'delimited with tab')
*  Parameter List....: tcFileName, tcType
*  Created by........: Idea - Sergey Berezniker
*  Modified by.......: Nadya Nosonovsky 01/02/2002 10:21:56 AM
********************************************************************
lparameter tcFileName, tcType, tnBufferSize
if vartype(m.tcFileName)<>"C" && invalid parameter passed
     return .f.
endif
if vartype(m.tcType)<>"C" && invalid second parameter passed
     tcType = "delimited with tab" && Default type of the file
endif
if vartype(m.tnBufferSize)<>"N"
     tnBufferSize = 32*1024 && Default 32K
endif
local lnHandle, lcBuffer, llReturn, lcTempName
lnHandle = fopen(m.tcFileName)
llReturn = .f.
if m.lnHandle > 0 && File is successfully opened
     lcBuffer = fread(m.lnHandle, m.tnBufferSize)
     =fclose(m.lnHandle)
* Get read of the last incomplete record
     lcBuffer = left(m.lcBuffer, rat( chr(13)+chr(10), m.lcBuffer) - 1)
     lcTempName = addbs(sys(2023))+forceext('tmp'+sys(2015),'txt')
     =strtofile( m.lcBuffer, m.lcTempName)
&& Assumes, what the table to append is currently active
     append from (m.lcTempName) &tcType
     delete file (m.lcTempName)
     browse
     llReturn = messagebox('Do appended records look correctly? ' + ;
                           'If yes, will now append the whole file...',36,'Check append...') = 6 && Yes
endif
return m.llRetur
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform