Notifications
Clear all

[Closed] syntax problem with functions

Hi,
I’m trying to define a simple function and I’m getting a syntax error when I use it in the Listener. I only see the problem when I make the function use the 2nd parameter (log_fs). I’m sure I need to learn a fundamental lesson. Any help is much appreciated. Thanks!

     Here is the function definition (stored in myScript.ms):
fn justLogTheName mtl log_fs =
         (
         	format "the name is: %" mtl.name to:log_fs
         )
     Here is my usage:
fileIn myScript.ms
         ob = selection[1]
         log_fs = openFile log_filename mode:"wt"
         justLogTheName ( ob.material, log_fs )
         
     And this is the confusing error that the Listener shows with the usage above:
      -- Syntax error: at ),, expected <factor>
     --  In line: justLogTheName ( ob.material, l[color=Navy]
    [color=Silver]
   [color=Silver] I was wondering if I needed to use a different function to allocate the filestream, but I am able to use 'log_fs' in the Listener window with no problems, e.g.
   [/color] [/color][/color] 
format "testing the filestream, writing material name: %.
" ob.material.name to:log_fs
 
        OK
        

[color=Navy]
[/color]

1 Reply
justLogTheName ( ob.material, log_fs )

should be

justLogTheName ob.material log_fs

maxscript does not use parentheses around function arguments and the arguments are separated by whitespace, not a comma