Insert Script Step Pseudocode

The best we can do for now…

Problem

You want to insert pseudo code into FileMaker?

Something generated by AI or found on a website

Maybe something like this? (the example code for the MBS SaveFileDialog function)

Delete All Records [No dialog]
Set Variable [$r; Value:MBS("FileDialog.Reset")]
Set Variable [$r; Value:MBS("FileDialog.SetShowHidden"; FileDialog::ShowHidden)]
Set Variable [$r; Value:MBS("FileDialog.SetAllowMulti"; FileDialog::AllowMulti)]
Set Variable [$r; Value:MBS("FileDialog.SetResolvesAliases"; FileDialog::ResolvesAliases)]
Set Variable [$r; Value:MBS("FileDialog.SetTreatsFilePackagesAsDirectories"; FileDialog::TreatsFilePackagesAsDirectories)]
Set Variable [$r; Value:MBS("FileDialog.SetCanSelectHiddenExtension"; FileDialog::CanSelectHiddenExtension)]
Set Variable [$r; Value:MBS("FileDialog.SetWindowTitle"; FileDialog::WindowTitle)]
Set Variable [$r; Value:MBS("FileDialog.SetInitialDirectory"; FileDialog::InitialDirectory)]
Set Variable [$r; Value:MBS("FileDialog.SetNameFieldLabel"; FileDialog::NameFieldLabel)]
Set Variable [$r; Value:MBS("FileDialog.SetPrompt"; FileDialog::Prompt)]
Set Variable [$r; Value:MBS("FileDialog.SetMessage"; FileDialog::Message)]
Set Variable [$r; Value:MBS("FileDialog.SetNameFieldStringValue"; FileDialog::NameFieldStringValue)]
Set Variable [$r; Value:MBS("FileDialog.SaveFileDialog")]
If [$r = "OK"]
    Set Variable [$index; Value:0]
    Set Variable [$count; Value:MBS("FileDialog.GetPathCount")]
    Loop
        New Record/Request
        Set Field [FileDialog::Path; MBS("FileDialog.GetPath"; $index)]
        Commit Records/Requests []
        Set Variable [$index; Value:$index + 1]
        Exit Loop If [$index = $count]
    End Loop
End If

You want to be able to copy this text and paste this into FileMaker?

Delete All Records [No dialog]
Set Variable [$r; Value:MBS("FileDialog.Reset")]
Set Variable [$r; Value:MBS("FileDialog.SetShowHidden"; FileDialog::ShowHidden)]
Set Variable [$r; Value:MBS("FileDialog.SetAllowMulti"; FileDialog::AllowMulti)]
Set Variable [$r; Value:MBS("FileDialog.SetResolvesAliases"; FileDialog::ResolvesAliases)]
Set Variable [$r; Value:MBS("FileDialog.SetTreatsFilePackagesAsDirectories"; FileDialog::TreatsFilePackagesAsDirectories)]
Set Variable [$r; Value:MBS("FileDialog.SetCanSelectHiddenExtension"; FileDialog::CanSelectHiddenExtension)]
Set Variable [$r; Value:MBS("FileDialog.SetWindowTitle"; FileDialog::WindowTitle)]
Set Variable [$r; Value:MBS("FileDialog.SetInitialDirectory"; FileDialog::InitialDirectory)]
Set Variable [$r; Value:MBS("FileDialog.SetNameFieldLabel"; FileDialog::NameFieldLabel)]
Set Variable [$r; Value:MBS("FileDialog.SetPrompt"; FileDialog::Prompt)]
Set Variable [$r; Value:MBS("FileDialog.SetMessage"; FileDialog::Message)]
Set Variable [$r; Value:MBS("FileDialog.SetNameFieldStringValue"; FileDialog::NameFieldStringValue)]
Set Variable [$r; Value:MBS("FileDialog.SaveFileDialog")]
If [$r = "OK"]
    Set Variable [$index; Value:0]
    Set Variable [$count; Value:MBS("FileDialog.GetPathCount")]
    Loop
        New Record/Request
        Set Field [FileDialog::Path; MBS("FileDialog.GetPath"; $index)]
        Commit Records/Requests []
        Set Variable [$index; Value:$index + 1]
        Exit Loop If [$index = $count]
    End Loop
End If

No problem! 😎

Solution

At least, a partial solution, and the best we’ve got right now…

You need:

fmCheckMate-XSLT

  • the fmCheckMate-XSLT library
    • which contains the conversion function in its bin folder

fmAutoMate

  • fmAutoMate
    • which puts the function at your fingertips in a context menu in the script workspace

Disclaimer:

This is an 80/20 process. It will get you 80% of the way there, but it is neither perfect nor complete.

Please note the following limitations of this process.

Limitations:

  • FileMaker Pseudocode is incomplete A major problem that FileMaker has in this area is that FileMaker’s script step text is not a complete description of the code.
    • Steps like Import Records or Sort Records do not list all the fields or options.
    • There is currently no standard way of writing complete pseudocode.
  • Complex steps are not implemented.
    • Only simple steps are implemented, these are likely to make up the majority of your code.
  • Single line calculations:
    • Currently only single line calculations are supported.
  • Not necessarily up to date:
    • Yeah, I need to get new steps integrated into the tool. Please ping me.

Disclaimer

Before you start using the fmPseudocode technique you should understand its limits.

To paste pseudocode into your FileMaker solution

These four steps will get you 80-100% of the way there:

  1. Copy the script step pseudocode you want to paste
  2. Open the script where you want to paste the code
  3. Right click to show the fmAutoMate context menu
  4. Select fmAutoMate > Clipboard Paste > Paste Script Pseudocode

This converts the text into code and pastes it in - as best it can.

Every line that is not recognised, is added as a comment, which means to correct the code you have everything you need in the steps.

Video TODO