Ho do I make a function with if?
Options
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
Back To Top
Categories
- All Categories
- 18 Welcome
- 949 Hangout
- 56 NI News
- 471 Tech Talks
- 2.5K Native Access
- 11.1K Komplete
- 1.3K Komplete General
- 3K Komplete Kontrol
- 3.9K Kontakt
- 842 Reaktor
- 298 Battery 4
- 611 Guitar Rig & FX
- 325 Massive X & Synths
- 761 Other Software & Hardware
- 4.1K Maschine
- 4.8K Traktor
- 4.8K 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