Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File to str - I need a carriage return
Message
From
15/10/2014 04:00:59
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01609388
Message ID:
01609396
Views:
31
>>>>>I have created a dbf with a number of records each containing a long memo field with a long string - there are 2 types of records A and B
>>>>>
>>>>>When I convert this to a text file using file to string I need all B records to have a carriage return at the end of that line in the text file
>>>>>
>>>>>How can I do this
>>>>>
>>>>>I don't need a line feed character as well
>>>>>
>>>>>Thanks
>>>>
>>>>This is a bit a to wide question
>>>>assuming you will remember the CRLF discussion of yesterday.
>>>>
>>>>
>>>>SELECT yourTable
>>>>lcx = "" &&initial
>>>>SCAN FOR [expression that filters out record b]
>>>> TEXT to lcx TEXTMERGE NOSHOW ADDITIVE
>>>><<field1>>,sometconstant <<fieldn>>
>>>>
>>>> ENDTEXT
>>>>ENDSCAN
>>>>STRTOFILE(lcx,YourFileName)
>>>>
>>>>*or within the scan anything else that will build the string, we had examples yesterday.
>>>>
>>>>
>>>>other version
>>>>
>>>>SELECT yourTable
>>>>COPY TO YourFileName FOR [expression that filters out record b] TYPE SDF
>>>>*or
>>>>COPY TO YourFileName FOR [expression that filters out record b] TYPE CSV
>>>>
>>>>
>>>>also look for TYPE DELIMITED in the help
>>>>
>>>>or
>>>>
>>>>SELECT;
>>>> Cur1.*;
>>>> FROM YoruTable AS Cur1;
>>>> TO FILE YourFileName;
>>>> WHERE [expression that filters out record b]
>>>>
>>>>
>>>>thats not all possible, but it's a start.
>>>>
>>>>I while sooner or later need to move to some SQL Server anyway. would do something like
>>>>
>>>>*could be replaced for SQL Server w/o changing te cursor
>>>>SELECT;
>>>> Cur1.*;
>>>> FROM YoruTable AS Cur1;
>>>> INTO CurOutPut;
>>>> WHERE [expression that filters out record b]
>>>>
>>>>*this might be in some function that itself coud be replaced and be generic or what ever
>>>>lcx = "" &&initial
>>>>SCAN FOR [expression that filters out record b]
>>>> TEXT to lcx TEXTMERGE NOSHOW ADDITIVE
>>>><<field1>>,sometconstant <<fieldn>>
>>>>
>>>> ENDTEXT
>>>>ENDSCAN
>>>>*or something similar
>>>>
>>>>*final write
>>>>STRTOFILE(lcx,YourFileName)
>>>>
>>>>This gives fine control over the output.
>>>>
>>>>Lutz
>>>
>>>Sorry I made a mistake - all records need the carriage return
>>>
>>>Is there now a simple way of doing this?
>>>
>>>Thanks for your help
>>
>>so, first.
>>
>>Does the reord or the output of the records needs a CR?
>>
>>I assume the output, so:
>>
>>Just remove the clauses
>>
>>WHERE [expression that filters out record b]
>>*or
>>FOR [expression that filters out record b]
>>
>>
>>from the examples above.
>>
>>please note the FOR clause in the las example given is superfluous. It's all out of the SELECT.
>>
>>Lutz
>
>I file to string the whole table but EACH record needs a carriage return
>
>Sorry for the confusion
>
>Can you please give the the answer again to this as I am a bit confused myself
>
>Thanks
>
>Colin

Colin, beg your pardon, we need to come to a common language first.
It would be a bit more easy to me if you give an example like the file should be formated. Your question allows to much answers.
Then I can give you a one-example-answer and do not need to guess. Guessing is a pain because I'm never shure that I do not confuse my english. :)

like:
example
I need for all records: all fields of the table, in order of the table formated as:

filed1,field2,..fieldn
filed1,field2,..fieldn

there should be a CR / CRLF / LF at the end of line
/example
or
example
I need for all records: Field1 and Field 2 like:

filed1<tab>field2
filed1<tab>field2

there should be a CR / CRLF / LF at the end of line
/example

Lutz
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform