Jump to content

Global vs Local Variables


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

Recommended Posts

Hey, guys. Just a quick question for clarification. I have a script that involves a lot of IF statements. I want to make a sub-script that I can call via Perform Script, so I don't have to have a 1000 line script. If I set variables in the main script that I want to use in the sub-script, do I need to set those to global variables?

Link to comment
Share on other sites

If you were to use variables, yes.

An alternative would be to pass the values to the sub-script in the script parameter, but if you want to pass multiple values, then you will need a method to manage that. There are plenty of options for this, my preferred method is: http://sixfriedrice.com/wp/filemaker-dictionary-functions/

Link to comment
Share on other sites

It's OK to use global variables, but... If you do, keep in mind that they are file-specific, so it won't work if the sub-script is in a separate file. Another potential drawback is that you have to clean up after yourself, as a persistent value in a global variable could have unintended consequences.

For those reasons, I generally prefer to pass script parameters as Dan suggested. I use this method, which is a little simpler than the 6FR way, which requires a function both to send and receive the params. The one I use only uses a function to receive the params.

Link to comment
Share on other sites

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