Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create Table From Array
Message
From
14/09/1999 11:47:22
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
14/09/1999 11:10:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00264400
Message ID:
00264511
Views:
31
Tom,
Then you should hack with the result file using lowlevel io (not VFP6 where Filetostr, strtofile exist).
use mytable
copy to myFile type delimited with tab
=removequotes("myFile.txt")


function removequotes
lparameters tcFileName && Copy to .... with tab filename - existing file
handle=fopen(tcFileName,12)
lnSize = fseek(handle,0,2) && Get size
=fseek(handle,0,0) && Rewind to start
lcFile = chrtran(fread(handle, lnSize), ["], "")
=fseek(handle,0,0) && Rewind to start
=fwrite(handle, lcFile , lnSize)
=fchsize(handle, fseek(handle, 0,1)) && Set new size
=fclose(handle)

*This would remove the quotes. 
*But there is another version which also transfers memos.

use myTable
=_copyto("myFile.txt", chr(9))

function _copyto
LPARAMETERS tcOutFileName, tcDelimiter
#DEFINE TABULATE tcDelimiter
#DEFINE NL chr(13)
handle = fcreate(tcOutFileName)	&& Create copy file
SCAN				&& Start scan..endscan
  FOR ix = 1 to fcount()	&& Write field values
    =fwrite(handle, TypeConvert(ix) )
    IF ix < fcount()
      =fwrite(handle, TABULATE)
    ENDIF
  ENDFOR
  =fwrite(handle, NL)
ENDSCAN
=fclose(handle)

FUNCTION TypeConvert
  LPARAMETERS tnField
  lcType = type(field(ix))
  IF lcType # "G"
    luValue = eval(field(ix))
  ENDIF
  DO case
    CASE lcType = "D"
      lcValue = dtoc(luValue)
    CASE lcType = "T"
      lcValue = ttoc(luValue)
    CASE lcType = "N"
      lcValue = padl(luValue,20," ")
    CASE lcType = "L"
      lcValue = iif(luValue,"Yes","No")
    CASE lcType $ "M" && Replace paragraph marks with "~"
      lcValue = strtran(luValue, chr(13)+chr(10), "~")
    CASE lcType $ "C"
      lcValue = luValue
    OTHERWISE
      lcValue = ""
  ENDCASE
  RETURN alltrim(lcValue)
Cetin


>John:
>Now for part two. Once I create this table, I do some work on it and overwrite the text file with a COPY TO name DELIMITED WITH TAB (after making a backup of course). The help says I can stack WITH commands (i.e.; DELIMITED WITH BLANK WITH TAB) but it doesn't work. I need the resulting file to be tab delimited with no string delimiters (quotes around each field). Can you help with this?
>
>>I would generally agree, Cetin. But, sometimes, you have to use things you don't like :-)
>>>>>>THANKS!
>>>>>>Tom.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform