Return value from a handler two commands away

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Return value from a handler two commands away

Post by jalz » Mon Sep 15, 2014 10:27 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Return value from a handler two commands away

Post by dunbarx » Mon Sep 15, 2014 11:15 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Return value from a handler two commands away

Post by FourthWorld » Mon Sep 15, 2014 11:22 pm

3. For many content creation tasks, LiveCode's merge function is very handy.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Return value from a handler two commands away

Post by jalz » Tue Sep 16, 2014 3:27 pm

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

Post Reply