A repeating calculation is easier to trust when you can explain what changes on every pass and why it eventually stops. We will turn three task names into a numbered list, without moving through records or writing data.
The example requires FileMaker Pro 18 or later. It assumes a return-separated list of non-empty task names. It is a calculation exercise; for work that edits records or calls an API, use a script with explicit error handling instead.
1. Decide what one iteration means.
Our input has three values: Prepare quote, Send invoice and Call supplier. One iteration reads one value and appends one numbered line. Before writing the expression, write down the output you want:
Expected result
1. Prepare quote
2. Send invoice
3. Call supplierThis small contract answers several questions in advance. Numbering starts at one. Input order is preserved. Empty input produces empty output. Blank entries inside a list are outside this first example; decide whether to retain or remove them before adapting it to uncontrolled input.
2. Build the calculation.
FileMaker calculation
While (
[
items = "Prepare quote¶Send invoice¶Call supplier" ;
count = ValueCount ( items ) ;
i = 1 ;
output = ""
] ;
i ≤ count ;
[
output = List ( output ; i & ". " & GetValue ( items ; i ) ) ;
i = i + 1
] ;
output
)The first block establishes the values that must survive between iterations. The condition checks whether there is another item. The logic appends the current item and then advances the index. The final expression returns the accumulated text.
These unprefixed names belong to the calculation. Using them keeps this exercise separate from script variables such as $i or global variables such as $$output.
3. Follow the first and last passes.
At the first condition check, i is 1 and count is 3. The first task is appended, then i becomes 2. After the third task is appended, i becomes 4. The condition is now false, so the result is returned.
Trace the fixture
Before pass | Item read | Index after pass
1 | Prepare quote | 2
2 | Send invoice | 3
3 | Call supplier | 4
4 | no pass | result returnedChange the order of the two assignments and the example changes: incrementing first would skip the first value. This is why a loop should be reviewed in execution order, not only for balanced brackets.
4. Test the boundaries before using fields.
- One task: expect exactly one line beginning “1.”.
- Empty input: replace the input string with
""; expect empty output. - Repeated task names: keep both entries, numbered separately.
- A longer list: verify the last number equals the number of intended input values.
Next, replace the literal input with a field or script input whose format you control. Test accented characters and long task names. The calculation returns text; wrapping and font choices belong to the layout, so do not insert extra spaces merely to make one screen look aligned.
If you need totals rather than text, begin with a separate numeric fixture. Do not extend this list example with record access and formatting all at once.
5. Treat a runaway loop as a logic problem.
Every successful pass must move toward a false condition. Removing i = i + 1 breaks that guarantee. FileMaker limits iterations and may return a question mark when the limit is exceeded; raising the limit is not the first fix for a loop that never advances.
Keep the input, expected output and trace with the calculation during review. Use the formatter to make the four parts visible, then verify the result in your target FileMaker version. For a simple fixed list, ordinary text functions may be clearer; While earns its place when the repeated transformation is easier to explain than a long chain of special cases.
PUT IT INTO PRACTICE
Continue with Filesoft.
Open the calculation formatterPrefer a guided learning path? Explore the free FileMaker courses.
Continue reading
Claris references: While · ValueCount · GetValue · List. Examples are learning aids; verify them in your own FileMaker working copy.