Getting left and right expression values
Bruce Easton
bruce at stn.com
Tue Apr 24 11:19:25 PDT 2012
On 4/24/12 1:37 PM, Kenneth Brody wrote:
> (Top-posting fixed.)
>
> On 4/24/2012 1:17 PM, Stanley - stanlyn-com wrote:
> [...]
>>> "left()" is simply "mid()" starting at position 1.
>>>
>>> "right()" is a smidge more involved, but you can use len() to get the
>>> length of the field, and use length-n as the mid() starting position to
>>> get the rightmost "n" characters.
> [...]
>> Also Chris, here we have been talking about date and time values, but
>> there are many other places that this right() function stuff could
>> really be your friend. I too did not see it way back when I was doing
>> only fp. It was only when the other languages introduced them to me that
>> I say a much bigger picture.
> [...]
>
> As I stated above:
>
> To get the left-most "Num" characters from field "Field":
>
> mid(Field,"1",Num)
>
> To get the right-most "Num" characters from field "Field":
>
> mid(Field,len(Field)-Num,Num)
>
As I said in my reply early this am, this is the approach I would take
to get the last nn chars of a string, BUT, the example above is
a bit muddy. If you look at my example you will see that the middle
argument should be "1" less than the last argument (the last being
the number of chars you want returned). Also, I pointed out that it
is important that the argument to the len() function not simply be
a reference to a real or declared field, but should be an undeclared
field, otherwise you would always be starting from the last blank
space of the maximum position declared for the field.
So the example above would better be stated as:
Then: fd=Field{""
Then: rightPortion = mid(Field,len(fd)-(Num-"1"),Num)
More information about the Filepro-list
mailing list