14 for 14: Working with the Script Workspace

By Daniel Wood, 19 May 2015

What the Script Workspace looks like

Below is our reference image of the script workspace that we will use in the article, just click on it to enlarge.

1. Running a Script

These two buttons allow you to either run the selected script directly, or to run the selected script in the debugger. Being able to run direct in debugger is a great new feature and saves you having to open and close the debugger while working on a script.

 

The + button is for creating a new script. The new script is placed underneath the selected script (if any) otherwise it is placed at the bottom of the list of scripts.

    

2. Working with the Scripts Menu

The script workspace is divided into three main sections. The first we will deal with is called the Scripts Menu and this always appears as the left-most section.

The first button is for showing/hiding the "Show in Scripts Menu" checkbox. When ticked, a script appears in the scripts menu. This button is not for setting this checkbox, merely to show or hide it.

The next icon is for creating a script folder.

The last icon is for adding a separator. In the Script workspace, separators are no longer blank scripts, they are actual separators.

    

3. Script Search

This is for locating a specific script or scripts in your list. The search works in the same way as previous versions - it will search from any point in the script name but only sequentially. In the screenshot above we have scripts named Script A through Script D.

A search for "Script" will find all scripts. A search for "Script A" only finds that script.  A search for "ript A" will also find this script.

It is important to note this search differs from the way the script workspace and data viewer now carries out auto-complete on your text, you can learn more about these in other 14 for 14 articles

Folders are also shown in search results for the matching script.

   

4. Script List

The list of scripts will show folders and script names. We have already covered the show in scripts menu checkbox.

There are two other icons that can appear beside a script:

 This icon indicates the script is run with full access privileges

 This icon indicates the script is in an unsaved state.

  

5. Open Scripts

There is more to this one than meets the eye. The script workspace now has tabbed scripting meaning no longer will you have separate windows for open scripts.

Now, there are some interesting things to note about how the tabs work.  To demonstrate this lets start with no scripts selected:

Without a script chosen we get a nice icon of a script, how lovely.

Now lets single click on a script. Note here single as opposed to double click.

When a single script is chosen using a single left-mouse click you'll notice the script name appears in blue text.  The blue indicates that this script is the "active" script, and the one that we shall call "unlocked".

If you now click through other scripts using a single click, this will change the active unlocked script to the one you choose. The end result is only one script tab open at any given time.

Now lets go back to nothing selected and this time we will double click the same script:

The script tab is now entirely filled blue as opposed to the text blue.  A blue tab indicates the active tab. In this case because we double-clicked Script C it is now locked into its own tab. If we now select another script, we will open that in a new tab, with Script C now locked into its own tab:

Script B is now the active tab, but because we single-clicked script B to open, it is not locked to its own tab, and choosing another script will replace Script B with the new script.

This will be an important distinction to learn. In situations where you want to keep a script open in the workspace remember to double-click. If you do not need it locked single-click instead.

You can also still open scripts in their own standalone windows if you need to. This is not a shortcut feature, nor is there a button for it. You can access this via the contextual menu or the View menu while in the script workspace:

Note also the feature to select scripts in the scripts pane. This is useful if you have lost your context in the scripts list, for example if you have searched for another script in the mean time.

You can directly edit a scripts name by double-clicking its open tab:

  

6. Scripting Area

This is where the core of your scripting occurs. There are a number of great features here to help you write scripts fast.

One of these is auto-completion of script steps you type. This is covered in a separate 14 for 14 article where we give you all the shortcuts you can enter to enter specific script steps.

One thing you may notice first is there is some colour now to scripts. Colour can be defined for the following:

The above menu is accessible via the View -> Syntax Coloring... menu.

This script step has been disabled, but how do we disable steps? In FileMaker 13 there used to be a big disable button at the bottom of the script, but this is now gone.

The answer is to use a shortcut key, this is by far the quickest way. On a mac the shortcut is cmd+/ ,  on windows this is ctrl+/ .  You can use this to toggle enabled/disabled.  The option is also available via the Edit menu.

A blue line indicates that line is selected. How might we go about inserting a blank line into a script? In the example above lets say we want to put a blank line between these two steps.

The answer is simply the return key.... with a couple of gotchas to look out for.  A script step may be selected such as above, but there is a difference between a selected line, and an active script step.  When no step is active, the return key will create a blank line.

We can now also define whether to insert a blank line below or above the selected line. Hold the shift key with return to insert a line above the selected line.

Back to active steps. How can we tell if a script step is active? The surefire giveaway for most steps is either the settings cog icon appears blue, or any part of the line appears in a blue outline:


