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

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

Recommended Posts

Posted (edited)

Hi all,

Is it good practice to set global script variables to store preferences (or business rules) that will need to be called by scripts at some point during file use?

As an example, I need to globally store the values of the time that the user's business opens, the time it closes and its lunchtime start-and-finish times. I've used global fields that are set by script at startup to predefined values. Should I just set global script variables instead to these values? Why or why not?

Thanks in advance for your help! :B

Edited by Guest
Posted

yes you can use the variable in leu of a global the only benefit of a global in this cases is if you need to view it on a layout or you wish to edit/modify the value outside a script

Posted

I use Golbal fields mostly because I can then place them on layouts and follow my scripts with pause steps. This helps me to better understand how my db flows as I write it. When I'm done I either hide the layout or just delete the fields from the layout.

John

Posted

Thanks for the help, Stephen and John!

yes you can use the variable in leu of a global the only benefit of a global in this cases is if you need to view it on a layout or you wish to edit/modify the value outside a script

Isn't there also the limitation of it being called on by scripts that reside only in the current file? Is this understanding correct?

I use Golbal fields mostly because I can then place them on layouts and follow my scripts with pause steps. This helps me to better understand how my db flows as I write it. When I'm done I either hide the layout or just delete the fields from the layout.

Good point...although I find myself using Data Viewer for this purpose with increasing frequency, even with global fields.

So, what about performance? Let's say I have to call up a dozen or so business rules in a looping script. Would I notice an improvement in performance between global fields and global variables?

Posted

I decided to test it so I built a solution that loops through record creation and sets a number of fields in each record. One script in the solution uses global fields to pass data, the other script uses global variables to pass the same data, with all other conditions being equal between scripts.

Here's what I came up with. The script with the variables consistently had the shortest elapsed time of execution. The difference was almost always insignificant (1-2%) but one interesting thing I observed was that the difference increased to 10% as I decreased the quantity of records the script dealt with to 100. I ran about half a dozen tests with each script for each quantity of 100, 1000, 5000, 10000 and 15000.

All testing was performed on a 2.66 GHz Pentium 4 using FMP 8 Advanced

Attached is the file I used if you want to try it for yourself. I'd be interested in hearing if anyone gets different results.

GlobalVsVariable.zip

Posted

Thanks for the info. This will definetly weight my future programing. You did mean decrease didn't you?

"one interesting thing I observed was that the difference increased to 10% as I decreased the quantity of records the script dealt with to 100."

John

Posted

Thanks for the info. This will definetly weight my future programing. You did mean decrease didn't you?

"one interesting thing I observed was that the difference increased to 10% as I decreased the quantity of records the script dealt with to 100."

John

The difference in performance was what I was referring to as an increase. When I ran my tests earlier with just 1000 records (the 100 in my quote above is a typi), I was consistently getting 10 seconds elapsed with the global fields and 9 seconds with the global variables, i.e. an increase in performance to 10% Vs. the 1-2% I was seeing with the larger quantities of records.

That was then...now, several hours later I decided to try it again just to make sure I'm getting the same results. Now my results are all over the place for the 1000 qty. Both scripts are executing from 2 to 10 seconds, sometimes the global field script being the faster of the two, sometimes not. I'm puzzled!!! Can anyone offer some hint as to what could be happening?

This topic is 6887 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.