Ho do I make a function with if?

mr_blond97
Member Posts: 2 Member
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
This discussion has been closed.
Back To Top
Categories
- All Categories
- 18 Welcome
- 1.6K Hangout
- 66 NI News
- 863 Tech Talks
- 4.4K Native Access
- 17.7K Komplete
- 2.1K Komplete General
- 4.6K Komplete Kontrol
- 6.1K Kontakt
- 1.6K Reaktor
- 398 Battery 4
- 894 Guitar Rig & FX
- 456 Massive X & Synths
- 1.4K Other Software & Hardware
- 6.2K Maschine
- 7.9K Traktor
- 7.9K 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