Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MaxScript: Function pointers?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
istan
551 Views, 2 Replies

MaxScript: Function pointers?

I have an understanding problem..

struct tTest (
  fnptr = undefined,
	
  fn tst = (
	fnptr()
  ),
  fn setfnptr func = (
	fnptr = func  
  )
)
fn TestFoo = ( print "TestFoo" )

foo = tTest()
foo.setfnptr TestFunc
foo.tst()

Why is "TestFoo" printed out twice?

 

btw, the foll. does the same:

xyx = TestFoo
xyx()

How can I be sure, the function will only be called once?

 

2 REPLIES 2
Message 2 of 3
Swordslayer
in reply to: istan

It's called once, every function in maxscript returns something, you could just as well write it as fn TestFoo = return (print "TestFoo"), and the return value for print is the string it prints. Maxscript listener shows the return values of everything that gets executed in global scope and of the last expression in local scope. If the function was for example fn TestFoo = (print "TestFoo"; OK), it would print the string and return OK.

Message 3 of 3
istan
in reply to: Swordslayer

ahhh and oups.. I forgot about that.. Thanks.. C++ is so much easier for me..

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report