Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Export memo data in delimited text file
Message
From
28/09/2000 02:41:54
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/09/2000 13:59:26
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00421640
Message ID:
00421910
Views:
21
>How do I export and include data contained in memo data type fields ?


The way I know is lowlevel. Below is a routine doing that for TAB delimited files that I use to pass data to Excel or Word (this is intended to be compatible with all VFP versions so there is no transform, strtofile, filetostr etc) :
FUNCTION _CopyData
LPARAMETERS tcTableName, tcFieldList
#define TABULATE chr(9)
#define NL chr(13)+chr(10)
lcOldAlias = Alias()  && Save alias
SELECT &tcFieldList ;
  from (tcTableName) ;
  nofilter into cursor crsTemp  && Select recs into a cursor
IF reccount("crsTemp")=0
  USE in "crsTemp"
  RETURN
ENDIF
SELECT crsTemp
lnFields = fcount()
lcTempFileName = "X"+sys(2015)+".tmp"
handle = fcreate(lcTempFileName)  && Create a temp file
&& Write header line
FOR ix = 1 to lnFields
  =fwrite(handle, field(ix))
  IF ix < lnFields
    =fwrite(handle, TABULATE)
  ENDIF
ENDFOR
=fwrite(handle, NL)
SCAN    && Start scan..endscan
  FOR ix = 1 to lnFields
    =fwrite(handle, TypeConvert(ix) ) && Write converting all to char type
    IF ix < lnFields
      =fwrite(handle, TABULATE)
    ENDIF
  ENDFOR
  =fwrite(handle, NL)
ENDSCAN
=fclose(handle)
USE in "crsTemp"
IF !empty(lcOldAlias)
  SELECT (lcOldAlias)
ENDIF
return lcTempFileName

FUNCTION TypeConvert && Convert VFP data types to char
LPARAMETERS tnField
lcType = type(field(ix))
luValue = iif(lcType='G','',eval(field(ix)))
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
Ç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