Activating a Function in a Different Stack

Marielle Lange mlange at widged.com
Sun Oct 29 20:13:46 EST 2006


> Never mind.  It is in parameters where that does not work.

You are right. This works:

   on mouseup
     put "1" into aTest[1]
     put "2" into aTest[2]
     get return_array(aTest)
     put the result into aResult
     combine aResult using cr
     answer aResult
   end mouseup

   function return_array pArray
     return pArray
   end return_array


But this doesn't (didn't really expect so)

Stack A
---------
   on mouseup
     put "1" into aTest[1]
     put "2" into aTest[2]
     get return_array(aTest)
     send doSomething to button 1 of stack "stackB"
   end mouseup


Stack B
---------
   on doSomething
     put the result into aResult
     combine aResult using cr
     answer "--" & aResult
   end doSomething

------------------------------------------------------------------------ 
------------------------------------

What is exactly the scope of this "the result"?
According to the doc: "The result function is set to empty when the  
current handler finishes executing."
This doesn't work either:

         on mouseup
           put "1" into aTest[1]
           put "2" into aTest[2]
           get return_array(aTest)
           test_result
         end mouseup
	...
         on test_result
           put the result into aResult
           combine aResult using cr
           answer "--" & aResult
         end test_result

------------------------------------------------------------------------ 
------------------------------------

And about passing arrays as parameters, it looks like a challenge  
indeed.

This works:

Stack A
----------
   put "one" into aTest
   send "doSomething aTest" to button 1 of stack "stackB"

This doesn't
Stack A
---------
   put "1" into aTest[1]
   put "2" into aTest[2]
   send "doSomething aTest" to button 1 of stack "stackB"

------------------------------------------------------------------------ 
------------------------------------

Unsurprisingly, this doesn't work:
       set the array_data of button 1 of stack "stackB" to aTest

------------------------------------------------------------------------ 
------------------------------------

But this works:

Stack A
---------
on mouseup
   put "1" into aTest[1]
   put "2" into aTest[2]
   set the customproperties of button 1 of stack "stackB" to aTest
   send "doSomething" to button 1 of stack "stackB"
end mouseup

Stack B
---------
on doSomething
   put the customproperties of me into tArray
   .....
end doSomething

Tadam ...
1
2

But I would stay away from this option... too dangerous to use!

------------------------------------------------------------------------ 
------------------------------------

Of interest... this works as well

Stack A
---------
on mouseup
   put "1" into aTest[1]
   put "2" into aTest[2]
   set the customproperties["test"] of button 1 of stack "stackB" to  
aTest
   send "doSomething" to button 1 of stack "stackB"
end mouseup

Stack B
---------
on doSomething
   put the customproperties["test"] of me into tArray
   ...
end doSomething


Multidimensional arrays can be used:
(simply because the array indexes are converted into a string)
   put "1" into aTest[1,2,3]
   put "2" into aTest[2,2,3]
  ...
   combine aResult using cr and tab

Thanks for the brainstorming and the ideas!
Marielle




More information about the use-livecode mailing list