Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Merging lines in a text file
Message
De
06/10/2014 11:52:37
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:
01608814
Message ID:
01608862
Vues:
43
>>>>>It is probably a Monday morning blind spot
>>>>>
>>>>>I want to create a text file where the headings all alphabetic are on one dbf
>>>>>
>>>>>and the detail to go under the headings is a mixture of text, numeric and dates on another dbf
>>>>>
>>>>>Can I copy the data from the first file to a text file and somehow append the data from the second file to the same text file?
>>>>>
>>>>>Thanks
>>>>>
>>>>>
>>>>>Colin
>>>>
>>>>Sure,
>>>>Check STRTOFILE() function and especially last parameter :-)
>>>
>>>Thanks can you give me example code
>>>
>>>one.dbf has the text headings
>>>
>>>two.dbf has the data which should appear in the text file under the headings
>>>
>>>Thanks
>>>
>>>Colin
>>
>>lcx = ''
>>lcDelim = ' '
>>sele one && Field cHeader for the headers
>>scan
>> lcx = lcx+alltr(cHeader)+lcDelim
>>endscan
>>lcx = left(lcx,len(lcx)-len(lcDelim))+0h0D0A
>>
>>sele two
>>scan
>> lcx = lcx+transform(Field1)+lcDelim
>> lcx = lcx+transform(Field2)+lcDelim
>> *..
>> lcx = lcx+transform(Fieldn)+lcDelim
>> lcx = left(lcx,len(lcx)-len(lcDelim))+0h0D0A
>>endscan
>>lcx = left(lcx,len(lcx)-2)
>>
>>strtofile(lcx,'Yourfile.ext')
>>
>>
>>something like this?
>>You can replace TRANSFORM with something mor meaningfull, also remove spaces etc.
>
>Very helpful - how do I put carriage return at and of each line

The 0h0D0A will add CR+LF where a line ends

the 0h adds a string literal in hex. You can change every string forward backward:
?'ABC'+0h44 && ABCD
?0h+'D' && 0h44
?'D'=0h44 && .T.
iow
CHR(13)+CHR10) is the same as 0h0D0A
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]
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform