Page 1 of 1

Return value from a handler two commands away

Posted: Mon Sep 15, 2014 10:27 pm
by jalz
Hi Guys,

I need to get a value returned from the Footer handler into my MouseUp handler. However the footer is called from the CreatPage handler. Is there an efficient way of doing this, or do I have to process the return in the create page and then return that returned value to the mouse up.

Code: Select all

command Footer tCardName, tPaperHeight, tPaperWidth

   some processing
   
   return (tFooter - 30)
   
end Footer


command CreatePage tPageNo,tPaperWidth,tPaperHeight
   
   -------<Copy header and footer detail>-----------
   
   Footer tCardName, tPaperHeight, tPaperWidth
   put the result into tFooter
   
end CreatePage


on mouseUp
   lock screen

   -- deleted a lot of variables which set tPaperHeight, tPaperWidth etc.
   -- I need the return value from Footer to go into tMaxPageBottom
   put (tPaperHeight - 110) into tMaxPageBottom
   

   CreatePage tPageNo, tPaperWidth, tPaperHeight
   

end mouseUp

Thanks

Jalz

Re: Return value from a handler two commands away

Posted: Mon Sep 15, 2014 11:15 pm
by dunbarx
Hi.

A couple of ways.

1- Do you need three handers? If these are not called from other places, why not run the whole thing from "mouseUp"?

2- Make the two handers functions instead. These can then be called from elsewhere if needed (as per the query above), and if invoked from the original "mouseUp" handler, control will return back where it started. You can have all your returned data back where it belongs.

Craig Newman

Re: Return value from a handler two commands away

Posted: Mon Sep 15, 2014 11:22 pm
by FourthWorld
3. For many content creation tasks, LiveCode's merge function is very handy.

Re: Return value from a handler two commands away

Posted: Tue Sep 16, 2014 3:27 pm
by jalz
Thanks alot guys, I've refactored and got it to run through 2 handlers now.

I'll do some reading on the merge function. Sounds like something useful to know.

Jalz