Getting left and right expression values
Chris Sellitto
sellich at guaranteedreturns.com
Tue Apr 24 08:01:43 PDT 2012
> -----Original Message-----
> Subject: Re: Getting left and right expression values
>
> On 4/23/2012 10:30 PM, Stanley - stanlyn-com wrote:
> > Hi Ken,
> >
> >> Use MID(), which is the equivalent of your substr() example.
> > OK, yes I see that, and thanks...
> >
> > Now, what about the left and right functions? How would you get those
> > parts out of a string?
> [...]
>
> "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.
>
> --
> Kenneth Brody
To elaborate on what Ken said for "right()". If the "space" between the two values is a constant, as stated in your
earlier example (2012/04/23 21:25), then you can do something like this....
Then: LL = len(var) 'in this case LL would be 16
Then: aa(2,.0) = instr(var," ","1") 'this gets the position of the "space" within the string variable (starting at position 1)
aa would equal 11.
Knowing the full length of the string using len(), then we could do the following...
Then: rr = mid(var,(aa+"1"),(LL-aa)) 'this will set rr equal to "21:25"
I know it's a few steps, but it does work.
More information about the Filepro-list
mailing list