Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/05/2011 at 15:50, xxxxxxxx wrote:
User Information: Cinema 4D Version: 11 Platform: Windows ; Language(s) : C.O.F.F.E.E ;
--------- I'm new to scripting in C4D and I just can't figure out what is wrong with my function definition. If I paste the following code into the Script Manager and click Execute...
_TestFunction(msg) { println(msg); }
println("About to call the function"); TestFunction("This is the message");_
I get the error "[FAIL] Script 'TestScript' Line 1 Pos 14 : Variable or function expected." It seems to happen with every function I try, even ones pasted from examples. Code by itself seems to work ok though.
e.g.
println("About to call the function");
by itself works just fine.
On 18/05/2011 at 16:28, xxxxxxxx wrote:
As far as I know, you can't call functions outside of another function (i.e.: globally) in COFFEE. You usually start with main() and call other functions which call other functions or functions in class instances.
Every script starts with:
main(doc,op) { }
Every COFFEE plugin has a:
main() { }
Therefore, try something like this:
main (doc, op) { println("About to call the function"); TestFunction("This is the message"); }_
See if that succeeds!
On 18/05/2011 at 16:57, xxxxxxxx wrote:
Thanks for your quick response kuroyume. I tried your code, but unfortunately I get exactly the same error. A friend of mine has just tried it in C4D V12 and he gets the same error as me. It's strange, it seems to reject any function definitions.
On 18/05/2011 at 17:00, xxxxxxxx wrote:
You have spaces within the main(doc , op) part that breaks it. Try (works here) :
TestFunction(msg) { println(msg); } main(doc,op) { println("About to call the function"); TestFunction("This is the message"); }
Cheers Lennart
On 18/05/2011 at 17:13, xxxxxxxx wrote:
You're right. The space in the main function before the bracket breaks it. Although the error message is not very helpful!
Thanks for your help.
On 18/05/2011 at 19:20, xxxxxxxx wrote:
That's pretty sad for COFFEE.
Got Parser?