Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FF,LF and CR chars
Message
De
21/04/2015 12:19:00
 
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:
01618876
Vues:
37
>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

Are you saying that you're storing into a variable named "ff"?
#DEFINE _CR_  CHR(13)
#DEFINE _LF_  CHR(10)
#DEFINE _FF_  CHR(12)

* string value matches character
? m.ff == _FF_
? m.ff == _LF_
? m.ff == _CR_

* specified string is a substring
? _FF_ $ m.ff
? _LF_ $ m.ff
? _CR_ $ m.ff

* Index of character within string (0 if not found)
? AT(_FF_,m.ff)
? AT(_LF_,m.ff)
? AT(_CR_,m.ff)
Do be careful about CR and LF characters -- although the effect of CR followed by LF and the reverse (LF followed by CR) appears to give the same result (at least when you TYPE the contents of the file), the interpretation can differ when read by a program. Typical newline sequence for DOS style (and Windows) text file is CR followed by LF. If you have the reverse, some programs will have built-in assumption of CR followed by LF and could cause different effects:
- If it sees LF without linefeed, it may assume that the file is Unix style (where newline is specified by only a linefeed), so it changes LF as if it was CR+LF
- the following CR could be interpreted as being an additional newline -- either as beginning of one, or simply an additional one, so you might end up with "double-spaced" lines (i.e. you get inserted blank lines)
- if the CR was interpreted as beginning of a newline sequence, the next character could be "eaten" (assumed to be LF) -- so you lose the first character of the next line.

CR followed by LF would give the usual results if you try to TYPE the contents at the command line.
If you only have CR, the result of TYPE at the command line is all the lines overstrike each other
If you only have LF, the result of TYPE is subsequent lines appears "indented" -- with the first character of a line appearing in a column just to the right of the last character of the previous line.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform