4 Replies Latest reply: May 15, 2014 9:58 AM by Gillian _ RSS

    Odd behavior with RTrim and LTrim

    Gillian _

      I'm having a very odd problem with the RTrim and LTrim functions.  I've got a text file exported (using Redwing) from PDF, and I need to trim the trailing and leading spaces from a field I have.  The field looks a bit like this:

       

      [font="courier"]       100.00      43          VISION

               80.00         I         CHKG

            540001.59      52     MED[/font][/quote]I'm trying to use the LTrim and RTrim functions to return something just like this:

       

      [font="courier"]100.00     43     VISION

      80.00       I        CHKG

      540001.59  52    MED[/font][/quote]I can't show it well here, but the text IS spaced such that trimming the left spaces will return such uniform formatting.  However, when I try to use LTrim (syntax: LTrim(Temp1) where Temp1 is the name of the field), it gives me text that looks like this:

       

      [font="courier"]100.00       43

      80.00

      540001.49    52[/font][/quote]It doesn't show the third section of the line, and doesn't always show the middle section of the line, with no apparent pattern.

       

      When I use RTrim:

       

      [font="courier"]100

      80

      540001[/font][/quote]The pattern seems to be that it's trimming everything from the right up to the decimal point in the number!

       

      Am I missing something simple here?  I have considered that what look like spaces may actually be characters of some kind, but I'm not sure how I could find out what they are, or even how to get rid of them.

       

      I hope this has made sense.  I'll try to clarify anything that isn't clear.

        • Odd behavior with RTrim and LTrim
          Steve Caiels

          Hi Gillian,

           

          The LTRIM(TEMP1) would do something similar to this if the field length of the calculated field was too low. Although I'd have expected to see the I on the 2nd example. The only explanation I can think of for the RTrim() example is that at some stage in the calculation, the field has been converted to a numeric with no decimal places. Are you also using the VAL() function, or are you just using LTrim() and RTrim()? I guess a sample file may be needed here. You may just have time to get one to US tech support.!! Or email one to me if you like, but it's 7pm on a Friday evening here, and I'm off to the pub!!

           

          Cheers

          Steve

           

          [size="1"][ July 18, 2003, 02:44 PM: Message edited by: Steve Caiels ][/size]

          • Odd behavior with RTrim and LTrim
            Grant Perkins

            Gillian,

             

            This is  really dumb thought from me but, it is Friday and that a day when I often forget to check simple things so, here goes.

             

            If I perform an Ltrim or Rtrim on a cut and paste version of your sample I get a new field of only 10 chars width default (using 5.02) which exhibits similar output to yours (but not identical). Have you tried changing the data and display widths for your resulting field(s)? I assume you are Ltrimming and the Rtrimming the result of that?)

             

            Silly thought but one to eliminate from the possibilities I suspect. Just in case Friday has got to you!      

             

            Grant

             

              Originally posted by Gillian:

            I'm having a very odd problem with the RTrim and LTrim functions.  I've got a text file exported (using Redwing) from PDF, and I need to trim the trailing and leading spaces from a field I have.  The field looks a bit like this:

             

            [font="courier"]       100.00      43          VISION

                     80.00         I         CHKG

                  540001.59      52     MED[/font][/quote]I'm trying to use the LTrim and RTrim functions to return something just like this:

             

            [font="courier"]100.00     43     VISION

            80.00       I        CHKG

            540001.59  52    MED[/font][/quote]I can't show it well here, but the text IS spaced such that trimming the left spaces will return such uniform formatting.  However, when I try to use LTrim (syntax: LTrim(Temp1) where Temp1 is the name of the field), it gives me text that looks like this:

             

            [font="courier"]100.00       43

            80.00

            540001.49    52[/font][/quote]It doesn't show the third section of the line, and doesn't always show the middle section of the line, with no apparent pattern.

             

            When I use RTrim:

             

            [font="courier"]100

            80

            540001[/font][/quote]The pattern seems to be that it's trimming everything from the right up to the decimal point in the number!

             

            Am I missing something simple here?  I have considered that what look like spaces may actually be characters of some kind, but I'm not sure how I could find out what they are, or even how to get rid of them.

             

            I hope this has made sense.  I'll try to clarify anything that isn't clear. /b[/quote]

             

            [size="1"][ July 18, 2003, 02:50 PM: Message edited by: Grant Perkins ][/size]

            • Odd behavior with RTrim and LTrim
              Gillian _

              redface.gif[/img] 

               

              Yep, the calculated field length seems to have been too low.

               

              I'm not at all sure why RTrim was doing what it did, but now that I've changed the field length to an acceptable size, the problem has gone away.

               

              Thanks!

              • Odd behavior with RTrim and LTrim
                Gillian _

                Originally posted by Grant Perkins:

                Just in case Friday has got to you!        

                 

                Grant[/b][/quote]It most certainly has.  I'm all ready for the weekend, right about now-ish.