Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Trying to create a simple WHILE calc

Featured Replies

Howdy all:

The goal is to take the contents of the Notes field from each record in a found set and combine them into one field with a line space between each note entry; it'll then end up as a text inserted into a Send Mail script step.

Rather than the traditional way of looping through a found set of records to create this--or even using a Summary (List of) field--I thought I'd try my hand at using the (new) WHILE command but for the life of me I can't figure out how it works even after re-reading Skeleton Key's fine article ( https://skeletonkey.com/filemaker-18-the-while-function-looping-in-calculations/ ). I'd appreciate some guidance in putting it together...or if it's not a good way of doing it with WHILE I'd appreciate input on that, too.

 

Thanks tons,

Rich

11 hours ago, WF7A said:

if it's not a good way of doing it with WHILE I'd appreciate input on that,

It may be a good exercise, but since a script is already running anyway, my preference would be to go the "traditional" way, as you call it.

A summary field defined as List of Notes should give you the required result directly - unless an individual note can contain returns.

Anyway, doing it with While() is fairly simple:

While ( [ 
i = 1 ;
result = ""
] ; 
i ≤ Get ( FoundCount ) ; 
[ 
result = List ( result ; GetNthRecord ( YourTable::Notes ; i ) ) ;
i = i + 1
] ; 
result
)

 

 If you want a double space between the notes then change:

result = List ( result ; GetNthRecord ( YourTable::Notes ; i ) ) ;

to:

result = List ( result ; GetNthRecord ( YourTable::Notes ; i ) & ¶ ) ;

(but this assumes there will be no empty Notes fields).

 

 

Edited by comment

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.