Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to strip out trailing blanks/CR/LFs from a stri
Message
 
 
To
20/07/2004 06:22:26
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00925773
Message ID:
00926044
Views:
15
Hi Fernando,

You got error message because you've double "=" sign in the expression.
cRem = = RTRIM(cSourceString, SPACE(1), CHR(10), CHR(13))
>
>There was yet another test to be made: with the VFP 9 rTrim() function as you suggested, and here it is. BTW, looking at VFP9's help file I couldn't find that syntax you've presented. How did you get to it? The second test rTrim() syntax gave me an error message when trying to use it.
>
>cTempSource= "        Test     of   " + chr(13) + Chr (10) + ;
>             "      char   removal  " + chr(13) + Chr (10) + ;
>                                        chr(13) + Chr (10) + ;
>             Space ( 5)               + chr(13) + Chr (10) + ;
>             Space (10)
>
>* Sergey Berezniker 1: VFP9 rTrim()
>
>cSourceString = cTempSource
>
>t1= Seconds ()
>
>For I = 1 To 100000
>    cRem = RTRIM(cSourceString,0, SPACE(1), CHR(10), CHR(13))
>EndFor
>
>Elap8 = Seconds () - t1
>
>* Sergey Berezniker 2: VFP9 rTrim()
>
>cSourceString = cTempSource
>
>t1= Seconds ()
>
>For I = 1 To 100000
>    cRem = = RTRIM(cSourceString, SPACE(1), CHR(10), CHR(13))
>EndFor
>
>Elap9 = Seconds () - t1
>
>MessageBox ("Sergey Berezniker 1: VFP9 rTrim():  " + Transform (Elap8) + Chr (13) + Chr (10) + ;
>            "Sergey Berezniker 2: VFP9 rTrim():  " + Transform (Elap9) )
>
>After 100,000 loops for each routine I got the following results:
>
>Sergey Berezniker 1: VFP9 rTrim(): 0.219
>Sergey Berezniker 2: VFP9 rTrim(): Error: Command contains unrecognized phrase/keyword.
>
>So the final score for all tests are:
>
>Gregory Adam (StripTrailing):      0.875
>Gregory Adam (StripTrailing2):     0.187
>Fabio Lunardon:                    0.203
>Alan Popow:                        3.938
>Mike Pratt:                        3.953
>Steve Gibson:                      2.015
>Sergey Berezniker 1: VFP9 rTrim(): 0.219
>Sergey Berezniker 2: VFP9 rTrim(): Error: Command contains unrecognized
>
>Regards,
>
>Fernando
>
>
>>In VFP9 you could use RTRIM() function
>>cString = RTRIM(cString,0, SPACE(1), CHR(10), CHR(13))
>>* or
>>cString = RTRIM(cString, SPACE(1), CHR(10), CHR(13))
>>
>>
>>
>>>
>>>What is the best/fastest way to remove trailing carriage returns/line feeds from a string?
>>>
>>>Example:
>>>
>>>cString = "This is what I want to keep!"                         + ;
>>>          Space (10) + Chr (13) + Chr (10) + Chr (13) + Chr (10) + ;
>>>          Space ( 1) + Chr (13) + Chr (10) + ;
>>>          Space ( 1)
>>>
>>>After execution of the routine, all trailing blanks/CR/LFs should be removed (last 18 characters removed, first 28 characters ketp).
>>>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform