Jump to content

Basics of Script / Function Formatting in if / else structures


Recommended Posts

Posted

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.

 

 

 

Posted

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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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