Both of the above steps are considered active. For active script steps the return key does not create a blank line but has the action of activating the step. This normally means either toggling a setting, opening the script step setup, opening a popup menu, or directly entering the step for data entry as is the case with an IF script step.

Initially this may cause the greatest source of frustration for you when trying to work with scripts. More often than not once you finish setting up a script step your next action is to insert a blank line, however your script step may still be active in which case you will go back into its settings.

There are two ways to resolve this issue.  The first is to use  the command modifier key with return (ctrl on windows). By using cmd+return, this will always insert a blank line beneath your active script step.

Another way we have uncovered during development is to simply save your script using cmd+S.  Saving a script will deactivate any active line.

    

Working with Script Step Settings

Once you have an active script step, return generally will open its settings in whatever form that may take. For control steps such as IF and LOOP it will depend on what is visually the active element of the step:

These steps have two possible active elements - the direct data entry component, or the Fx button which will open the calculation engine. The great thing about this script step in 14 is you can directly enter the code for a basic IF statement without the need to enter the calculation engine.  The tab or arrow keys can be used to toggle between the active areas of the step, and the return or space bar will activate that area.

We won't cover all variations on steps but suffice to say the vast majority of script steps will no longer require the user to reach for the mouse to setup which is great.  There are still some steps that are going to require you to reach for the mouse, such as Set Variable, or set field (if you need to specify via calculation) or the setup of a Custom Dialog. We think these will slowly become a thing of the past and in future everything will be mouse free.

   

Knowing when to use space bar versus return

Not all script steps work quite the same, and different steps have different amounts of settings. Sometimes you will find using the space bar to setup a step is much faster than return. We will use the common "Set Field" step as an example here.

First thing we do is type "set f" followed by return to create the step:

The step is selected, and the settings icon is activated. This means we can use the return or spacebar to open the settings:

For all intents and purposes it looks like the 'specify target field' option is selected. It is, but the return key will dismiss the settings popover we are looking at, which is not what we want.

Instead, the spacebar more often than not will open the selected settings area, and from there we can setup the target field (albeit having to reach for the mouse most likely!)

 

Once we select the field, we are presented with the above. Now it looks like no setting is highlighted so what do we do?  Well, return key will dismiss the dialog so that's no good.  The spacebar does nothing because no setting is chosen.

In this instance arrow keys become our most useful keys. A down arrow press will reselect the specify field option. Pressing down a second time selects the calculated result option, and then spacebar will open it.

  

While it may seem odd, we guarantee you will get into the habit of using a combination of return, space and arrow keys to navigate these various steps with ease, it just takes a little practice!

What about comments? Well in 14 a comment is still a script step, but it is very easy to add. simply enter a hash symbol to directly enter a comment. Alternatively a quick way is to use space+return in sequence. Space will initiate the drop-down of auto-complete steps. Comment is the first step in this list as shown below. Now just hit return to add that. Some may find this easier than reaching for the shift+3 shortcut.  (note that compatibility shows in auto-complete how nice!)

The final thing we'll mention about the script area are line numbers. 

While they serve no real scripting benefit, they are useful if you are referencing a specific point in a script to another developer or user.  Breakpoints can still be set by clicking on a line number as shown above.

There is so much more to the scripting area but we will leave it up to you to explore!

   

7. Manage workspace and compatibility

The first of these three buttons is for nominating a specific compatibility platform:

Lets say we only want to show Server compatible steps:

Incompatible steps appear here in red in both the script itself, and the list of script steps. This colour is a customisable colour, but red is pretty clear !

The other two icons are for expanding/collapsing both the scripts list, and the script step lists. We think that you'll actually end up never showing the list of script steps when you become more proficient at working with the new script workspace. Once you learn your favourite shortcuts for auto-completing script steps there really becomes no need to show a list of steps, and it can be hidden to free up more space for the script.

   

8/9/10. Script Step List

If you do feel the need to list all of the script steps, there is a nice new feature that allows you to mark specific steps as your favourites. These appear in the top group of scripts so that they are readily available (Think Show custom Dialog!!)

To add an item as a favorite, click the star icon with the step selected - and do the same to remove it from the favorite list.

The a/z icon is for showing the script steps as a full list alphabetically as opposed to grouped by category.

If not sorting alphabetically the grouped option is really much better now as you can collapse groups that aren't frequently used to keep your list of steps shorter.

Script steps can also be right-clicked to reveal the following contextual menu:

A useful option here is to look up the step in documentation, useful for beginners (or developers who have forgotten a thing or two!)

   

