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.

Basics of Script / Function Formatting in if / else structures

Featured Replies

I am using FileMaker Pro 19.

This is such a basic question, it's embarrassing. I have been using FileMaker Pro since, I think, around version 7. Every 3 to 5 years I bring it out and make something relatively complex for my personal business use, I then use that custom app for many years. Each time the gears gradually wind up and I am more less back where I was before, able to get what I need. This time, not so much.

I have an if then script function...

If( (SCAAAPE | PreProcess::UX | Statement | Bank | Card) = "Apple / Goldman-Sachs | Mastercard"; "AGS"; "BECU")

The script is located in a button using Perform Script

It is the first stage of a concatenation script/function: simple choice from a drop menu sends the process down one of two paths to create a unique primary key name for one of tow credit cards.

This works well but I need it to do a bit more and I have gotten hung up on some basic formatting. This first question I have is the field enclosed in parentheses. In all the examples in Filemaker help the field name was bare, without parens but this did not work so I had to wrap the file name in parentheses. Why is this?

The next and thornier problem...

I would like to move to this format - example is from FileMaker Pro Help

If [Get ( FoundCount ) = 0]
    Show Custom Dialog ["Find Records"; "No records were found."]
Else
    Sort Records [Restore; With dialog: Off]
End If

I do not understand the use of the brackets, "[ ]"-especially within the context of my particular usage. I have done several days of research but I have gotten nowhere, basic script structure questions like this are very difficult to find. Lots of advanced users and I guess few newbies.

Thanks in advance.

 

 

 

I find your term "script function" confusing - and it could well be the source of your problem too.

Scripts are not functions and functions are not scripts. You use functions in calculations (including calculations that take place inside a script). You use scripts to perform actions.

Filemaker offers IF both as a function and as a script step. What you show here is a calculation using the If() function:

2 hours ago, GarrettC said:

If( (SCAAAPE | PreProcess::UX | Statement | Bank | Card) = "Apple / Goldman-Sachs | Mastercard"; "AGS"; "BECU")

While this is an example of the If[] script step:

2 hours ago, GarrettC said:

If [Get ( FoundCount ) = 0]

By convention, function parameters are in () parentheses, script step options are in [] square brackets.

 

2 hours ago, GarrettC said:

I would like to move to this format

It's not only a question of format. The result of your calculation is one of the two strings. The result of a script step must be some action (e.g setting this field or another). What different actions would you like to take here based on the evaluation of the condition?

 

2 hours ago, GarrettC said:

without parens but this did not work so I had to wrap the file name in parentheses. Why is this?

I can see no good reason for this.

 

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.