Ho do I make a function with if?

mr_blond97
Member Posts: 2 Newcomer
I make a function that contains if:
on init message(Add(1,2)) end on function Add(x,y) -> output if x > 0 output := x + y else output := 0 end if end function
And I get the error message:
The definition of function Add needs to consist of a single line (eg. "result := <expr>") in order to be used in this context
Ho do I make a function with if?
Tagged:
0
Best Answer
-
You cannot call a function within another command like that, you need to store the output of it to a variable. So:
var = Add(x, y) message(var)
0
Answers
-
You cannot call a function within another command like that, you need to store the output of it to a variable. So:
var = Add(x, y) message(var)
0 -
Thank you!
on init declare $var $var := Add(1, 2) message(var) end on function Add(x,y) -> output if x > 0 output := x + y else output := 0 end if end function
0
Back To Top
Categories
- All Categories
- 21 Welcome
- 761 Hangout
- 73 NI News
- 361 Tech Talks
- 1.6K Native Access
- 7.3K Komplete
- 940 Komplete General
- 1.7K Komplete Kontrol
- 2.7K Kontakt
- 664 Reaktor
- 232 Battery 4
- 401 Guitar Rig & FX
- 265 Massive X & Synths
- 397 Other Software & Hardware
- 3.1K Maschine
- 23 Sampling Room
- 3.8K Traktor
- 3.6K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators