Getting left and right expression values
Stanley - stanlyn-com
stanley at stanlyn.com
Tue Apr 24 10:17:05 PDT 2012
Hi Chris,
> I know it's a few steps, but it does work.
Yes, but the main problem with the instr() function is you must be looking
for a known value (or pattern) and not a position. In this case you are
looking for the space, and of course if the string had more than one space
it would fail. It would also fail if the date and time was stored together
with no space. If you were saving the :'s as part of the time string, then
one could search for the :, but once againwe are looking for a value or
pattern, and many times they are not known.
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.
Thanks Stanley
-----Original Message-----
From: filepro-list-bounces+stanley=stanlyn.com at lists.celestial.com
[mailto:filepro-list-bounces+stanley=stanlyn.com at lists.celestial.com] On
Behalf Of Chris Sellitto
Sent: Tuesday, April 24, 2012 11:02 AM
To: filepro-list at lists.celestial.com
Subject: RE: Getting left and right expression values
> -----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.
_______________________________________________
Filepro-list mailing list
Filepro-list at lists.celestial.com
Subscribe/Unsubscribe/Subscription Changes
http://mailman.celestial.com/mailman/listinfo/filepro-list
More information about the Filepro-list
mailing list