Page 1 of 1
Custom command with multiple parameters
Posted: Tue Apr 12, 2016 7:52 pm
by guillem
This is my first post btw so: hello all!
I'm trying to make a custom command take two parameters in this fashion:
Code: Select all
command twoParams pOne, pTwo
-- do things with pOne and pTwo
end command
I'm calling it as
twoParams("foo", "bar"), and I was expecting to see that pOne = "foo" and pTwo = "bar" (same as with custom functions), but what I get is pOne = "foo,bar" and pTwo = "". I don't know if I'm not seeing some stupid big obvious typo.
I'm using LC8DP16 on OSX Yosemite (RC1 still downloading, didn't try yet).
Edit: thanks!
Re: Custom command with multiple parameters
Posted: Tue Apr 12, 2016 8:00 pm
by Klaus
Grüezi guillem,
1. welcome to the forum!
2. Hm, you created a COMMAND:
-> command twoParams pOne, pTwo
but call it like a FUNCTION:
-> twoParams("foo", "bar")
Not sure what you are exspecting or what exactly should happen
or how your command returns anything?
Best
Klaus
Re: Custom command with multiple parameters
Posted: Tue Apr 12, 2016 8:11 pm
by guillem
Grüezi wohl, Klaus, and thanks for the welcome!
Well in fact I was not expecting the command to return anything. Elaborating a bit more on my pseudocode:
Code: Select all
command putSomeWordsNicelyAroundTheUI pAlistOfWords pAdifferentListOfWords
-- chew pAlistOfWords and spit it on the card as a navigation menu
-- chew pAdifferentListOfWords and spit it on the card as a secondary navigation menu
end command
Those menus are intended to be different every time the command putSomeWordsNicelyAroundTheUI is called, that's why I wasn't using a function; and I was taking for granted that it was allowed for commands too... Maybe it's just a problem of perspective and I should be trying to do the menus differently.
Re: Custom command with multiple parameters
Posted: Tue Apr 12, 2016 8:33 pm
by dunbarx
Hi.
Step through these:
Code: Select all
on mouseUp
put 3 into param1
put 5 into param2
answer doubleUp(param1,param2)
doubleUp param1,param2
end mouseUp
function doubleUp firstArg,secondArg
return firstArg * 2 & return & secondArg * 2
end doubleUp
on doubleUp firstArg,secondArg
put firstArg * 2 & return & secondArg * 2 into fld 1
end doubleUp
The way commands and functions work is similar, but depends on how you want to use them, and where control is delegated to.
Craig Newman
Re: Custom command with multiple parameters
Posted: Tue Apr 12, 2016 8:46 pm
by guillem
Oh!
It was the parentheses!
I feel stupid now
Thank you Klaus and Craig!
Re: Custom command with multiple parameters
Posted: Tue Apr 12, 2016 9:19 pm
by Klaus
guillem wrote:It was the parentheses!
That's what I meant with "you are calling it like a function"
Glad you got it working now!
Re: Custom command with multiple parameters
Posted: Wed Apr 13, 2016 7:31 am
by guillem
@Klaus,
yes, yes, it makes sense now, but my brain was very busy running into the same wall over and over

Re: Custom command with multiple parameters
Posted: Wed Apr 13, 2016 9:36 am
by Klaus
Switch walls from time to time!

Re: Custom command with multiple parameters
Posted: Wed Apr 13, 2016 10:34 am
by SparkOut
But don't give up either, the wall will come tumbling down in the end.
http://forums.livecode.com/viewtopic.php?p=40553#p40553