Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FF,LF and CR chars
Message
De
21/04/2015 13:30:44
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:
01618860
Message ID:
01618880
Vues:
34
>>>My code stores a singe character to ff
>>>
>>>How do I test ff for FF, LF and CR characters
>>>
>>>Simple I know
>>>
>>>One of those days
>>>
>>>Colin
>>
>>in general $ or AT()
>>
>>lcString =`'ABCD'
>>?'A'$lcString
>>?'a'$lcString
>>?at('A',lcString)
>>?at('a',lcString)
>>
>>for CR,LF etc you can use CHR() or the 0h Syntax
>>
>>lcCHR = CHR(13)
>>lcCHR2=0h0D
>>?lcCHR=lcCHR2
>>
>>
>>For the codes see http://en.wikipedia.org/wiki/ASCII
>
>I have revised one line to IF chn=CHR(10) OR chn=CHR(13)
>
>But it is still not creating the blanks

The first thing is that you do not have an idea about the file format. Normaly one would know the type of line break.
So we do it in general
CLEAR
#DEFINE dcCRLF	0h0D0A
#DEFINE dcCR	0h0D
#DEFINE dcLF	0h0A

lcFile = "Your File Name"
lcData = ALLTRIM(FILETOSTR(lcFile))

*We do not have an idea what file type we have
*lets figure it out
*if the line breaks are mixed, not with this programm
*this would need some more things (or a loop, but this is boring)
DO CASE
 CASE dcCRLF$lcData
* this is a CRLF File
  lcLineBreak = dcCRLF
 CASE dcCR$lcData
* this is a LF File
  lcLineBreak = dcCRLF
 CASE dcLF$lcData
* this is a LF File
  lcLineBreak = dcCRLF
 OTHERWISE
*no idea, do nothing
  lcLineBreak = .NULL.
ENDCASE

*to format all files with CRLF replace .f. with .t.
IF .F. THEN
 lcLineBrkNew = dcCRLF
ELSE  &&.F.
 lcLineBrkNew = lcLineBreak
ENDIF &&.F.

IF !ISNULL(lcLineBreak) THEN
*we found something, lets do
 lcData = STRTRAN(lcData,lcLineBreak,lcLineBrkNew+' ')
ENDIF &&!ISNULL(lcLineBreak)
?lcData
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform