Notifications
Clear all

[Closed] macro is not seeing rollout definition at startup

Hi,
Max does not seem to think my rollout is defined when my macro tries to use (include) it. The Max error is:
error: addRollout requires RolloutClass, got: undefined

I’ve defined a .mcr file and it includes a rollout I’ve defined in a .ms file. If I mess around in the Listener window using ‘filein’ to load scripts the .mcr script, I have no problems. However, if I ONLY use the ‘Startup’ folder to launch a script which uses ‘filein’ to load the .mcr and .ms scripts when Max starts, I see problems when I click the button I placed on my toolbar to launch the .mcr. Max says my Rollout class is not defined when I click the toolbar button linked to my .mcr. This .mcr includes the rollout class definition in the same manner as other .mcr files I have in the same folder. These other toolbar buttons are working with no problems. Does anyone see an issue? Many thanks for any help!

  My startup scripts (2)
  1- Scripts/Startup/STI_start.ms
filein "STI/startup_loader.ms"
     
  2- Scripts/STI/startup_loader.ms
-- this one works fine at startup
     -- the OgreMax material duplication utility's dependencies
     filein "materialDuplicator.ms"
     filein "ui_material_duplicator.ms"
     filein "macro_duplicate_materials.mcr"
     
     -- this is the new one that will not work after many restarts
     -- the OgreMax material technique duplication utility's dependencies
     filein "AddTechniquesUtils.ms"
     filein "AddTechniques.ms"
     filein "ui_technique_duplicator.ms"
     filein "macro_duplicate_materials.mcr"
     
 My broken .mcr file (Scripts/STI/macro_duplicate_techniques.mcr)
include "ui_technique_duplicator.ms"
     
     MacroScript OgreMax_DuplicateTechniques category:"STI" tooltip:"Duplicate OgreMax Techniques"
     (
     	on execute do
     	(
     		myFloater = newRolloutFloater  "Duplicate OgreMax techniques" 250 350
     		addRollout Rollout_for_OgreMax_Technique_Duplicator myFloater
     	)
     
     	on closeDialogs do
     	(
     		--destroyDialog repathRollout
     	)
     
     	on isChecked do
     	(
     		false
     	)
     )
     
The code that defines that Rollout that the above .mcr file is not seeing
(Scripts/STI/ui_technique_duplicator.ms)
include "AddTechniques.ms"
    
    rollout Rollout_for_OgreMax_Technique_Duplicator "Duplication parameters" width:232 height:296
    (
    	button btn2 "Run" pos:[92,264] width:48 height:24
    	label lbl2 "Technique Duplicator" pos:[64,16] width:103 height:24
    	editText _source "source" pos:[8,64] width:205 height:32
    	editText _duplicated "duplicated" pos:[5,104] width:205 height:32
    	editText _association_file "association file" pos:[9,192] width:205 height:32
    	button btn4 "Browse" pos:[152,152] width:56 height:32
    	groupBox grp5 "Name Techniques" pos:[3,48] width:224 height:96
    
    	on btn2 pressed  do
    	(
    		addTechniques _source.text _duplicated.text _association_file.text
    	)
    	
    	on btn4 pressed do
    	(
    		file_path = getOpenFileName caption:"Browse for shader associations:" filename:_association_file.text
    		
    		if file_path != null do
    		(
    			_association_file.text = file_path
    		)
    	)
    )
    
 My functioning .mcr file (Scripts/STI/macro_duplicate_techniques.mcr)
(rollout code is too big to show, but the include is all that should matter I think)
include "ui_material_duplicator.ms"
     
     MacroScript OgreMax_DuplicateMaterials category:"STI" tooltip:"Duplicate OgreMax Materials"
     (
     	on execute do
     	(
     		myFloater = newRolloutFloater  "Duplicate OgreMax materials" 360 610
     		addRollout OgreMax_MaterialDuplicator_Rollout myFloater
     	)
     
     	on closeDialogs do
     	(
     		--destroyDialog repathRollout
     	)
     
     	on isChecked do
     	(
     		false
     	)
     )
     
4 Replies

doubled

actually it’s not right way to do this kind of things but the moving of include inside macro has to solve the problem…
the right way is not using any include in mcr file, but define rollout’s name as global, and use whatever will be created by startup script.

 lo1

It seems the rollout is being defined in global scope so technically this should work.

Try using

addRollout ::Rollout_for_OgreMax_Technique_Duplicator myFloater

and see if it makes a difference.

@denisT: thanks for the tip about making my rollout classes global instead of writing an include statement. I’ll definitely start doing that.

I actually realized the issue as soon as I clicked ‘submit’, but I have not been able to respond for 2 days because of the server being busy or some crap.

The problem, as it turns out, was that I copied and pasted the the startup commands (filein) for a working macro, but forgot to change the file name on one of them. What a ‘doh!’ moment. I should have had this:
filein “macro_duplicate_techniques.mcr”

Thanks for trying to help guys.