Getting left and right expression values
Stanley - stanlyn-com
stanley at stanlyn.com
Tue Apr 24 09:35:29 PDT 2012
Hi Bruce,
> You can get more indexes in version 5.7.
Just curious as to how many??
> Then: aa=errorExpression{"" '(aa should be undeclared)
> Then: ab(3,.0)=len(aa)
> Then: lcTime=mid(aa,(ab-"3"),"4"); lcDate=mid(aa,(ab-"12"),"8")
> Of course this assumes that in these expressions, that each ends with the
same date_time format.
Yes, this would work for a right() function, just a bit cumbersome...
As far as the seconds question, I need to revisit that as you reminded me of
the HMS edit that does have the seconds portion. In what I was doing??, it
was only returning the hours and minutes as 12:25, omitting the seconds
portion, and I was basically asking "where is the seconds".
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 Bruce Easton
Sent: Tuesday, April 24, 2012 1:47 AM
To: filepro-list at lists.celestial.com
Subject: Re: Getting left and right expression values
Stanley - I have a few more comments (inline). Bruce
On 4/23/12 11:59 PM, Stanley - stanlyn-com wrote:
> Hi Bruce,
>
> [..]
>
> In this datetime example, I am using the approach you suggested and if
> I need to do date math on it, I just assign it to a variable with the
> date datatype, like aa(yymd/,10).
>
>> There is no 'right' function in filepro
> This is a real bummer? Is there an easy way to get the time part of
> these 2 strings?
> 1. "Error 123, The prob is in customers... 20120423 0412"
> 2. "Error 33, Bad Index... 20120521 0322"
>
> It appears that a trim is implied, but the problem is knowing where
> the time part is. If we could read from the trimmed variable/field
> right side, then it would be easy...
For fields holding variable-length strings, you can always grab a specific
number of chars from the end of the string (assume below that
'errorExpression' is a long var that has already been set to either
#1 or #2 of your example above):
Then: aa=errorExpression{"" '(aa should be undeclared)
Then: ab(3,.0)=len(aa)
Then: lcTime=mid(aa,(ab-"3"),"4"); lcDate=mid(aa,(ab-"12"),"8")
Of course this assumes that in these expressions, that each ends with the
same date_time format.
>
>> why are you combining a date and time into one field
> Simple, it's all in one field, and if you had left and right functions
> then getting at any of its data is simple and fast and much easier to
> maintain than 2 separate fields. Also note that what I'm saying here
> is useful for any string and date time data types, as I previously
> mentioned it's easy to convert a string to a date or time types.
>
> Also, another reason is that I'm out of automatic indexes... As A-P is
> SEVERELY limiting...
Ah - well this would have to be THE reason for me not to have separate
fields for dates and times for whatever filepro file is storing the data for
this app, because otherwise, everything is more difficult than it needs to
be with respect to sorting and math. You can get more indexes in version
5.7.
>
> Is there any of getting seconds into the time part as in "11:25:50"?
I don't understand how this relates to the discussion above, but you can
have seconds stored in a field with either edit type 'TIME' or 'HMS'
depending on how you plan to use it (but where you want filepro to know that
it is a time field that can be sorted and operated on accordingly).
>
> 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 Bruce Easton
> Sent: Monday, April 23, 2012 11:14 PM
> To: filepro-list at lists.celestial.com
> Subject: Re: Getting left and right expression values
>
> Stanley,
>
> There is no 'right' function in filepro. filepro's 'mid()', as Ken
> said, can take care of all of your needs for extracting part of a
> string. You can also use a dummy or long-variable field declared with
> a specific length to effectively truncate a field at the desired point
(and give you a 'left'
> part):
>
> Then: declare dateportion(10,*)
> Then: dateportion = datetimefield
>
>
> Just curious, but possibly more importantly, why are you combining a
> date and time into one field? With filepro's turbo-charged,
> other-worldy abilities to sort and do math on dates and times as separate
and special
> data types, why ever do that? Maybe many years ago when, in
> filepro, you could not create auto indexes on non-contiguous fields,
but....
> Or maybe I misunderstood and you are not actually storing the data
> that way....
>
> Bruce
>
> Bruce Easton
> STN, Inc.
>
>
> On 4/23/12 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?
>>
>> Thanks, Stanley
>>
>>
>>
>>
>>
>>
>>
>> -----Original Message-----
>> From: Kenneth Brody [mailto:kenbrody at spamcop.net]
>> Sent: Monday, April 23, 2012 10:21 PM
>> To: Stanley - stanlyn-com
>> Cc: Filepro-list at lists.celestial.com
>> Subject: Re: Getting left and right expression values
>>
>> On 4/23/2012 9:49 PM, Stanley - stanlyn-com wrote:
>>> Hi,
>> [...]
>>> How do I get just the date part and/or the time part? In the other
>>> languages I use we have a left and right functions that returns
>>> values from the left or right as in:
>> [...]
>>> Also what about a function that would return a string starting at a
>>> known position and for x number of characters, such as
>>> lcString=substr(datetimefield, 7,6) where lcString would be equal to
>>> "4/23 2"
>>>
>>> I use this kind of stuff all the time in other languages and don't
>>> see any easy way of doing it in filePro.
>> [...]
>>
>> Use MID(), which is the equivalent of your substr() example.
>>
>> --
>> Kenneth Brody
>>
>> _______________________________________________
>> Filepro-list mailing list
>> Filepro-list at lists.celestial.com
>> Subscribe/Unsubscribe/Subscription Changes
>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>>
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
>
_______________________________________________
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