Call Function Syntax question

Get help using Construct 2

Post » Fri Feb 08, 2013 3:55 am

What is the correct syntax for calling a function from within an expression when that function is being passed parameters?

I tried:

Functions.Call("Srand(20,90)")

where Srand is my function name, I am passing the minimum and maximum value of the seeded random number to be returned, and I do have the "Set return value to" event set correctly. I only ever get zero though, and no other variation in syntax gets passed C2's error detector.
I know my return value statement is good because the function works perfectly when I get my return value with a separate Functions.ReturnValue event just after the call function event.

Thanks.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Fri Feb 08, 2013 5:21 am

Functions.Call("Srand",20,90)

Your function name is just the first parameter of the Call() function of the Function object (:
If you use this though the return value can be directly assigned to a variable[code]-> System: set myVariable to Functions.Call("Srand",20,90)[/code]
The other way to do it is
[code]-> Function: Call "Srand" (20,90)
-> System: set myVariable to Function.ReturnValue[/code]
Yann2013-02-08 05:25:29
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Feb 08, 2013 6:30 am

Thankyou! That's perfect. I had done it the second way, but I knew it should be able to do it inline.

Thanks a bunch.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go and 21 guests