Why this line doesn't work?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 06 June 2008   #1
Why this line doesn't work?

Ok, it's not just 1 line...but very simple anyway...

I really want to know why these lines doesn't work in the first run:

(
 fn printTest =
 (
    print "Test"
 )
 a = "printTest()"
 execute a
 )


This is very annoying. I'm creating a script that has an rcMenu with variable items, so I must create them on the fly, but the function calls are not working (but outside they do).

Is there any other method than generating a string and executing it for sruch cases?

Thanks,

Jr.
 
Old 06 June 2008   #2
scope...

You defined the function within ()'s so the function is local to your script. Execute commands work in max's global scope.


  -- function defined globally 
  fn printTest =
      (
      print "Test"
      )
  
  (
  a = "printTest()"
  execute a
  )
  


or


   (
  global printTest
  fn printTest =
      (
      print "Test"
      )
  a = "printTest()"
  execute a
  ) 
   


if your RCmenu items are to be accessed from the standard max quads then all the functions will need to be global...
__________________
Keith R Morrison
www.focus360.com

XP Pro x64, Win 7 - Max 2009, Max 2013 - Vray 2.30.01 - Backburner (uhg)

Last edited by Kramsurfer : 06 June 2008 at 03:48 PM.
 
Old 06 June 2008   #3
The function needs to be defined outside the code block that is executing the code. So define the function as a global outside the code block or the function needs to be in a seperate code block.
(
  fn printTest =
   (
 	print "Test"
   )
 )
 (
  a = "printTest()"
  execute a
 )
or
global printTest
 (
  fn printTest =
  (
 	print "Test"
  )
  a = "printTest()"
  execute a
 )
Hope that makes sense,
-Eric

Edit: Looks like Kramsurfer beat me to the post.
__________________
"The Evil Monkey hiding in your closet."
 
Old 06 June 2008   #4
ha ha... nice post Eric... but I'm faster...
__________________
Keith R Morrison
www.focus360.com

XP Pro x64, Win 7 - Max 2009, Max 2013 - Vray 2.30.01 - Backburner (uhg)
 
Old 06 June 2008   #5
Thanks for the answer guys!

Interesting though, I expected it to work because they were inside the same scope...but I think I got the case...

Regards,

Jr.
 
Old 06 June 2008   #6
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:12 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.