Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File to str - I need a carriage return
Message
 
À
15/10/2014 04:00:59
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01609388
Message ID:
01609398
Vues:
32
>>>>>>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

There is only 1 field in each record - it's a memo field - I need the text file created by file to string to have a carriage return at the end of each line

So a file containing 12 records would have 12 lines in the text file each terminating with a carriage return

This is an example of the memo filed in the dbf

"B","4561234","10/06/2014","98.50","7220726","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","LONDON","","EC2A 1ER","GB","MAYER INTERNATIONAL LTD","","1 CABOT SQUARE","CANARY WHARF","INDIA","LO","E14","IN",""
Specialist in Advertising, Marketing, especially Direct Marketing

I run courses in Business Management and Marketing
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform