Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STRTRAN not working

Status
Not open for further replies.

Ed Andres

IS-IT--Management
Mar 27, 2001
142
US
I have a situation where I export data from a legacy database to a comma delimited file using " to designate text and this cannot be changed. I am then importing them into a tables for further use. There is one text file that has a situation where the characters ,", show up and it blows up the import for obvious reasons. I wrote some code to change the ,", to just ,, but it doesn't seem to work. There appears to be no change to the file. I have tried both STRTRAN & CHRTRAN and neither seems to work.

Here is what I have tried:

LOCAL lcMyString
lcMyString = FILETOSTR('c:\ftp\somast.txt')
STRTRAN(lcMyString, ',",', ',,')
STRTOFILE(lcMyString, 'c:\ftp\somast.txt')

Thanks in advance for any suggestions.
 
Jim,
Thanks for the quick reply but foxpro doesn't like that line unless I am reading it wrong. Is it two double quotes then one double quote?

Ed
 
What you trying to do?
To replace a string [comma + one double quote + comma] to double comma?
If so try this:
Code:
LOCAL lcMyString
lcMyString = FILETOSTR('c:\ftp\somast.txt')
*** Here you forgot to assign lcMyString to STRTRAN result
lcMyString = STRTRAN(lcMyString, [,",], [,,])
STRTOFILE(lcMyString, 'c:\ftp\somast.txt')

Borislav Borissov
 
Its a double quote enclosed in two single quotes and then just two single quotes. Like this, with spaces added:
' " ', ' '. Of course, with the spaces it wouldn't work.

Regards,
Jim
 
Borislav,
That's what I'm trying to do and assigning the variable to the strtran result was the piece I was missing! It works fine.

Thanks to all
Ed
 
No it isn't. Copy and paste the code in VFP editor and you'll see. See how many commas has the expression.

Borislav Borissov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top