Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    variable or function expected

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 474 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        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:

        _TestFunction(msg)
        {
         println(msg);
        }

        main (doc, op)
        {
          println("About to call the function");
          TestFunction("This is the message");
        }_

        See if that succeeds! 🙂

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          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.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            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

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              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.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 18/05/2011 at 19:20, xxxxxxxx wrote:

                That's pretty sad for COFFEE. 😞

                Got Parser? 🙂

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post