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:
00599518
Views:
16
This message has been marked as a message which has helped to the initial question of the thread.
Hi Nadya,

A couple of comments. First, the 'fixed' temporary file name could create conflict in the multi-user environment. Second I would pass the buffer size as the third parameter(with degfault to 32k or whatever). This'll allow you to control the number of appended test records, if necessary.

< snip >
>
>Thanks, Sergey:
>
>********************************************************************
>*  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 12/31/2001 01:16:20 PM
>********************************************************************
>lparameter tcFileName, tcType
>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
>local lnHandle, lcBuffer, llReturn
>lnHandle = FOPEN(m.tcFileName)
>llReturn = .f.
>if m.lnHandle > 0 && File is opened
>   lcBuffer = FREAD(m.lnHandle, 32*1024)  && 32K 
>   FCLOSE(m.lnHandle)
>* Get read of the last incomplete record
>   lcBuffer = LEFT(m.lcBuffer, RAT( CHR(13)+CHR(10), m.lcBuffer) - 1)
>   =Strtofile( m.lcBuffer, 'tempfile.txt')
>   && Assumes, what the table to append is currently active
>   append from tempfile.txt &tcType
>   delete file tempfile.txt
>   browse
>   llReturn = messagebox('Do appended records look correctly? If yes, will now append the whole file...',36,'Check append...') = 6 && Yes     
>endif
>return m.llReturn
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform