AnsweredAssumed Answered

leftwords and rightwords eliminating punctuation

Question asked by amixer on Mar 19, 2009
Latest reply on Mar 20, 2009 by amixer

Title

leftwords and rightwords eliminating punctuation

Post

Hello all, I'm totally new to the forum but have been dabbling in Filemaker Pro for several years.  I'm trying to write a script that will parse a phrase of text, determine how many words are in the phrase, and insert a carriage return halfway through, creating 2 lines from the one phrase.  Here's the problem I'm having:  I'm using Leftwords and Rightwords to select the different parts of these phrases.  The output of these two functions is eliminating all the punctuation in my original phrase, which is unacceptable.  I'm sure there's an easier and correct way to do this that will preserve my punctuation.  Can anyone lend a hand?  Here's the script I wrote to do what I was hoping to do:

 

put hard CR in long line
Paste [ subtitle::Subtitle entry ]
[ Select ]
Set Field [ subtitle::z; WordCount ( subtitle::Subtitle entry ) ]
Insert Calculated Result [ subtitle::Text holder; LeftWords ( subtitle::Subtitle entry ; Round ( subtitle::z/2 ; 0) )  & "¶"  & RightWords
( subtitle::Subtitle entry ; subtitle::z - Round ( subtitle::z/2 ; 0) ) ]
Copy [ subtitle::Text holder ]
If [ (Length ( subtitle::Subtitle entry ) = (Length ( subtitle::Text holder ))-1) and WordCount ( subtitle::Subtitle entry ) = WordCount
( subtitle::Text holder ) ]
Set Field [ subtitle::Pass; "PASSED" ]
Clear [ subtitle::Fail ]
[ Select ]
Else
Set Field [ subtitle::Fail; "FAIL" ]
Clear [ subtitle::Pass ]
[ Select ]
End If 

 

    I paste the long line in the field Subtitle entry

then I set the field z = to the word count of that line 

Then I insert a calculated result into the field Text holder, taking LeftWords of the field Subtitle entry, and using the word count, z, divided by 2 and rounded to the next whole number, then inserting a carriage return and then taking right words of z- (round(z/2)).   Finally I copy the result with the carriage return and run a comparison of that field to the field subtitle entry to make sure they are the same.  The comparison requires the word counts to match and the character counts to match (I subtract the carriage return from the text holder to account for the extra character).  Frustratingly, all the punctuation disappears (commas, periods the works) in the text holder once I've split the text.  Any help would be appreciated! Thanks,

-Andrew 

 

 








Outcomes