Can anyone tell me the problem here? :-)

Can't seem to get this simple example to work. Any help would be much appreicated.

rollout myTest "My test" (
curmaxFileName = maxFileName
newMaxFileName = substring curmaxFileName 1 9
Messagebox (newMaxFileName as string)

)
createDialog myTest

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

In the previous post Panayot

In the previous post Panayot gave you a very detailed explanation about everyting you need to know about "rule of thumb".You need to store all interface functions or structs inside button event or use variables if you want to define your custom function

try(destroyDialog ::testRoll)catch()
rollout testRoll "test"
(
	button render_btn "render"
	on render_btn pressed do
	(
		if renderSceneDialog.isOpen() do renderSceneDialog.close()
		rendSaveFile = on
		rendOutputFilename = (maxFileName + "//" + "sub folder" + "//" + "test.tga")
		max quick render
	)
)
createDialog testRoll 

barigazy

ce89's picture

No probs, I'll keep trying to

No probs, I'll keep trying to work this one out. I was more after general protocols and I guess you are right in that Panayot described some of these quite well. The thing is when you are fairly experienced with all the associated terms everything makes sense straight away.

I will take your advice and look over all these things again. I would post my end goal, but I kind of want to get there with a little help but not have someone do it all for me, hence the guidance and not "can someone write this for me".

Thank you both for your help. I think you have given me a few things to consider and look at.

Anubis's picture

+1

I alsway glad to meet peoples who not ask someone to do their entire job. It's correct to make example code where to isolate the problem. Keep going like this ;)

my recent MAXScripts RSS (archive here)

Anubis's picture

Hi Claire

There a lot of problems in this code :) but then ask question please tell us what's the main aim, else you may get a bit chaotic help :)

What I'll say is almost the same.

* maxFileName is a read-only variable that will be empty string if the current scene is Untitled.

* If you need (by some reason) to show only first 9 characters, need to be sure if the string length is larger than this value.

-- something like this:
strLength = maxFileName.count
curmaxFileName = \
if strLength == 0 then "Untitled" else
(
	if strLength > 9 then
		substring maxFileName 1 9
	else maxFileName
)

* Next but more grave problem is that you try to use Rollout as replacement of Function :) For example, if you just copy/paste my code into the body of your rollout... hehe, read the error message ;)

In the body of the Rollout you can declare local/global variables, functions, etc., but calling functions (and MessageBox is also function) can do that only from some of the Events of the Rollout itself (like #open), or from the Events of UI-controlls inside (like button #pressed, etc.).

Cheers!

my recent MAXScripts RSS (archive here)

ce89's picture

Firstly thanks for the

Firstly thanks for the examples barigazy. Most helpful.

Anubis,

Sorry for the confusion. I left a few other code lines in because I was having problems accessing certain code lines. From a bit more researching I think this has more to do with "scoping" I think? I have looked through the scoping info but it still doesn't seem very clear. Is there any "rule of thumb" to use with scoping if this is the problem.

Another example of what i am testing. This too doesn't work.

try(destroyDialog ::testRoll)catch()
rollout testRoll "test"
(
renderSceneDialog.close()
curmaxFileName = maxFileName + "//" + "sub folder" + "//" + "test.tga"
rendSaveFile = on
rendOutputFilename = curmaxFileName

button render_btn "render"

on render_btn pressed do
(
max quick render
)

)
createDialog testRoll

Many thanks for any help.

barigazy's picture

You need to have saved

You need to have saved current file, and if you want to show messageBox just use

Messagebox (maxFileName) title:"Current File Name" beep:off

or in your case solution with button

rollout testRoll "test"
(
	button btn "Get Current File Name"
	on btn pressed do (Messagebox curmaxFileName)
)
createDialog testRoll style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

or solution when rollaut open

try(destroyDialog ::testRoll)catch()
rollout testRoll "test"
(
	on testRoll open do (Messagebox curmaxFileName)
)
createDialog testRoll style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.