« Dutch FileMaker Meetu… | Home | MapView video in Engl… »

New functions of the MBS Plugin Version 9.5

In this article Stefanie introduces some of the new functions of the MBS Plugin version 9.5.

The list dialog

At first we start with news about the list dialog for Windows and Mac. With the list dialog component we show a list dialog with entries and you can select an item. With the new plugin version you can add a new third button to this dialog. For example it can call an information website for this dialog. In the following script we create a listdialog with two items and an info button.

Set Variable [ $r ; Value: MBS("ListDialog.ClearList") ]
Set Variable [ $r ; Value: MBS("ListDialog.SetPrompt"; "Please select an item:") ]
Set Variable [ $r ; Value: MBS("ListDialog.AddItemToList"; "First Item"; "1") ]
Set Variable [ $r ; Value: MBS("ListDialog.AddItemToList"; "Second Item"; "2") ]
Set Variable [ $r ; Value: MBS("ListDialog.SetAllowMultipleSelection"; 1) ]
Set Variable [ $r ; Value: MBS("ListDialog.SetSelectedTitle"; "1") ]
Set Variable [ $r ; Value: MBS("ListDialog.SetOtherButtonLabel"; "Help") ]
Set Variable [ $r ; Value: MBS("ListDialog.SetOtherButtonEvaluate"; "MBS( \"ShowURL\"; \"https://mbsplugins.eu\" )") ]
Set Variable [ $r ; Value: MBS("ListDialog.ShowDialog") ]

Global variabels

Perhaps you have experience with the variables that you can set with the MBS Plugin from the component Variables. The variable is not limited to a file, a script or a user, so you can use it for example on your server to count the file accesses or to save a text in memory for all users that not need saved in the database. We add a new operation on this variable. Now you can append text to a variable with FM.VariableAppend function. The benefit of this function is that you don’t need the combination of FM.VariableGet and FM.VariableSet for appending a text. This avoids errors that are caused by operations between both functions.

Set Variable [ $r ; Value: MBS( "FM.VariableSet"; "Name"; "My name is " ) ]
Set Variable [ $r ; Value: MBS( "FM.VariableAppend"; "Name"; "Stefanie" ) ]

The keyboard on the screen

For Mac and Windows you can now show the keyboard in your solution. In this way you can enter data by mouse click. Additional, if you type while the keyboard is shown, the currently pressed keys are colored dark, so the keyboard can help you for example in tutorials or presentation.

Set Variable [ $r ; Value: MBS("Window.ShowKeyboard") ]

New developer functions for Mac

We have some features only for Mac, where we provide goodies for developers. If you open the set variable dialog you see in the right upper side some new characters. This characters show you the position of the cursor. L shows the line number and C the number of characters in the line. If you select a part of the text, it addition we show the number of characters that you selected. It counts also characters that are invisible, for example if you have an emoji that need two characters in the storage it the value of S is two.

We have a very powerful function for contextual menus. You can now add context menu entries by yourself. You add an entry with the „SyntaxColoring.AddContextMenuCommand“ script step. For example it is possible to add a loop, that iterates by one in each repetition, with one click. We defined the expression in the parameters of the function. Here is a script for the loop example:

Set Variable [ $r ; Value: MBS( "SyntaxColoring.AddContextMenuCommand";
"Insert For Loop";
"Let ([
xml = \"<fmxmlsnippet type=\\\"FMObjectList\\\"><Step enable=\\\"True\\\" id=\\\"89\\\" name=\\\"# (comment)\\\"><Text>loop counting up from 1 to $count</Text></Step><Step enable=\\\"True\\\" id=\\\"141\\\" name=\\\"Set Variable\\\"><Value><Calculation><![CDATA[\\\"/* add count here */\\\"]]></Calculation></Value><Repetition><Calculation><![CDATA[1]]></Calculation></Repetition><Name>$count</Name></Step><Step enable=\\\"True\\\" id=\\\"141\\\" name=\\\"Set Variable\\\"><Value><Calculation><![CDATA[1]]></Calculation></Value><Repetition><Calculation><![CDATA[1]]></Calculation></Repetition><Name>$index</Name></Step><Step enable=\\\"True\\\" id=\\\"68\\\" name=\\\"If\\\"><Calculation><![CDATA[$index ≤ $count]]></Calculation></Step><Step enable=\\\"True\\\" id=\\\"71\\\" name=\\\"Loop\\\"></Step><Step enable=\\\"True\\\" id=\\\"89\\\" name=\\\"# (comment)\\\"><Text>your script steps here</Text></Step><Step enable=\\\"True\\\" id=\\\"89\\\" name=\\\"# (comment)\\\"></Step><Step enable=\\\"True\\\" id=\\\"89\\\" name=\\\"# (comment)\\\"><Text>next</Text></Step><Step enable=\\\"True\\\" id=\\\"141\\\" name=\\\"Set Variable\\\"><Value><Calculation><![CDATA[$index + 1]]></Calculation></Value><Repetition><Calculation><![CDATA[1]]></Calculation></Repetition><Name>$index</Name></Step><Step enable=\\\"True\\\" id=\\\"72\\\" name=\\\"Exit Loop If\\\"><Calculation><![CDATA[$index > $count]]></Calculation></Step><Step enable=\\\"True\\\" id=\\\"73\\\" name=\\\"End Loop\\\"></Step><Step enable=\\\"True\\\" id=\\\"70\\\" name=\\\"End If\\\"></Step></fmxmlsnippet>\";
r = MBS( \"Clipboard.SetFileMakerData\"; \"ScriptStep\"; xml );
r = MBS( \"Menubar.RunMenuCommand\"; 57637 /* paste */ )
]; \"\" )"; 0 )]

If you use the context menu entry the following lines are added to your script:

# loop counting up from 1 to $count
Set Variable [ $count ; Value: "/* add count here */" ]
Set Variable [ $index ; Value: 1 ]

If [ $index ≤ $count ]
    Loop
        # your script steps here
        #
        # next
        Set Variable [ $index ; Value: $index + 1 ]
        Exit Loop If [ $index > $count ]
    End Loop
End If

With the use of Clipboard.GetFileMakerData and Clipboard.SetFileMakerData you get and set the XML of the current script steps. We look forward that the community will write a lot of this script snippets, that are useful for a lot of us. In our function reference you find more examples. You can enter context menu entries in a deeper level if needed. For example you want to iterate a loop by 1 or you want to iterate a loop by 2.

Also you can clear the entries of the context menu. You can choose if you want delete a single entry by title or you want to delete all customised entries of the context menu.

News from the web viewer

Moreover we have some news about the web viewer component, with the web viewer of FileMaker you can display websites in your solution. We added a new function to set the web viewer to privat browser mode. This allows you to surf in the internet without a history within the web viewer. You set this setting with „Webview.SetPrivateBrowsing“ und you can query it with „Webview.GetPrivateBrowsing“. For the web viewer you can now install user scripts, which are automatically embedded and executed in all loaded website. Great to remove unwanted content like ads or navigation/login areas. You can see that in this example where we set variables, perform a calculation and alert the result.

Set Variable [ $r ; Value: MBS( "Webview.AddUserScript"; $$web; "var x = 5; var y = 6; var z = x + y; alert(x+'+'+y+'='+z);"; "AtDocumentStart"; 1 ) ]

In the third parameter of this MBS Function you decide if the script is add in the start or the end of the loading process. That can be essential for the result. Attention: That function request webKit 2, that mean you must us FileMaker 16 or newer. The web view must be created with the FileMaker tool because the web viewers created by the plugin use WebKit 1.

In Addition we can delete all user scripts, that have been set, with „Webview.RemoveAllUserScripts“ or you can query a list of all user scripts with „Webview.UserScripts“. Thats function returns you a JSON with the informations of the scripts.

We extend MapView

We add 18 new functions to the component MapView. With MapView you can display maps, based on the Apple map data, in your solution. In addition of the existing functions, there are now functions that determine the appearance of annotations and overlays. We can set an annotation and a drag image, the fill and stroke color for overlays.

In the example script you see how you set the fill color of an overlay and an image of an annotation:

Set Variable [ $$map ; Value: MBS( "MapView.CreateWithControl"; 0; "Placeholder") ]
Set Variable [ $annot ; Value: MBS( "MapView.AddPinWithAddress"; $$map; "Bonn" ) ]
Set Variable [ $r ; Value: MBS( "MapView.SetAnnotationImage"; $$map; $annot; Test 9.5::Field ) ]
Set Variable [ $circle ; Value: MBS( "MapView.AddCircle"; $$Map; "{ \"longitude\": 7.329722, \"latitude\": 50.413333, \"radius\": 5000, \"title\": \"Monkeybread Software\", \"subtitle\": \"MBS is here\", \"color\": \"#FF000077\" }") ]
Set Variable [ $r ; Value: MBS( "MapView.SetOverlayFillColor"; $$Map; $circle; "#0000FF88" ) ]

Soon there will be a detailed post about MapView, where you can get an insight into what is possible with MapView.

I hope that the MBS plugin has some exciting features for you and wish a lot of fun with our new functions. If you need a license or have questions, don't hesitate to contact us.

21 11 19 - 15:21