11. Selected Step Information

Another good feature for beginners. This panel displays some information about what the selected script step does. You can also click the little question mark icon to go to the documentation for that step.

    

Contextual Menus and Script Menus

 It is worth also exploring contextual menus and the script menus for additional options and shortcuts. There are a number of contextual menus in the script workspace.

The folder contextual menu has options that are normally achieved through shortcuts, however we think the Print option is pretty cool. this will print all scripts within that folder. This has been a useful tool in the past if you need to locate a given item in a script. Print the scripts to PDF and then search the PDF for what you want.

Most of the items in the script contextual menu are again fairly straightforward but you'll notice here you can choose to open a script in a new window. This is not a shortcut feature so you will have to use the contextual menu on either the script, scripts open tab, or the View menu.  Note that a script in its own window does not have the scripts list:

The edit menu in the script workspace has all the usual suspects, but just take note that this is where the disable/enable script step option and shortcut lives:

The view menu contains the syntax coloring option which is not accessible from anywhere else, and has no shortcut attached.

Note the different shortcuts for closing items. We don't think closing all tabs will be used much as holding down the close tab shortcut for a second or two seems to do the same job.  It will be important though to distinguish between closing a tab and closing the workspace. In FileMaker 13 we only had the ability to close a script - there was no workspace.  Now you'll need to learn to hold shift to close the whole workspace.

It is also interesting to note that if you close the workspace with scripts open, those scripts will remain open once you reopen the workspace, a really nice feature. Even cooler is that this persists even after the file is closed for files both local and hosted!

The scripts menu has all the usual suspects. Ones to note are the shortcut for opening a script directly into a new window when selected.  If you have a script open in a tab, then using the "Open Script in New Tab" has the effect of locking that script tab open.

    

In Conclusion...

The script workspace is awesome, embrace it and love it!!!!!

Something to say? Post a comment...

