Hi
I have several records in a FMP 11 database.
all records are basically the same except certain words
As I need to get rid of everything else but these particular words I tried to create some Scripts In FMP where
1 Go to the first record
2 Select the field I need to “clean up”
3 Insert the “Find-Replace” script step inserting the phrase I want to replace with “”
4 Select the replace and find option as in the FMP dialogue box
5 Select “all” as requested number of fields to work on (tried with forward and the other options but is the same)
Running the script everything works except the Find replace step.
However doing it manually:
1 Copy the text
2 Select the keys
3 entering nothing as a replacement text
4 selecting “all records and this specific field”
Everything works perfectly
Is there a way to run a regular apple script to do so?
The series of text I want to eliminate are as follows:
same number of chars, including spaces, commas, stops and CR
they are 5 or 6 phrases resulting from a form my students send me.
Is there a way to do so in Applescript?
Regards and thanks
Danwan
AppleScript: 2.3
Browser: Safari 533.17.8
Operating System: Mac OS X (10.6)
You could likely do this in FileMaker. I very rarely use the Find/Replace step. It looks easy to use; but it does not accept calculations as parameters (which almost everything else does), and it is dangerous.
The Replace command does accept calculations. But it is also a bit dangerous, as it processes the field in all records of the found set. Which may be what you want.
Alternatively you could use a Loop, with a simple Set Field. If you have FileMaker Advanced this allows you to watch it happen, 1 record at a time. So you can stop if it doesn’t work right.
There is NO “undo”, so you should always backup your file before doing any of this.
It sounds like you’re trying to:
See if one (or more?) of the values you want is in the field.
If so, put ONLY the value(s?) in the field; otherwise nothing
The functions to look for a value are either PatternCount (the field; the value), or Position.
(similar to AppleScript’s contains and offset.)
You’d then use Set Field [ the field; the value ]
If it is possible for multiple values to be in 1 field, you’d need to add them, likely return-separated. But you did not really say.
[Actually, once you get the calculation right, you can use it as an auto-enter by calculation, with [ ] Do not replace existing off. Then it will automatically do the clean up upon entry into the field.]
P.S. If you’re trying to always remove exactly the same text, then a Substitute ( the field; the text; “”) would do it. Would have to be exactly the same.
I said: P.S. “If you’re trying to always remove exactly the same text, then a Substitute ( the field; the text; “”) would do it.”
The Substitute command can be “chained”, and requires only 1 call (in later versions of FileMaker). To remove a series of text expressions (do them in the right order, if there is overlap, or you may change one too soon).
Substitute ( the field or whatever; [“some text”; “”]; [“other text”; “”]; [“more text”; “different text”] )
It is case-sensitive (few FileMaker functions are). There is also a Replace() function, but I seldom use it.
There are other useful functions for working with text. Filter() works on a character level. FliterValues() works with return-separated lists.