Notifications
Clear all

[Closed] Backup Maxscript??

This is weird…the post was obviously deleted by the hackers or something. Anyway…my original post was:

I got a new external HD not so long ago, i now store my work folder on both my harddrives now. However, sometimes i forget to dump my saved stuff (that i’ve saved on external) to my internal HD. I was wondering is there a maxscript out there where, when you save a file, it saved a copy of that in a certain directory on the other HD at the same time? That way i can come into the lab with my laptop with all the files i need on it. I dont like to bring my external into the lab cos its a bit too big and clunky. Cheers

And somebody was already looking into scripting something to do this…Thanks again

6 Replies

Curently writing it as we speak
It will only save a copy of the max file at this point. Maybe I’ll extend it to make it save all files used later on.

Yea, all post between 6 and 14 may are lost… ah well. :shrug:

Question:

The basic script is nearing completion, only there’s one problem.
Whenever I run the code below and try to enter a text in one of the fields and then call the array I get “undefined”.
However, when I evaluate the same code again I get returned from that array exactly what I entered and it updates nicely with every new change too. When I rename the array it happens again once, but never again after that.

Is this a problem that will only occur when I evaluate the script? If not, what am I doing wrong?

The rollout code:


rollout options_roll "Options" width:320 height:448
(
	
	-- rollout layout
	
	checkbox overwrite_chkb "Ask Before Overwrite" pos:[40,344] width:128 \
	 height:16 checked:true
	checkbox incremental_chkb "Incremental Saves" pos:[40,368] width:128 \ 
	 height:16
	button loc1_button "Get Location #1" pos:[40,168] width:96 height:24 \ 
	 tooltip:"Choose where the original file will be placed"
	button loc2_button "Get Location #2" pos:[40,240] width:96 height:24 \
	 tooltip:"Choose where the copied file will be placed"
	editText base_edittext "Base File Name:" pos:[40,32] width:192 height:20
	editText loc2_edittext "Location #2:" pos:[48,272] width:240 height:20
	editText incr_edittext "Max Increments:" pos:[63,392] width:160 height:20 \
	 enabled:false text:"1000"
	editText loc1_edittext "Location #1:" pos:[48,200] width:240 height:20
	label note1_label "Note: .max extension is automatically added." pos:[48,64] \
	 width:216 height:16
	groupBox file_group "File Name" pos:[16,8] width:288 height:128
	label note2_label "Note: When incremental save is on numbers will be automatially \ 
	 added between the base name and the extension." \
	 pos:[48,80] width:216 height:48
	groupBox location_group "File Location" pos:[16,144] width:288 height:168
	groupBox options_group "Options" pos:[16,320] width:288 height:112
	
	
	-- defines what the buttons etc. do, blabla
	
	on incremental_chkb changed state do
	(
		if state == true then incr_edittext.enabled = true 
		else incr_edittext.enabled = false
	)

	on base_edittext changed txt do
	(
		base = txt
	)

	on loc1_button pressed do
	(
		original_dir = ( getSavePath caption:"Specify the location of the \
		 original file." )
		loc1_edittext.text = original_dir
	)

	on loc2_button pressed do
	(
		copy_dir = ( getSavePath caption:"Specify the location of the copy." )
		loc1_edittext.text = copy_dir
	)

	on loc1_edittext changed txt do
	(
		original_dir = txt
	)

	on loc2_edittext changed txt do
	(
		copy_dir = txt
	)

)
ms = newRolloutFloater "Max Saver v1" 330 470

addRollout options_roll ms


Also, how can I split up strings into readable format? Because “” doesn’t seem to work with strings (you’ll have to make the string of note2_label into a single line, or else it won’t work).

Thanks.

I don’t understand your first problem – what array are you trying to call? I don’t see any arrays defined in the code sample you posted. As to the line break question, you can force line breaks using the
(newline) escape sequence.

Example:

print “this is a
string”
“this is a
string”

RH

I’m sorry, I wasn’t very clear in my last post. It was rather late at that time

But I was talking about something like in this line: original_dir = txt. I thought that when you define A as B then A would be called an array, even though in this case it only has one element. How would you call something like this?

But the problem is that, after evaluating the code, when I type (for example) original_dir in the listener I get returned undefined. However when I close the floater and evaluate again and type original_dir in the listener I get returned what’s in the edittext at that point. After this it updates nicely and returns whatever I have typed in the edittext.
When I change original_dir to original_dir2 and evaluate I get the same problem (undefined) until I evaluate the script again.

About the
. It splits up the string in the output, but I’m trying to split it up in the code so that it won’t mess up the entire layout of this forum
I know “” makes max read the next line as if it’s on the same line, but then the string gets all messed up (see the code I supplied).

But thanks for helping

Ok, I found the solution to the text problem. But for future maxscripters with the same problem: here’s the solution, found in the vast depths of the MaxScript reference.

txt = “line one line one “
txt += “line one /n line two “
txt += “line two!”
print txt

This way long text lines can be split up so they won’t mess up the layout when posted here and still be a single line in the script.

Anyway, I just wanted to say that the code is almost finished and should be ready tomorrow. Don’t expect much though, as it will still only duplicate your max file

I’m fairly new to MaxScript, but I’ll try and help with the “original_dir = txt” problem. It’s a scope issue. Since you first define “original_dir” inside the “on button pressed” section, it’s local to just that section and isn’t retained outside of that. To solve the problem you need to call the variable earlier in the script. Try adding this before the entire rollout section:

local original_dir, copy_dir

This basically tell Max to store these variables on a higher level of the script so that they can be used anwhere.

Bobo posted a really explanation of scope either here or on the Max Webboard. If I come across it I’ll post a link.