Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting rid of carriage returns in memo fields
Message
De
22/08/1999 05:29:42
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
22/08/1999 00:06:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00256063
Message ID:
00256381
Vues:
31
>>Correct - the character is in the second expression is replaced with the >equivalent character in the third expression. STRTRAN() is needed when the >string that need to be found for replacement is more than 1 character or where >the replacement string for a given item is more than 1 character long, so that >if you only wanted to strip CR/LF pairs (CHR(13)+CHR(10)), or wanted to >replace each CHR(13) with the string "CARRIAGE RETURN", you'd have to use >STRTRAN(). For example, I use the followiung to strip down multiple linefeeds >to a single linefeed:
>
>>STRTRAN(test string, CHR(10) + CHR(10), CHR(10))
>
>>CHRTRAN() is better and faster in the case we're looking at, especially since >it only has to be invoked once, and does it's thing in a single pass.
>
>Mike, Ed ...
>
>We had thought of using something like the examples you mentioned for our application however we only wanted to remove leading spaces and carriage returns that occured before the first character. We didn't want to remove spaces or carriage returns elsewhere in the memo field if the user entered them.
>
>Is there a simple modification to the code samples you wrote that will handle removing leading carriage returns and leading spaces only?. If so I would love to use it and get out of the loop I wrote in a previous post.

If you're using VFP6, there's a function alines(). In VFP5 you can use WordNum(this.value, i, chr(13)+chr(10)) to chop it into lines. You could do something like this in editbox's .lostFocus:
n=alines(laRows, this.value)
lcOutValue=""
lOK2Copy=.f.        && this will be .t. when we've found first non-empty line
for i=1 to n
   if lOK2Copy
       lcOutValue=lcOutValue+chr(13)+laRows[i]         && just copy it as a new line
   else
      lOK2Copy=!empt(LTrim(laRows[i]))      && .t. when we find the first not empty line
      if lOk2Copy
         lcOutValue=LTrim(laRows[i])       && start with this line, left trimmed
      endif
   endif
endfor
this.value=lcOutValue

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform