Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4268 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I am running a database on FileMaker Server 12, and have a number of daily imports and scripts that need to be run, but due to a limitation in the ODBC driver (connecting to 4D.  Server can't run the imports, it has to be done on my client machine), I can't set up a scheduled script on the Server to run the imports.

 

The thought I had on how to get around that was to have a scheduled script on Server which would populate a "Script Request" table, which would simply add a record to a table with when the script is requested, which script is requested, and the times that it can be run.

 

Then, I'd set up an OnTimer script on my client machine that looks at that table for any records which don't have a completed stamp, would pull the name of the script from the field, and run that script.

 

However, unlike being able to go to layout by calculation or set field by calculation, I don't see a way to run a script by calculation.  The only way I see to do this is to write one big script that goes through a bunch of

 

If [scriptToRun = "import"]

  Perform Script [import]

end if

if [scriptToRun = "import 2"]

  Perform Script [import 2]

end if

 

etc.

 

So, I have two questions:

 

1) Is there something I'm missing that would be a better solution than all of this?

2) If not, is there a way for me to optimize this so I don't have to remember to update multiple scripts each time I need to create a new import?  

Posted

Though you may choose other methods, it appears that in any case you should understand the else if script step:

 

 

If [scriptToRun = "import"]

  Perform Script [import]

else if [scriptToRun = "import 2"]

  Perform Script [import 2]

end if

Posted

Though you may choose other methods, it appears that in any case you should understand the else if script step:

 

 

If [scriptToRun = "import"]

  Perform Script [import]

else if [scriptToRun = "import 2"]

  Perform Script [import 2]

end if

 

 

Yeah, I should have written my example that way - I use that when I actually write the scripts (and am staring at the list of script steps), but when I'm thinking through a problem, I tend to forget about it and think in straight-up If/End If statements.

Related question - if I just end up doing this as the long string of If/Else If/Else If/End If statements (there will probably be 10-15 of them right now... Well, that's a lot for me!), will Filemaker have to evaluate every single If, or will it just evaluate until it finds the matching one, and then skip over all the remaining else's?

 

I'm sure since it's only a couple handfuls of possible criteria, there would be no appreciable difference in performance, but I'm trying to make sure I'm building this database in ways that will teach me best practices as well, and I'm sure if this has to evaluate every single statement, that's not a good way to make a scalable solution.

  • 3 weeks later...
Posted

The script will do a test each time it reaches an if. The else will be ignored if the initial IF is TRUE. Therefore using else if should be more efficient.

Eg

 

IF....

Else....

IF

Else...

IF....

Else....

 

IF....

Else....

will always test four times

 

IF

else if..

else if

else if

has the potential to test only once but could test four times.

This topic is 4268 days old. Please don't post here. Open a new topic instead.

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.