## 1 LeftWords Function & 2 Time calculations

### 1 LeftWords Function & 2 Time calculations

DOMINIQUE WROTE:

Quote:> 1. I want to do a slight variation of the LeftWords function but I'm not
> sure if it's possible. I want to look for a specified text string, but
> then get the function to output the first word to the left of the search
> string. For example if I had a text string "I have 10 apples" and I
> searched for "apples" the function would return "10". The point is that
> the number in this case will vary, so I can't include it in the search
> string. Any ideas?

TIM:
It sounds like you need to use the function Abs (number)

1.  Create a file with these fields:

-- TextField (text)
-- GetNumber (calc, number) = Abs (TextField)

2.  Enter "I have 10 apples" in TextField.  GetNumber returns "10"

### 1 LeftWords Function & 2 Time calculations

A couple of questions from a newbie, so apologies if these have been
1. I want to do a slight variation of the LeftWords function but I'm not
sure if it's possible. I want to look for a specified text string, but
then get the function to output the first word to the left of the search
string. For example if I had a text string "I have 10 apples" and I
searched for "apples" the function would return "10". The point is that
the number in this case will vary, so I can't include it in the search
string. Any ideas?

2. I'm having a problem with a time calculation. I have 2 time fields,
and I'm trying to subtract a time interval from a specific point in
time. This works fine unless the calculation crosses over a 24hr period.
For example, if I have a time of 02:00 and I want to subtract 3 hours
from that, I get a reult of -01:00 rather than 23:00. Is there a way
around this?

Dominique

### 1 LeftWords Function & 2 Time calculations

> A couple of questions from a newbie, so apologies if these have been
> 1. I want to do a slight variation of the LeftWords function but I'm not
> sure if it's possible. I want to look for a specified text string, but
> then get the function to output the first word to the left of the search
> string. For example if I had a text string "I have 10 apples" and I
> searched for "apples" the function would return "10". The point is that
> the number in this case will vary, so I can't include it in the search
> string. Any ideas?

Say you have a global into which you will type the text you are looking
for.
Create calc fields:

NewEndText = Position(text; Global; 1; 1)-2   [Minus 2 to account for
the first letter of "apple" and the space before "apple".]

NewText = Left(text; NewEndText)
gives just "I have 10".

Final calc = RightWords(Newtext;1)

You could amalgamate these fields into one calc.

Quote:

> 2. I'm having a problem with a time calculation. I have 2 time fields,
> and I'm trying to subtract a time interval from a specific point in
> time. This works fine unless the calculation crosses over a 24hr period.
> For example, if I have a time of 02:00 and I want to subtract 3 hours
> from that, I get a reult of -01:00 rather than 23:00. Is there a way
> around this?

Not sure of my ground on this one, but you could have a further calc
field =

If(TimefieldCalc<0;86400+TimefieldCalc;TimefieldCalc)

It's + the calc because it will be a minus value as you have discovered.

--
Mire Black
Scotland

What ASCII characters can I use between words to join them as far as
the LeftWords, MiddleWords,RightWords functions are concerned.

ie  text_string = "Wordone~Wordtwo Wordthree Wordfour"
"Wordone*Wordtwo Wordthree Wordfour"
"Wordone\$Wordtwo Wordthree Wordfour"

RightWord (text_string,1) returns Wordone

I can put in some garbage and do it but

"WordoneXXXXWordtwo Wordthree Wordfour"

RightWord (text_string,1) returns WordoneXXXXWordtwo

I want it to return Wordone~Wordtwo

Thanks