Accessing properties of an object (script) from other script

Hi,

I have a following scenario:

There are 3 script files file1.script, file2.script & file3.script

The file3.script is:

properties

test1:""
test2:""

end properties

  1. file1 loads file2 in background by “start using “file2.script”” command
  2. file2 loads file3 in background by “start using “file3.script”” command
  3. file1 calls a function f1 which is defined in file2.
  4. One of the commands in function f1 of file 2 sets the “property test1” in file3 to a list as:

put (1,2) into file3.test1

Now when I print the value of property test1 in file3 from file 2 by giving the command:

put file3.test1

I get the correct value (1,2)

Problem:

but when I give the same command from file1 I get an empty response.

Second Issue:

In the above scenario, I need to use item 1 of list (1,2) to be passed as input parameter to another function in file3.

Thanks in advance.

Kamran.

The problem here is that “file3” is simply a local variable. When you give the command “put (1,2) into file3.test1” SenseTalk tries to treat file3 as an object. If it finds a script object named “file3.script” (such as in the local suite) it will use that object, but if not it will simply set the file3 variable to be a property list containing a property “test1” with the value (1,2). In this case this variable has no connection to any script object, and the other script will have no access to its value.

So, I’m guessing that your file3 is not located in the same folder as file2. The “start using” command you’re using will add the file3 script object to the messaging path, but this doesn’t help it find the file3 script when the file3 variable is used as an object (I hope this isn’t too confusing!).

To ensure that the file3 script is found, instead of using the “start using” command, you should add the suite where file3 is located to your Helpers list, or use the OpenSuite command earlier in your script to open that suite.

Assuming that file3 can be found, you should be able to do this:

put file3.anotherFunction(item 1 of file3's test1)