functions from the message box

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

Fermin
Posts: 154
Joined: Fri Jun 05, 2015 10:44 pm

functions from the message box

Post by Fermin »

Hi.
I'm probably doing something wrong, but do not know what:

in the script of card:

Code: Select all

function calcular h1,h2
   return h1 + h2
end calcular
---------------------
on calcular h1,h2
   put h1 + h2
end calcular
("calcular" in Spanish means "calculate")
If I call these routines from the code of a button:

Code: Select all

on mouseup
   put calcular (12,3)
end mouseup
or

Code: Select all

on mouseup
   calcular 12,3
end mouseup
The result is 15 in both cases. Right.

But If I call these routines from the message box:

Code: Select all

calcular 12,3
The result is 12. It seems that only computes the first parameter.
And:

Code: Select all

put calcular (12,3)
The result is:

Message execution error:
Error description: Function: error in function handler
Hint: calcular


¿?¿?¿?
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: functions from the message box

Post by Klaus »

Just guessing, but having a function and a handler with the SAME name is asking for trouble! 8)
Does it work when you change the name of your function or handler?
Fermin
Posts: 154
Joined: Fri Jun 05, 2015 10:44 pm

Re: functions from the message box

Post by Fermin »

I do not think so. I put it this way for example purposes. If I change the names or even remove one of the two, I guess it's the same. Anyway you left me with doubt ... As I can I try again :)
Thanks Klaus.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: functions from the message box

Post by Klaus »

Maybe this is just a message hierarchy issue?

When I put this into the message box (and put the curor over my test stack): send "calcular 1,12" to cd 1 of the mousestack
I get 13 in the message box as exspected!

However the error descriptions are really not very helpful, that is true!
Fermin
Posts: 154
Joined: Fri Jun 05, 2015 10:44 pm

Re: functions from the message box

Post by Fermin »

Well, I open one of my stacks. I put in the script of the card, the function

Code: Select all

function calcular h1,h2
   return h1*h2
end calcular
Then create a button and put in his script:

Code: Select all

on mouseUp
   put calcular (22,4)
end mouseUp
Click the button and I get:

88

Ok. Then I open the message box and write:

Code: Select all

put calcular (22,4)
I hit the return key and:

Message execution error:
Error description: Function: error in function handler
Hint: calcular

----
I'm starting to think I'm making a very silly mistake, but I can not see it... :lol:

Thank you for your patience, Klaus
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: functions from the message box

Post by Klaus »

No mistake, I am still convinced this is "just" a message hierarchy issue!
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: functions from the message box

Post by dunbarx »

WHAT IS GOING ON HERE???

Sorry, Ahem.

A single parameter associated with any function call at all, in either the card or stack script works fine:

Code: Select all

put calcular (22)
Forget for a moment that the function no longer does anything useful. At least it runs. But add another parameter, and the msg box version flat out fails. The message does not even start; a breakpoint in the card script does not catch a thing.

Confirmed in v 6.7x. I am going for a walk.

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

Re: functions from the message box

Post by dunbarx »

Klaus.

What is a message hierarchy issue? :shock:

Oh, never mind. It is the end of the world.

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

Re: functions from the message box

Post by dunbarx »

I have no issues with command calls from msg, only function calls.

This is odd, because, and I could be remembering from HC, both types of calls are treated basically the same by the engine.

How has this gone unnoticed (especially by me) for so long? Or is it something relatively new? Anyone able to test in v5? v4?.

Craig
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: functions from the message box

Post by Klaus »

dunbarx wrote:What is a message hierarchy issue? :shock:
Oh, never mind. It is the end of the world.
EX-ACTLY! :D

I am not sure if the message box does put itself somewhere in between the existing message hierarchy
or if it is meant to do so at all!?
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: functions from the message box

Post by Klaus »

Looks like this is a known regression bug, introduced in LiveCode 8.0.1 RC1:
http://quality.livecode.com/show_bug.cgi?id=17800
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: functions from the message box

Post by dunbarx »

Klaus.

Since the beginning of time, the msg box has sent its tidbits directly to the card.

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

Re: functions from the message box

Post by dunbarx »

It cannot be a "regression" if it is an issue in v6. No?

Anyway, I guess it is fixed in the latest v8.

Craig
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: functions from the message box

Post by Klaus »

dunbarx wrote:Since the beginning of time, the msg box has sent its tidbits directly to the card.
Aha, thanks, I was not sure about this!
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: functions from the message box

Post by Klaus »

dunbarx wrote:It cannot be a "regression" if it is an issue in v6. No?
Ask Panos, I was only quoting him! :)
Post Reply