Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Append from
Message
 
 
To
30/08/2005 02:52:06
Yh Yau
Ingenuity Microsystems Sdn Bhd
Kuala Lumpur, Malaysia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01045038
Message ID:
01045090
Views:
46
This message has been marked as the solution to the initial question of the thread.
>Trying to import a colon delimited text file to dbf via append from command. Problem is that in one of the fields (character type) the user is allowed to key in the Enter key hence resulting in the following text data on that particular record to drop down to another line. Even though the complete text is wrapped in the colon, the imported data is completely off from this field onwards.
>Could not use strtran to remove this character as each line contain an end of line character as well.

You can preprocess the file and remove/replace new line characters from inside the field. Here's a sample code that shows how it can be done. You'll have to add error handling and adjust it to your requirements.
lcFileName = "..."
lcFileNameOut = "..."
* # of colons per line ( # of fields - 1 )
lnColonsPerLine = 3

lhIn = FOPEN(lcFileName)
lhOut = FCREATE(lcFileNameOut)

DO WHILE NOT FEOF(lhIn)
	lcStr = FGETS(lhIn, 512)
	DO WHILE OCCURS(":", lcStr) < lnColonsPerLine
                * Replace ENTER with SPACE
		lcStr = lcStr  + SPACE(1) + FGETS(lhIn, 512)
	ENDDO
	IF NOT EMPTY(lcStr)
		FPUTS(lhOut, lcStr)
	ENDIF
ENDDO	

FCLOSE(lhIn)
FCLOSE(lhOut)
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform