Notifications
Clear all

[Closed] function pointers?

Are we able to do Function pointers in maxscript?

here’s a simple example i can’t get to work…or maybe my syntax is wrong.

(
  	fn SubValue A B =
  		return A-B
  
  	fn AddValue A B =
  		return A+B
  	
  	fn CheckValues CheckFunction=
  	{
  		a = 5 ; b = 6
  	
  		print( CheckFunction(a)(b) )	
  	}
  
  	CheckValues( SubValue )
  	CheckValues( AddValue )
  )
3 Replies

Hi,

You can but you are using curly braces.

Light

haha :rolleyes:.

Ah…there it is. Thats what i get from going back and forth from C#.

Thanks

This is possible because in maxscript, most syntax constructs are expressions, not statements.
In C++, an if statement is a statement:
if (true) …
because it doesn’t return anything.

In Maxscript, and if statement is actually an expression:
foo = if (true) …
Meaning an expression has a left hand side.

Chris J.