Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Edittext - needs function or class

Edittext - needs function or class

Anonymous
Not applicable
803 Views
6 Replies
Message 1 of 7

Edittext - needs function or class

Anonymous
Not applicable

I've got a simpleUI here that passes a string from a edit text box to a function.

 

 

 

-- put everything in brackets
(
	local printIt
	
	rollout moveItRollout "" width:230 height:70
	(
		label lbl1 "Enter secret code" pos:[10,10] width:200 height:20
		editText edStr "" pos:[10,40] width:160 height:20
		button btnOK "Okay" pos:[180,40] width:40 height:20

		on btnOK pressed do
		(
			myString = edStr.text as string
			printIt myString
		)
		
		function printIt str =
		(
			print str
		)
	) -- end rollout
	
	createDialog MoveItRollout "" width:230 height:70
)

 

Only it keeps  the error : >> MAXScript Rollout Handler Exception: -- Type error: Call needs function or class, got: undefined

 

I don't know why? Any pointers please?

 

To get around this I've removed the function and but that part of the code within the on button pressed segment.

 

 

0 Likes
Accepted solutions (1)
804 Views
6 Replies
Replies (6)
Message 2 of 7

Steve_Curley
Mentor
Mentor
Probably the order in which things are delared as there's a fairly specific order when dealing with rollouts. This Maxscript help page should give you some clues.
http://help.autodesk.com/view/3DSMAX/2015/ENU/?guid=__files_GUID_608825CD_D025_4054_91E2_2562A6AB31C...

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 3 of 7

blakestone
Collaborator
Collaborator
Accepted solution

This line is invalid:

 

printIt myString

 

It should be:

 

print myString

 

--------------------------------------------------------------------------------------
Technical 3D Graphic Artist
Autodesk 3dsMax 2015 - Service Pack 4
--------------------------------------------------------------------------------------
Message 4 of 7

Steve_Curley
Mentor
Mentor
He's trying to call the printIt function just below passing myString as a parameter - that function has a print statement in it to do the actual printing.
As per the help page I linked, functions should come before event handlers which is what's causing the error (probably - I've not actually tested the code).

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 5 of 7

blakestone
Collaborator
Collaborator

ah of course. yes as you've suggested if you move the PrintIt function above the button pressed then it will work.

--------------------------------------------------------------------------------------
Technical 3D Graphic Artist
Autodesk 3dsMax 2015 - Service Pack 4
--------------------------------------------------------------------------------------
0 Likes
Message 6 of 7

Anonymous
Not applicable

Thanks for that. That's a good reference page as well, which I've managed to overlook because I was searching for "scope" and not "visibility" - which is for object paramaters and Wonder Woman's plane,  that sort of thing.

0 Likes
Message 7 of 7

Steve_Curley
Mentor
Mentor
Not the snappiest title for page I would have to agree, but definitely one to remember 😉

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).