Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
They always move the goal-posts, don't they
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01028919
Message ID:
01029050
Views:
12
>>Hi Terry,
>>
>>I have a program called TestAppend. This program appends few first records, when presents output to the user. If the user agrees, that output looks correct, when I continue. Otherwise I have to investigate...
>
>Hi Nadya
>
>Would you mind slipping me the prog to have a look at? See if I can use such.
>
>Terry
********************************************************************
*  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, tnBufferSize
*  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 rid 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.llReturn
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform