Files
2026-09-16 16:48:24 +02:00

137 lines
4.1 KiB
Markdown

# `.fmscript` 0.90 grammar reference
Source: [https://fmscript.org/spec.html](https://fmscript.org/spec.html)
This is a concise working reference to the public 0.90 grammar overview. The published page is not yet the complete script-step catalog. When a particular step or parameter variant is uncertain, use the authoritative catalog in `../examples/`, a known-good FileMaker/ai2fm export, or validation with ai2fm; do not infer syntax from another step.
## Bracket Rule
Every script step that has parameters is followed by exactly one bracket group containing all parameters. Steps with no parameters have no bracket group.
Valid:
```text
Set Variable [ $x ; Value: "Hello" ]
Show All Records
```
Invalid:
```text
Set Variable $x = "Hello"
```
## Semicolon Rule
Main arguments inside brackets are separated by semicolon plus space. A comma is not a main argument separator.
Valid:
```text
Set Field [ Customers::Name ; "Ada" ]
```
Invalid:
```text
Set Field [ Customers::Name , "Ada" ]
```
## Comment Rule
Dedicated script comments use `# `. Disabled script steps use `// `. Multi-line comment steps continue with `#>`. Inside FileMaker calculation bodies, inline `//` and `/* */` comments are valid and must be preserved.
```text
# Explain the next operation
# Long comment title
#> continuation paragraph that remains part of the same comment step
// Perform Script [ Specified:From list; "Legacy Step" ]
Set Variable [ $x ; Value: Let ( [
a = 1 ; // inline calculation comment
b = 2 /* block calculation comment */
] ; a + b ) ]
```
## Field Reference Rule
Field references include both table occurrence and field name. Bare `::FieldName` references are invalid.
Valid:
```text
Set Field [ Customers::FirstName ; "Ada" ]
```
Invalid:
```text
Set Field [ ::FirstName ; "Ada" ]
```
## Variable Rule
Local variables start with one `$`. Global variables start with exactly two `$$`.
Valid:
```text
Set Variable [ $counter ; Value: 1 ]
Set Variable [ $$APP_MODE ; Value: "review" ]
```
Invalid:
```text
Set Variable [ counter ; Value: 1 ]
```
## Step Boundary Rule
Simple script steps are compact, but 0.90 preserves multi-line calculation bodies and multi-line comment steps. Boundaries are determined by known step names, balanced brackets, and continuation tokens, not by blindly flattening every real-world step.
```text
Perform Script [ Specified:From list; "Parse Result"; Parameter: Get ( ActiveLayoutObjectName ) ]
Perform Script [ Specified:From list; "Parse JSON"; Parameter: JSONSetElement (
"{}" ;
[ "id" ; Customers::ID ; JSONString ] ;
[ "name" ; Customers::Name ; JSONString ]
) ]
# Summary
#> This paragraph continues the same FileMaker comment step.
```
## Representative syntax.
The formal catalog covers the complete FileMaker step index. These examples show the public grammar style for common patterns, including 0.90 multi-line preservation.
`common-patterns.fmscript` — valid
```text
Go to Layout [ "Customers" (Customers) ]
New Record/Request
Set Field [ Customers::FirstName ; "Ada" ]
Set Field [ Customers::LastName ; "Lovelace" ]
Commit Records/Requests [ With dialog: Off ]
Perform Script [ Specified:From list; "Normalize Customer"; Parameter: JSONSetElement (
"{}" ;
[ "id" ; Customers::CustomerID ; JSONString ] ;
[ "fullName" ; Customers::FirstName & " " & Customers::LastName ; JSONString ]
) ]
If [ Get ( LastError ) = 0 ]
Show Custom Dialog [ "Saved"; "Customer created." ]
End If
```
## Review checklist
- Use an exact, supported FileMaker step name.
- Give each parameterized step one balanced outer bracket group and give parameterless steps no bracket group.
- Keep calculation parentheses and internal brackets balanced.
- Use semicolon plus space for main arguments.
- Fully qualify every field reference.
- Use `$` and `$$` variables correctly.
- Close every structured block with the complete matching FileMaker closing step.
- Preserve comment steps, disabled steps, calculation comments, and multiline calculation boundaries.
- Apply the project's formatting, naming, path, and output-only requirements.
- Validate uncertain or version-specific syntax through ai2fm or a known-good export before describing the script as round-trip ready.