Where can I find information regarding functions

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
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Where can I find information regarding functions

Post by shawnblc » Sun May 19, 2013 2:05 pm

Where can I find information regarding functions? I'm looking on how to use them, when to use them, etc for a complete beginner.

Thanks.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Where can I find information regarding functions

Post by jmburnod » Sun May 19, 2013 2:28 pm

Hi Shawnbic,

There is some infos into the dictionary with one example

Here is a very simple to get the result of an addition

on mouseUp
put AddTwoValue(1,2)
end mouseUp

function AddTwoValue pVal1,pVal2
return pVal1 + pVal2
end AddTwoValue

Best regards
https://alternatic.ch

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Where can I find information regarding functions

Post by Dixie » Sun May 19, 2013 6:18 pm

Shawn...

Have a read of p.134 of the User Guide... 'Custom Commands & Functions'

Dixie

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: Where can I find information regarding functions

Post by shawnblc » Sun May 19, 2013 6:28 pm

Dixie wrote:Shawn...

Have a read of p.134 of the User Guide... 'Custom Commands & Functions'

Dixie
Excellent. Thank you Dixie.

I knew I saw something on it before, but couldn't remember where I saw it, the user guide is exactly where I saw it. Gonna read it again now. Thanks again.

SimpleLife
Posts: 15
Joined: Sat Jul 28, 2012 6:48 pm

Re: Where can I find information regarding functions

Post by SimpleLife » Wed May 29, 2013 1:41 am

which is the link to the user guide :-(

I'm puzzled.

I have added a function to my CARD script, the card is call "mycard"

The function is called "myfunction"

function myfunction
put "hello world" into field "status"
end myfunction

When I use an image script to call myfunction, all variations complain they can't find it (except dispatch which shows no errors)

//dispatch "myfunction" to card "myCard"
//send "myfunction" to "myCard"
//send to "myfunction" of card "myCard"
//call "myfunction"
call "myfunction" to card "myCard"

As you can see, i am not sure of the correct syntax, but I seem to have tried all of the examples.

This must be so simple I can not see it :-(

Any ideas?

makeshyft
Posts: 221
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: Where can I find information regarding functions

Post by makeshyft » Wed May 29, 2013 1:50 am

what are u trying to do?
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

SimpleLife
Posts: 15
Joined: Sat Jul 28, 2012 6:48 pm

Re: Where can I find information regarding functions

Post by SimpleLife » Wed May 29, 2013 2:55 am

What I said.

I'm just trying to call a function in the card scripts, from a button/image in the main stack.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Where can I find information regarding functions

Post by jmburnod » Wed May 29, 2013 9:24 am

Hi SimpleLife,

You open the user guide with the help menu.
A function return a value

Try this:
In the cd or stack script
function myfunction
return "hello world"
end myfunction

In the control script
on mouseup
put myfunction() into fld "status"
end mouseup

Best regards
Jean-Marc
https://alternatic.ch

SimpleLife
Posts: 15
Joined: Sat Jul 28, 2012 6:48 pm

Re: Where can I find information regarding functions

Post by SimpleLife » Wed May 29, 2013 10:57 am

HUGE THANKS Jean-Marc :-)


that was the clue I needed!

It was just the missing brackets for the function

call myfunction()

now works - YAY!

Post Reply