# macOS Services to help write FileMaker code

**URL:** <https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261>\
**Category:** Tips and Techniques\
**Created:** [August 23, 2020, 1:47am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261 "2020-08-23T01:47:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [August 23, 2020, 1:47am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/1 "2020-08-23T01:47:08Z")

</div>

You can use macOS Services (built with Automator.app) to help write FileMaker code.  
(There are many good posts on the internet on what macOS Services are and how they work.)  
Files go in the ~/Library/Services/ folder.  
Use at you own risk!

You can see a movie with the 2 examples (shown and downloadable below) in this tweet...

> <https://twitter.com/tonywhitelive/status/1295395323435716609>

FM\_Grey\_8\_wrap\_string\_2020-08-20.workflow [download](http://www.twdesigns.com/freebies/macOS-Services-to-help-write-FileMaker-code/FM_Grey_8_wrap_string_2020-08-20.workflow.zip)

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/1X/59e16bca5f9c01514c8d21d388eb81b9dc89ee8b.png)

FM\_Bold\_wrap\_string\_2020-08-20.workflow [download](http://www.twdesigns.com/freebies/macOS-Services-to-help-write-FileMaker-code/FM_Bold_wrap_string_2020-08-20.workflow.zip)  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/1X/aa5cb398ee3898c88d6922255c4ae16020bef018.png)

What other macOS Services would be helpful in writing FileMaker code?

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [August 23, 2020, 11:06pm UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/2 "2020-08-23T23:06:01Z")

</div>

Nice idea.

I use text shortcuts via the Keyboard-\>Text prefs pane. The one I use most often is "exitloop", which expands to "let($i = $i+1; $i \> $n)".

Could your method place a complete clipping of script steps onto the clipboard or paste it into the script workspace? In this example I'd use

```
Set Variable [$n ; Get( FoundCount )]
Set Variable [$i ; 0]
Loop
Exit Loop If [let($i = $i+1; $i > $n)]
...
Exit Loop
```

---

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [August 24, 2020, 2:27am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/3 "2020-08-24T02:27:08Z")

</div>

> [@Malcolm](#):
>
> Nice idea.
> 
> I use text shortcuts via the Keyboard-\>Text prefs pane. The one I use most often is "exitloop", which expands to "let($i = $i+1; $i \> $n)".
> 
> Could your method place a complete clipping of script steps onto the clipboard or paste it into the script workspace? In this example I'd use

Thank you.

Pasting in "a complete clipping of script steps" is a different tool/technique.

We used to sell a tool that we call Script Building Blocks...  
[http://www.twdesigns.com/products/index.php](http://www.twdesigns.com/products/index.php)  
..that allowed pasting in "a complete clipping of script steps".

We would bring a more modern version of Script Building Blocks (and its siblings) back to market if there was enough interest.

Not sure what is currently available in the "a complete clipping of script steps" market?

In the meantime, macOS services are free!

Hope that helps.

---

<div class="post-metadata">

**Author:** ![jormond](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@jormond](https://the.fmsoup.org/u/jormond)\
**Post date:** [August 24, 2020, 4:13am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/4 "2020-08-24T04:13:34Z")

</div>

Geist's Generator is free also. You can create your own "Generators". 🙂[karbonfm/karbon\_Generator.fmp12 at 74cd1956f53f18cd583ec92b7d70565cb526a138 · karbonfm/karbonfm · GitHub](https://github.com/karbonfm/karbonfm/blob/74cd1956f53f18cd583ec92b7d70565cb526a138/KarbonFM/karbon_Generator.fmp12)

---

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [August 24, 2020, 8:59am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/5 "2020-08-24T08:59:59Z")

</div>

Have you seen the extensions you can define yourself for Script Workspace?

- [Custom context menu commands for FileMaker ScriptWorkspace](https://www.mbs-plugins.com/archive/2019-10-19/Custom_context_menu_commands_f/monkeybreadsoftware_blog_filemaker)
- [SyntaxColoring.AddContextMenuCommand](http://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml)
- [Add a search and replace command for FileMaker Script Workspace](https://www.mbs-plugins.com/archive/2019-11-14/Add_a_search_and_replace_comma/monkeybreadsoftware_blog_filemaker)
- [Insert snippet for FileMaker on Windows](https://www.mbs-plugins.com/archive/2019-11-20/Insert_snippet_for_FileMaker_o/monkeybreadsoftware_blog_filemaker)

---

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [December 31, 2021, 5:55pm UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/6 "2021-12-31T17:55:39Z")

</div>

If you are using ~ as the Let vars prefix, these 2 .workflows can help debugging.

1/2

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/6/69c402fb0eb745176d1fe747addd0306b6f7805d.png)

2/2

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/6/6a0010adaea4f745d9d1bffad4f4f30a230a2149.png)

Lot of other uses for macOS Service \> search\_and\_replace

**on**  **run** {input}  
**set** search\_string **to**"~"  
**set** replace\_string **to**"$$"

**set** text\_after **to** search\_and\_replace(input **as** _string_, search\_string, replace\_string)  
**return** text\_after  
**end**  **run**

**on** search\_and\_replace(text\_before, search\_string, replace\_string)  
**set** current\_delims **to** AppleScript's text item delimiters  
**set** AppleScript's text item delimiters **to** search\_string  
**set** text\_items **to**  **every** _text item_ **of** text\_before  
**set** AppleScript's text item delimiters **to** replace\_string  
**set** text\_after **to** text\_items **as** _string_

**set** AppleScript's text item delimiters **to** current\_delims  
**return** text\_after  
**end** search\_and\_replace

---

<div class="post-metadata">

**Author:** ![DanShockley](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@DanShockley](https://the.fmsoup.org/u/DanShockley)\
**Post date:** [January 9, 2022, 10:51pm UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/7 "2022-01-09T22:51:58Z")

</div>

Another set of free code is FmClipTools, which is found at [GitHub - DanShockley/FmClipTools: Tools for converting, modifying, and saving FileMaker Pro clipboard objects. Coded in AppleScript.](https://github.com/DanShockley/FmClipTools)  
Disclaimer: I built most of this, and hope people find it useful.

---

<div class="post-metadata">

**Author:** ![jwilling](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/jwilling/32/256_2.png) [@jwilling](https://the.fmsoup.org/u/jwilling)\
**Post date:** [January 10, 2022, 1:20am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/8 "2022-01-10T01:20:28Z")

</div>

@DanShockley thanks so much for your work on FMClipTools. It's, by far, the tool I use most, and I'm not even sure I could stand to use FileMaker without them anymore. I also know first-hand multiple other people who use them.

I quietly evangelize about your library whenever I get the chance.

Not sure I've ever thanked you directly, but you've really revolutionized the way I work.

---

<div class="post-metadata">

**Author:** ![DanShockley](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@DanShockley](https://the.fmsoup.org/u/DanShockley)\
**Post date:** [January 11, 2022, 1:53am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/9 "2022-01-11T01:53:32Z")

</div>

That's good to hear! Thanks for the encouragement. I enjoy building things that make other people's lives easier.

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [January 11, 2022, 2:33am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/10 "2022-01-11T02:33:54Z")

</div>

I've just downloaded them and installed them in the "no third-party" configuration. I'm not getting anything back when I run them. I do see the gear cog appear in the menu momentarily.

Is there a trick that beginners need to learn, or am I just doing it wrong?

Mac OS Big Sur FMP 19.4

---

<div class="post-metadata">

**Author:** ![jwilling](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/jwilling/32/256_2.png) [@jwilling](https://the.fmsoup.org/u/jwilling)\
**Post date:** [January 11, 2022, 3:06am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/11 "2022-01-11T03:06:24Z")

</div>

I can't comment on "no-third party" configuration, but IMHO a third party tool like TextExpander/Typinator really enhances FMClipTools. [This video](https://www.youtube.com/watch?v=RwptPsFpiP0) desperately needs a re-record (I didn't originally intend it for public), but it shows some of the potential and how to start integrating it with TextExpander.

---

<div class="post-metadata">

**Author:** ![DanShockley](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@DanShockley](https://the.fmsoup.org/u/DanShockley)\
**Post date:** [January 13, 2022, 2:17am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/12 "2022-01-13T02:17:29Z")

</div>

If they worked properly, most of those AppleScripts won't display anything, they just modify the clipboard.  
For example, the file "fmClip - Clipboard FM Objects to XML.applescript" just modifies the clipboard so that it contains the text (XML) representation of whatever FileMaker objects you just copied into the clipboard.  
So, if you go into a FileMaker script, copy a few script steps (or a whole script, or multiple scripts), then run that AppleScript from the Scripts menu in the menubar, your clipboard will now (also) contains text XML that you can paste into a text document.  
Some of the AppleScripts DO present a simple interface. For example, if you run "fmClip - Replace String in FM Objects.applescript", it will ask you for a search string and then a replacement string, which it will then use to modify the FileMaker objects in the clipboard. You could use this to rename a variable in a FileMaker script:

1. In your FileMaker script, select all steps.
2. Copy those steps to the clipboard.
3. Run "fmClip - Replace String in FM Objects.applescript"
4. Use the old variable (I recommend including the $, for reasons I'll explain below) as the SearchFor string.
5. When it asks for the Replace With string, type in your new variable name (make sure to include the $ symbol, again).
6. Back in your FileMaker script, delete the selected steps.
7. Paste the modified clipboard objects - wherever the old variable name was will now have the new variable name.

One IMPORTANT thing to know is that this replacement does not do any preservation of the XML infrastructure in the objects. So if, for example, you searched for "Field" and changed it to "Bartholomew", the objects in the clipboard would NOT be valid, and either wouldn't paste into FileMaker, or would paste broken/corrupted objects. I haven't tested what kinds of problems that could cause. So, as I suggested above, you really want to make sure you only SearchFor something that is _yours_, as in, VERY unlikely to be a string that would be contained in the rest of the XML.  
If you want to do a more cautious search-and-replace, you could use "Clipboard FM Objects to XML", paste the result into a decent text editor like BBEdit or Sublime, search for the thing you want to change and make sure the only matches are the things you INTEND to change, then search-and-replace in the text editor. Then, you could copy the modified text and use "Clipboard XML to FM Objects" to convert back to FileMaker objects you can then paste back into FileMaker. That's more steps than the "Replace" AppleScript, but can help if you aren't yet sure what kinds of things the XML contains and you don't yet know what to avoid changing.

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [January 13, 2022, 4:00am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/13 "2022-01-13T04:00:44Z")

</div>

Thanks for the explanations @DanShockley. It's working now, and I'm not sure what changed. I switched FMP off and on again.

I can imagine that doing replacements of TO names would be one of the first uses. Having checked the XML code that is produced I started thinking about how to ensure that I only act on the "correct" objects. Now all I can think of is Buster Keaton.

---

<div class="post-metadata">

**Author:** ![kupietz](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kupietz](https://the.fmsoup.org/u/kupietz)\
**Post date:** [March 12, 2024, 3:59am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/14 "2024-03-12T03:59:46Z")

</div>

Hey, somebody elsenet suggested I post this here.  
A couple of years ago I brought Debbie Fuchs's old PERL FM Calculation Formatter up to date with current FM syntax and packaged it as a MacOS System Service using an Automator workflow for easy availability within FileMaker or any other app. Available at [https://github.com/kupietools/\_format-FM-calc-automator-workflow](https://github.com/kupietools/_format-FM-calc-automator-workflow). Now you can select any calculation text (even outside of FileMaker, in text editors, etc.) and in a single mouseclick convert it from this:

`Let(textNoRangeMove=Substitute(alerts::full text display;["higher range, xu";"__"];["lower range, xo";"__"]); If((Position( position_prognosis_at_import ;"Bullish";1;1)>0 and Position (textNoRangeMove;" xu ";1;1)>0 ) or (Position( position_prognosis_at_import;"Bearish";1;1)>0 and Position (textNoRangeMove;" xo ";1;1)>0 );1;""))`

to this:

```auto
Let (
     textNoRangeMove =
     Substitute (
          alerts::full text display ;
          ["higher range, xu" ; "__"] ;
          ["lower range, xo" ; "__"]
     ) ;
     If (
          (
               Position ( position_prognosis_at_import ; "Bullish" ; 1 ; 1 ) >
               0 and Position ( textNoRangeMove ; " xu " ; 1 ; 1 ) > 0
          ) or
          (
               Position ( position_prognosis_at_import ; "Bearish" ; 1 ; 1 ) >
               0 and Position ( textNoRangeMove ; " xo " ; 1 ; 1 ) > 0
          ) ;
          1 ;
          ""
     )
)
/* Formatted with _Format FM Calc.workflow. Service based on Calculation_formatter.pl © 2008 by Debi Fuchs <debi@aptworks.com> and released under the GNU license. Debugged, modified, updated, and repackaged as a service by Michael Kupietz <consulting-fmsvc@kupietz.com> https://kupietz.com. Updated again at tremendous risk and great personal expense for nicer formatting in 2017. Released under GNU license, see source code for details. Be excellent to each other. */

```

That credit block always appears at the end, but obviously you're free to just remove it, it's just a text comment. (edited)

---

<div class="post-metadata">

**Author:** ![Glitchtraker](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@Glitchtraker](https://the.fmsoup.org/u/Glitchtraker)\
**Post date:** [March 12, 2024, 8:38am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/15 "2024-03-12T08:38:39Z")

</div>

Free version of MBS has a calculation beautifying tool

---

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [March 12, 2024, 9:47am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/16 "2024-03-12T09:47:22Z")

</div>

Yes, please check our ƒ button in the calculation dialog: [Goodies 37: Format button](https://www.monkeybreadsoftware.com/filemaker/SyntaxColoring/37-Formatbutton.shtml)

or the [SyntaxColoring.FormatCalculation](https://www.mbsplugins.eu/SyntaxColoringFormatCalculation.shtml) function for calculations stored in fields. See our example files:

- [Utility functions/Evaluate](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Evaluate.shtml#4ScriptAnchor_)
- [Utility functions/FileMaker Custom Functions](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/FileMaker%20Custom%20Functions.shtml#8ScriptAnchor_)
- [Utility functions/Formula Formatting](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Formula%20Formatting.shtml#1ScriptAnchor_)

 ![FormatButton3](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/0/0fd1338dd85b40f3e68f5ff2cba90c33e43b28ca.jpeg)

---

<div class="post-metadata">

**Author:** ![kupietz](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kupietz](https://the.fmsoup.org/u/kupietz)\
**Post date:** [March 13, 2024, 4:13am UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/17 "2024-03-13T04:13:40Z")

</div>

> Free version of MBS has a calculation beautifying tool

And nag screens. And isn't open source. And isn't a MacOS Service per the thread topic, so doesn't work outside of FIleMaker (like, in text editors or web forms.)

---

<div class="post-metadata">

**Author:** ![Glitchtraker](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@Glitchtraker](https://the.fmsoup.org/u/Glitchtraker)\
**Post date:** [March 13, 2024, 10:21pm UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/18 "2024-03-13T22:21:10Z")

</div>

no nag screen at all

---

<div class="post-metadata">

**Author:** ![barefoot](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/barefoot/32/2553_2.png) [@barefoot](https://the.fmsoup.org/u/barefoot)\
**Post date:** [March 18, 2024, 10:43pm UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/19 "2024-03-18T22:43:23Z")

</div>

Hello and thank you for your offer @DanShockley. Is there any literature or online training offered how I could learn these promising tools?

---

<div class="post-metadata">

**Author:** ![DanShockley](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@DanShockley](https://the.fmsoup.org/u/DanShockley)\
**Post date:** [August 5, 2024, 10:10pm UTC](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261/20 "2024-08-05T22:10:58Z")

</div>

There isn't any real training for using this, although there are some videos out there. Matt Petrowsky did a video on YouTube for ISO FileMaker Magazine showing how to use FmClipTools with a product called BetterTouchTool to easily work with FileMaker objects: [https://www.youtube.com/watch?v=oqj12X85zIg](https://www.youtube.com/watch?v=oqj12X85zIg)  
That includes a bunch of examples of how/why you might want to use something like this. You could manually do (at least some of ) the steps that BTT does yourself by copying an object, then running the FmClipTools "fmClip - Clipboard FM Objects to XML.applescript" script from the AppleScript menu. But, it's often really helpful to get a macro utility like BetterTouchTool, Keyboard Maestro, or Raycast, when it comes to running the various scripts included in the (free) FmClipTools.

[Next page](https://the.fmsoup.org/t/macos-services-to-help-write-filemaker-code/1261.md?page=2)
