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

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

Recommended Posts

  • Newbies
Posted

HELP! I have a script that I need to pass local variables between database files. I use the "Perform Script" script step and add my parameters "$Username; $OldPassword; $NewPassword".

How do I parse out the values in the referenced script?

Posted (edited)

Just to confirm, do you really mean pass local variables btw FileMaker files when you say "database files?" (btw, you cannot pass local or global variables between fm files. you would need a global field and a relationship between the files to "reach across" and grab the value).

Or..do you mean, pass a local variable from one script in one FM file to another script in another FM file? (again, can't be done, see above)

Or..do you mean, pass a local variable from one script to another script in the same FM file?

(if so, use script parameters or script results)

More:

What's with the passwords? Yikes. You should be using FM's built-in file security.

Passing a multi-value scriptparameter is easy if you separate each with a carriage return, and use GetValue (Get (scriptparameter) ; 3) for the third parameter.

Edited by Guest
added more
Posted

Unbelievable! I wasn't sure about this (I'm usually using one file/many tables), so I checked with Steve Lane's Using FM8 before I posted. They say, on p. 451 "There is no way to "reach across" to pull a global variable's data from one file to another."

Then, on p. 452, they take it back, "Using FM 8's new capability to return script results, you can have a script in File A return the value of a global variable from file A back to a script in file B."

And...here is your example using Local Variables.

  • Newbies
Posted

Yes, I am using the FM builtin security...Just trying to set it up so that my users can change the password for their account in the one file and have it then changed for all the other associated database files.

You rock! I was close but couldn't quite get the syntax down. The sample file was great!

}:(

Posted

There is a programming concept here that should be raised to help explain what is happening. When passing data between scripts there is what is called "pass by reference" and "pass by value."

Pass by reference passes the location of the data, not the data itself.

Pass by value passes a copy of the data, not the data itself.

Within a single file, any script can get the value of a global variable simply by referencing that variable name. However a script in FILEB can not reference the value of a global variable in FILEA. Rather, the script in FILEA must pass a copy of the value to FILEB. It does this by calling the script in FILEB with a parameter referencing the variable


Perform Script ["MyOtherScript" from file: "FILEB"; Parameter: $$myVariable]


In FILEB the script "MyOtherScript" can get this copy by setting it's own variable:



Set Variable [$$fromFileA; Value: Get( ScriptParameter )]


and after it's done whatever it needs to, can return a copy of the modified variable to the script in FILEA by using:



Exit Script [Result: $$fromFileA]


where the script in FILEA can retrieve a copy of the value returned by FILEB with the following:



Set Variable [$$myVariable; Value: Get( ScriptResult )]

Even in a single-file scenario you may need to do this ScriptParameter/ScriptResult passing if you are using script variables (aka local variables) rather than global. I use script variables almost exclusively because they assure me that some other script isn't (can't really) going to change the value in a variable I rely upon.

Posted

Thanks for the detailed explanation. I do use script parameters, exit script results, etc. all the time. I don't use global variables often, because I'm nervous that some other process may have changed them.

I supposed that S. Love declarative statement still stands, although he easily could have go on to say, but you can pass a copy of the value...

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