« Use Llama.cpp in Xojo… | Home | Scopes and namespaces… »

Dialogs with fields for Windows

We have our dialog functions in MBS FileMaker Plugin to quickly show a dialog in a calculation. Usually to show a custom dialog in FileMaker at any time to quickly report something to the user or to quickly ask a question with yes or no.

 

For example we can just ask with a Let statement for whether we should delete a file:

 

Let ( 

[

    _ = MBS("Dialog.Reset") ;

    _ = MBS("Dialog.SetDefaultButton" ; "Yes") ;

    _ = MBS("Dialog.SetOtherButton" ; "No") ;

    _ = MBS("Dialog.SetAlternateButton" ; "Cancel") ;

    _ = MBS("Dialog.SetMessage" ; "Delete the old file?") ;

    _ = MBS("Dialog.SetWindowTitle" ; "Backups done") ;

    _ = MBS("Dialog.Run") ;

    button = MBS("Dialog.GetButtonPressed")

] ;

    // 0 -> Yes, 1 -> No, 2 -> Cancel

    button

)


A few years ago we added a few helper functions for macOS to add some text fields to ask a question and get some data. For example we may ask:

  • The new file name for renaming a file
  • Ask for user name and password for new account
  • Ask user for an email, phone number or some other quick value
  • Ask for some initial values to create a new record.
  • Enter a approval code like TOTP

If someone needs to pick something from a list, you better use ListDialog functions.

 

For the fields, let's make a little script to ask the user for an user name and password with two fields:

 

Set Variable [ $r ; Value: MBS( "Dialog.Reset" ) ]

Set Variable [ $r ; Value: MBS( "Dialog.SetAlternateButton" ; "Cancel" ) ]

Set Variable [ $r ; Value: MBS( "Dialog.SetDefaultButton" ; "Create" ) ]

Set Variable [ $r ; Value: MBS( "Dialog.SetInformativeText" ; "To quickly add an user name and optional a password. If no password is provided, we generate one." ) ]

Set Variable [ $r ; Value: MBS( "Dialog.SetMessage" ; "Create new user account for My Solution" ) ]

Set Variable [ $r ; Value: MBS( "Dialog.AddField"; "Account name:"; ""; "Name" ) ]

Set Variable [ $r ; Value: MBS( "Dialog.AddField"; "Initial password:"; ""; "Password" ) ]

Set Variable [ $r ; Value: MBS( "Dialog.SetWindowTitle" ; "Create Account" ) ]

Set Variable [ $result ; Value: MBS( "Dialog.Run" ) ]

Set Variable [ $name ; Value: MBS( "Dialog.GetFieldText"; 0) ]

Set Variable [ $pass ; Value: MBS( "Dialog.GetFieldText"; 1) ]

Show Custom Dialog [ $result & ¶ & $name & ¶ & $pass ]

Or as Let statement:

 

Let(

[

r = MBS( "Dialog.Reset" ) ;

r = MBS( "Dialog.SetAlternateButton" ; "Cancel" ) ;

r = MBS( "Dialog.SetDefaultButton" ; "Create" ) ;

r = MBS(

"Dialog.SetInformativeText" ;

"To quickly add an user name and optional a password. If no password is provided, we generate one."

) ;

r = MBS( "Dialog.SetMessage" ;

"Create new user account for My Solution" ) ;

r = MBS( "Dialog.AddField" ;

"Account name:" ;

""

          "Name" ) ;

r = MBS( "Dialog.AddField" ;

"Initial password:" ;

"" ;

"Password" ) ;

r = MBS( "Dialog.SetWindowTitle" ;

"Create Account" ) ;

$result = MBS( "Dialog.Run" ) ;

$name = MBS( "Dialog.GetFieldText" ; 0 ) ;

$pass = MBS( "Dialog.GetFieldText" ; 1 )

] ;

$result

)

 

As you see we can just evaluate a Let to get the variables filled. This is very convenient to show a dialog at the spot in some calculation. 

If you need more, check out the example on how to make a dialog from a FileMaker layout and put many more controls on the dialog.

25 02 26 - 09:11