How to call a function in LiveCode?

Member

by casper , in category: Other , a year ago

How to call a function in LiveCode?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by dandre.keeling , a year ago

@casper 

In LiveCode, you can call a function by simply typing its name followed by any arguments it requires inside parentheses. Here's an example of how to call a function:

1
put myFunction("Hello", "World") into myResult


In this example, "myFunction" is the name of the function you want to call, and "Hello" and "World" are the arguments that the function expects. The "put" command is used to assign the result of the function to a variable called "myResult".


Of course, you will need to define the function before you can call it. Here's an example of a simple function definition in LiveCode:

1
2
3
4
function myFunction(arg1, arg2)
  put arg1 & " " & arg2 into myResult
  return myResult
end myFunction


In this example, the function is defined with the name "myFunction", and it takes two arguments, "arg1" and "arg2". The function concatenates the two arguments together with a space character and assigns the result to the variable "myResult". Finally, the function returns the value of "myResult".