Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

« Newer IMAP Email exam… | Home | MBS FileMaker Plugin,… »

Dialogs made in FileMaker


Sometimes you need a dialog to ask the user a few details your FileMaker solution. Maybe a selection dialog or a small input for a few text fields. FileMaker can open dialog boxes that show a layout with the new window script step. The layout used can look like a dialog and provide buttons to close the dialog. Since FileMaker 16 introduced the card style for windows, you can use dialogs as well as cards in a window.

 

Dialog Window

 

Basically, we have a little problem with such dialogs in a script. Usually the script ends and the button triggers later the next script to complete the work. This is annoying, because the flow in the script is interrupted and you can handle everything in one script. Local variables are gone with the end of the script and the context needs to be recreated in the second script.

 

We got a solution recently: While the dialog is displayed, the calling script waits in a script pause and continues as soon as the dialog is finished. This allows the result to be further processed directly in the script. Here is the sample script for a dialog:

 

Set Variable [ $x ; Value: Get ( ScreenWidth ) / 2 - 200 ] 

Set Variable [ $y ; Value: Get ( ScreenHeight ) / 3 - 100 ] 

New Window [ Style: Dialog ; Name: "Dialog" ; Using layout: “Card” ; Height: 240+20 ; Width: 400 ; Top: $y ; Left: $x ] 

Show/Hide Toolbars [ Hide ] 

Loop

Pause/Resume Script [ Indefinitely ] 

Set Variable [ $Result ; Value: Get(ScriptResult) ] 

Exit Loop If [ Length($Result) > 0 ] 

End Loop

#

Close Window [ Name: "Dialog" ; Current file ] 

Set Field [ Dialog Test::Result ; $Result ] 

 

Let's go through the script line by line. First, let us define where the dialog should appear on the screen. The width and height of the screen are divided and half size is subtracted for the dialog. Horizontally we take the middle of the screen. Vertically we take a third, so that the dialog appears further up on the screen. The new window script step takes Dialog as window type. We use the layout called "card" (in the example file) and the corresponding size. Width and height depend on the size of the layout. This layout shows the text for the dialog, possibly some input fields and at least one button to close the dialog. In order to make sure that no toolbar is displayed, we hide the toolbar explicitly.

 

The loop in the script sets an unlimited script break. The pause gives the user time to use the dialog. If the user continues the script, the loop will pause directly again. We get the result of the dialog via the script result function and finish the loop as soon as we have a result. When the user has decided, we close the window after the loop. With $Result we can continue our script. In the example, this information is only written to a field.

 
Close dialog

 

For the buttons in the dialog we need a little helper script. A global script for all dialogs in all scripts. This script has only one task: Return the script parameter directly as a result:

 

# Call this script from dialog buttons to pass back a result value

Exit Script [ Text Result: Get(ScriptParameter) ] 

 

It is important that the script is called with the option to continue the current script. The result of the dialog is given as a script parameter to this script, so it ends up in the Get(ScriptResult) in the main script above.

 

Here again a screenshot with the button dialog and the option below for the script. You may have to open the options with the small triangle.

 

Card Window

 

Instead of a dialog, you can use a card window in FileMaker 16 or newer:

 

New Window [ Style: Card ; Name: "Dialog" ; Using layout: “Card” ; Height: 240 ; Width: 400 ] 

Loop

Pause/Resume Script [ Indefinitely ] 

Set Variable [ $Result ; Value: Get(ScriptResult) ] 

Exit Loop If [ Length($Result) > 0 ] 

End Loop

#

Close Window [ Name: "Dialog" ; Current file ] 

Set Field [ Dialog Test::Result ; $Result ] 

 

These seven lines are copied into a script, a matching layout created and you already have a card for a query from the user.

 

We hope you can use these dialogs everywhere. If you need more or dialogs for a calculation or your own function, we recommend a look at the DialogListDialog and FileDialog functions in the MBS FileMaker Plugin.

04 03 19 - 10:26
No comments

  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.