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
- 19 Welcome
- 1.4K Hangout
- 60 NI News
- 762 Tech Talks
- 4K Native Access
- 16.2K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.6K Kontakt
- 1.6K Reaktor
- 373 Battery 4
- 831 Guitar Rig & FX
- 423 Massive X & Synths
- 1.2K Other Software & Hardware
- 5.6K Maschine
- 7.1K Traktor
- 7.1K 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