Notifications
Clear all

[Closed] Why can't this function access my edittext.text?

I’m a bit new to maxscripting, I am trying to make a rollout with a function built in for refreshing the elements of the rollout. For example, I have a read-only edittext box, and a “refresh” button. When I press the refresh button I want the text in the edittext box to change, but it says it is “undefined”. Here’s an example of the code, can someone tell me why it doesn’t work?

rollout tester "tester" width:224 height:140
     (
      fn test_refresh = 
      (
      edit_test.text = "refreshed"
      )
 
      edittext edit_test "Test Text" pos:[8,8] text:"None" width:208 height:16 readOnly:true
      button btn_refresh "Refresh" pos:[160,40] width:48 height:16
     
      on btn_refresh pressed do
      (
       test_refresh()
      )
     )
     
     createDialog tester
2 Replies

Hi,

This is because the function appears before the button is defined.


rollout tester "tester" width:224 height:140
	 (

	  edittext edit_test "Test Text" pos:[8,8] text:"None" width:208 height:16 readOnly:true
	  button btn_refresh "Refresh" pos:[160,40] width:48 height:16
	  fn test_refresh = 
	  (
	  edit_test.text = "refreshed"
	  )	 
	  on btn_refresh pressed do
	  (
	   test_refresh()
	  )
	 )
	 
	 createDialog tester

Josh.

Edit: sorry I made a mistake on the second try, but i found it. Thanks for the help!