Jump to content

SMGetVariable ( name )


andries
 Share

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

Recommended Posts

Hi all

I am switching from plain Java to Groovy, and I want to start using output variables ( SMGetVariable ( name ) ).

However there is something I don't really grab. To declare a variable in Groovy I use the "def" statement, however when I use this "def" statement, this variable cannot be read by the SMGetVariable ( name ) function.

For example:

def number1 = input1;

def number2 = input2;



def output1 = number1 + number2


Will return "ERROR" when I evaluate the function SMGetVariable ( "output1" ).



However the following lines of code, I am able to get the value of output1.




def number1 = input1;

def number2 = input2;



output1 = number1 + number2;

So I have the feeling that variables you want to get back to FileMaker should be declared differently. Can someone give me some background on why and how?

Thanks in advance!

Andries

Link to comment
Share on other sites

I think I found the answer, or at least this is what I hope for.

When you declare an object (and not a variable ! ! !) with the use of "def" you define it to exists in the local scope of the script, when you don't declare it. By not declaring the object you actually adds it to the Binding and my guess is that ScriptMaster is looking there for the variables.

Is this correct? Does this also implies that if you omit the "def" it is always a String?

Link to comment
Share on other sites

This topic is 4318 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
 Share

×
×
  • Create New...

Important Information

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