9 Replies Latest reply on Sep 18, 2013 9:44 AM by philmodjunk

# WordCount Problem

### Title

WordCount Problem

### Post

Hi Forum,

I have problem to find out how many words in my language list.

\$lang_List="SE-SF PF-PE SE"

WordCount(  substitute ( \$lang_list; " "; ¶)) = 5  ??   But I need it to be equal to 3 for my script logic.

I know WordCount will count the ampersand (&) and hyphen (-) characters for a beginning of a new word.

But

Getvalue(substitute("SE-SF PF-PE SE";" ";¶);1) =SE-SF

Getvalue(substitute("SE-SF PF-PE SE";" ";¶);2)=PF-PE

Getvalue(substitute("SE-SF PF-PE SE";" ";¶);3)=SE

Getvalue(substitute("SE-SF PF-PE SE";" ";¶);4) is Empty

Getvalue(substitute("SE-SF PF-PE SE";" ";¶);5) is Empty

Does it make sense?  If you say 5 words inside, why the 4th and 5th are empty and counted?

Thank you,

Jason

• ###### 1. Re: WordCount Problem

Words and values are not the same thing. GetValue is returning a value from a return separated list of values. That value could be one word or a 5,000 word paragraph, it will return everything between the returns.

Note that WordCount ( "SE-SF PF-PE SE" ) also returns the count of 5. changing the spaces into returns will affect the results returned by GetValue but does not change the total number of words counted by the WordCount function.

• ###### 2. Re: WordCount Problem

Hi Phil,

Thank you. but is there a way I can figure out how many ¶ inside a text?

Let's see there is a function f(text) which can tell me 2 ¶ inside the text, So I just need to run 2+1 times of GetValue to finish my loop.

Thanks,

Jason

• ###### 3. Re: WordCount Problem

ValueCount will return the number of VALUES inside the field just as WordCount returns the number of words. This will be one more value than there are returns unless there is a trailing return after the last value in your list--which is sometimes the case.

And Patterncount can count the exact number of returns.

• ###### 4. Re: WordCount Problem

Hi Phil,

Thank you very much. That is exactly what I am looking for.

Jason

• ###### 5. Re: WordCount Problem

Note that FileMaker has three sets of similar text functions. There's a set of character based functions, a set of word based functions and a set of value based functions. Often, if you know that a character based function exists, you can find similar word and value based functions with similar names and results. Example:  Middle, is character based and has corresponding MiddleWords and MiddleValues functions.

• ###### 6. Re: WordCount Problem

I found FileMaker missed a function GetWord(). You know we have GetValue(). Do you agree?

Thanks,

jason

• ###### 7. Re: WordCount Problem

MiddleWords ( Text ; WordPosition ; 1 )

Does that job for me.

MiddleValues, on the other hand, includes an extra Return after the last value and thus GetValue becomes the better option for values.

• ###### 8. Re: WordCount Problem

Thanks for your advice. Works great.  I guess I can make custom function GetWord() by using MiddleWords ( Text ; WordPosition ; 1 ).

Jason

• ###### 9. Re: WordCount Problem

That seems a lot of work for little benefit to me, but to each their own...

GetValue definitely isn't a member of the "matched set". There isn't a GetChar function either.