Comments

  • Agnes Riley 26/08/2015 5:38am (4 years ago)

    Stephen,

    If it is not a text editor, you can't just paste into it. :-)

    FileMaker is a proprietary software that has a great advantage vs. other software out there: model, controller and view in one package.

    And we're working hard requesting features that are out there in other (mostly web) development software. Some we get, some we will get later.

    It's leaps and bounds easier to program in FileMaker 14 than previous versions. We—who've been developing for decades in FM—appreciate the little goodies we get from one version to another.

    Yes, I agree, life would be simpler, if we could copy and paste from a library on the web. We can sort of with http://www.brindunning.com and Clip Manager, but we still all build our own library from our code snippets to other.

    And then there's http://www.modularfilemaker.com.

  • Stephen 26/08/2015 5:31am (4 years ago)

    Agnes / Mark,

    Much appreciate the response.

    It seems to me that FM is missing a simple piece here. I am not a programmer, in fact as far as this is concerned i’m doing it for a charity I run so it is all spare time stuff. Any way this is quite hard for me.

    I found pieces of code written like:

    Go to Layout ["Layout #1"]
    Enter Find Mode [ ]
    Set Field [ADateField ; ExampleTable::GlobalStartDate & "..." & ExampleTable::GlobalEndDate]
    Perform Find [ ]

    To me I should be able to just paste that and alter it as necessary.
    I accept that it is not a text editor but still….

    Anyway thanks for the explanation and I’ll look at the Clip Manager etc.

    Cheers

    Stephen

  • Mark Scott 26/08/2015 4:54am (4 years ago)

    Stephen,

    Just expanding a bit on Agnes' reply, one thing you <i>can</i> do is to use a third-party clipboard tool. <b>Clip Manager 5</b> from myFMButler allows you to build a library script steps, entire scripts, or other FileMaker clips (custom functions, tables, fields, etc.) for future use. You can also make batch edits to the clips before pasting back into FileMaker. It works with the XML format in which FileMaker places items onto the clipboard. I highly recommend it.

    An alternative is the combo of Clipboard Explorer from Dracoventions plus FMClips from CampSoftware, which work together to accomplish much the same thing as Clip Manager, although I have not worked with these much. Either approach is probably fine and will speed your development.

    Mark

  • Agnes Riley 26/08/2015 4:37am (4 years ago)

    Stephen,

    You cannot paste into the Script Workspace. It doesn't function like a simple text editor, because it's not text. It uses functions you have to grab from the script steps library. The calculation space you can paste into, however.

  • Stephen 26/08/2015 2:39am (4 years ago)

    Simple I am new to this. I have FMP14. MACBOOKPRO OS: Yosemite
    I can't cut - example code from web pages via clipboad to workspace of a script!
    I can copy / paste from web to notepad for example but not into the workspace.

    Am I missing something?

  • Dominique 23/07/2015 10:24pm (4 years ago)

    Hey Daniel,

    Nice Article!

    Just got a question i could not find the answer to.. Do you have any idea if it is possible to add a "stand alone" script to the script workspace?
    For example if you open a script via the debugger or just open a script in a separate window.

    Thnx

  • Siva 12/06/2015 8:43pm (4 years ago)

    Hi Daniel,
    Thanks for the nice article.

    Is there any way to rename the script when we open it from a button setup or script trigger?
    The situation I need that options is,
    I create a new button. Select Button Setup at context menu. Select Perform Script in action. Duplicate a script. I need to rename it. But it is not allowing. It was possible in previous version. Am I missing something?

  • Jaywill Sands 29/05/2015 9:58am (4 years ago)

    I mentioned in a previous topic, that Im not clear on how to filter by folder, this is something that was possible in 13. I have several folders for each section in my database that contain scripts, if Im working in "Inventory" for example I can no longer filter the scripts in the "Inventory" folder without having to change my naming convention.

    Hopefully there is something that Im missing...?

  • Scott Rose 21/05/2015 2:00pm (4 years ago)

    Thanks for the tip on the command-return (and shift-command-return) to create a new script line! Minor correction: You can't always save the script to make your active script line become inactive again. But it seems like you can always press the "ESC" key (sometimes twice in a row) to do so. For example, if you double-click the "If" script step in the right margin to add an "If" statement to your script, and then you immediately press command-S to save the script, that script line is STILL the active script. But if you press the "ESC" key once or twice in a row (depending on if you previously pressed command-S or not), then the script line becomes inactive.

  • Cath K 21/05/2015 10:12am (4 years ago)

    "how lovely" :) :) :) Useful article, thanks Daniel the future is mouse free...

  • Agnes Riley 21/05/2015 5:45am (4 years ago)

    Very detailed article, thank you, Daniel.

    Here are all the shortcuts for the new Script Workspace (form the Help menu): http://cloud.zerobluetech.com/image/2G0y2B0u2C2Q

    Tony, I couldn't find a way to get back to the left pane either. Next version!

  • Tony White 21/05/2015 5:35am (4 years ago)

    Just FYI...Shift+Command+T will open a script that is selected in the “Scripts Pane” in a New Standalone Window.

  • Tony White 21/05/2015 5:19am (4 years ago)

    Great post, Daniel,

    When the focus is in what FileMaker calls the “Scripts Pane”, typing return will move the focus to the “Scripting Fabric/Middle Area”. Does anyone know of a keyboard shortcut to go in the opposite direction?

    Thanks.

  • Daniel Wood 20/05/2015 10:04am (4 years ago)

    Hi Ruben, in the past copy/paste has been a FileMaker Pro Advanced feature of scripts and was not available in FileMaker Pro. Given I don't use FileMaker Pro I can't say for certainty whether this feature is in FileMaker Pro 14 sorry (but I know it is in Advanced) perhaps someone can shed some light on this.

    Kirk - you can auto complete on script steps?? Oh how did I miss that ! ;) Stay tuned I have other articles coming on that subject :)

  • Rubén Darío Orozco 20/05/2015 7:47am (4 years ago)

    I can copy lines or duplicate in one script. But, Can I copy lines from one script to another diferent script?. I don' t want to duplicate the script and then to erase the lines i don't need. I want to copy some lines from script to another.

  • Kirk Rheinlander 20/05/2015 3:39am (4 years ago)

    Daniel,

    Auto-complete of script steps! Just start typing commands and never leave the keyboard. I believe that is one of the prime directives on this new script maker workspace; keyboard centric and minimizing ever having to leave the keyboard and click the mouse.

    Being able to just type commands - at least for the ones that you commonly use (and can remember :-) - is a major productivity boon.

  • Mark Scott 19/05/2015 12:08pm (4 years ago)

    Thanks for another great article, Daniel. I agree emphatically with your conclusion!

    You touched on my two favorite SW discoveries so far: (1) space-return to enter a comment, and (2) the fact that SW remembers open script-tabs between sessions. I've been using the latter—an extremely nice touch from FileMaker's SW development team—to keep certain utility scrips (e.g., "Changelog") always open in a consistent location.

    Mark

  • Stu 19/05/2015 9:44am (4 years ago)

    Thanks for another great article Daniel, keep them coming :)

RSS feed for comments on this page | RSS feed for all comments