send variable between 2 scripts

Hi
I am trying to send a variable from one script to another.

When I click on script "test02", I activate "test03". I want "test03" to send the variables to "test02" to display BatchNumberLoading, BatchNumberTotal and Progressbar. It is to follow the export.

I reduced my code to focus on my problem

I know that the code below is not well placed,I do not know where to place it

 
BatchNumberTotal.text= theFilesNumber as string 
BatchNumberLoading.text= theFilesCurrent as string 

But the mark value received is "undefined"

Do you have an idea? Thx

Test02.ms

 
(
 
-- 	BatchNumberTotal.text = theFiles as string
-- 	BatchNumberLoading.text = f as string
	PathBatchMAX = "C:\Users\PC_new\Documents\Perso\Script\Test03.ms" 
 
 
	rollout test02 "test02"
	(	
 
		group ".max" (
		button btn_SaveMaxBatch "Batch copy" align:#right toolTip:"Current version useless and 3 previous versions!"
		)
 
		label BatchNumberLoading "No Value" align:#right across:3
		label BatchNumberSeparate "/" align:#center width:10
		label BatchNumberTotal "No Value" align:#left
		Progressbar loading color: [169,38,158]  height:20 align:#right 
 
		on btn_SaveMaxBatch pressed do 
			(
 
 
 
				fileIn PathBatchMAX
 
				BatchNumberTotal.text= theFilesNumber as string 
				BatchNumberLoading.text= theFilesCurrent as string 
 
			)	
 
	) -- end rollout
	createDialog test02 220 120
)

Test03.ms

 
 Clearlistener()
 
(	
	thePath = getSavePath()--get a path dialog to specify the path
	if thePath != undefined do--if the user did not cancel
	(
		theFiles = getFiles (thePath+"\\*.max") --collect all max files in the dir.
		theFilesNumber=theFiles.count
		theFilesCurrent=theFilesNumber-theFilesNumber
 
		print (theFilesCurrent as string + "/" + theFilesNumber as string)
 
		for f in theFiles do-- go through all of them
		(
			loadMaxFile f--load the next file
 
	-----------------------------------------------------------
	-- MAKE SOME SCRIPTED CHANGES TO THE SCENE HERE...
	-----------------------------------------------------------
 
		-----------------------------------------
		-- SAVE MAX START
		-----------------------------------------
 
-- 		temp_node = box()
-- 		temp_node.name = substituteString maxfilename ".max" ""
-- 		fileName = temp_node.name
-- 		delete temp_node					
-- 		saveMaxFile (MaxFilePath+fileName+"_new.max") useNewFile:false
-- 		print (fileName) 
 
		-----------------------------------------
		-- SAVE MAX END
		-----------------------------------------	
 
		-----------------------------------------
		-- COUNT StART
		-----------------------------------------	
		theFilesCurrent=theFilesCurrent +1
 
		fileNameCurrent=substituteString f thePath ""
		-----------------------------------------
		-- COUNT END
		-----------------------------------------	
		print (theFilesCurrent as string + "/" + theFilesNumber as string)
		print (fileNameCurrent as string + " SAVE")
		)--end f loop
 
	  resetMaxFile #noPrompt --at the end, you can reset
-- 	  BatchNumberTotal=theFiles 
	)--end if
 
 
)
 

Comments

Comment viewing options

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

Thank you for your answer.

Thank you for your answer. It's good!

I added Progressbar and scene name loading.

Thx again ;)

(
	global test02
 
	PathBatchMAX = "C:\Users\PC_new\Documents\Perso\Script\Test03.ms" 
 
	rollout test02 "test02"
	(	
 
		group ".max" (
		button btn_SaveMaxBatch "Batch copy" align:#right toolTip:"Current version useless and 3 previous versions!"
		)
 
		label BatchNumberLoading "No Value" align:#right across:3
		label BatchNumberSeparate "/" align:#center width:10
		label BatchNumberTotal "No Value" align:#left
		Progressbar loadingbar color: [169,38,158]  height:20 align:#right 		
		label LoadingCurrentName "No Value" align:#center
 
		on btn_SaveMaxBatch pressed do 
			(
				fileIn PathBatchMAX
			)	
	) -- end rollout
	createDialog test02 220 120
)
(	
	thePath = getSavePath()--get a path dialog to specify the path
 
	if thePath != undefined do--if the user did not cancel
	(
 
 
		theFiles = getFiles (thePath+"\\*.max") --collect all max files in the dir.
		theFilesNumber=theFiles.count
		theFilesCurrent=theFilesNumber-theFilesNumber
 
 
		print (theFilesCurrent as string + "/" + theFilesNumber as string)
		print (theFilesCurrentpercent as string + "%")
 
 
		for f in theFiles do-- go through all of them
		(
			loadMaxFile f--load the next file
 
	-----------------------------------------------------------
	-- MAKE SOME SCRIPTED CHANGES TO THE SCENE HERE...
	-----------------------------------------------------------
 
		fileNameCurrent=substituteString f thePath ""
		::test02.LoadingCurrentName.text= fileNameCurrent as string 
 
		-----------------------------------------
		-- COUNT StART
		-----------------------------------------	
		theFilesCurrent=theFilesCurrent +1
		theFilesCurrentpercent=theFilesCurrent*100/theFilesNumber
		-----------------------------------------
		-- COUNT END
		-----------------------------------------	
 
		print (theFilesCurrent as string + "/" + theFilesNumber as string)
		print (theFilesCurrentpercent as string + "%")
		print (fileNameCurrent as string + " SAVE")
 
		::test02.BatchNumberTotal.text= theFilesNumber as string 
		::test02.BatchNumberLoading.text= theFilesCurrent as string
		::test02.loadingbar.value= theFilesCurrentpercent as integer
 
 
		)--end f loop
 
		resetMaxFile #noPrompt --at the end, you can reset
	)--end if
 
)
miauu's picture

.

Test this:

(
	global test02
-- 	BatchNumberTotal.text = theFiles as string
-- 	BatchNumberLoading.text = f as string
	PathBatchMAX = "C:\Users\PC_new\Documents\Perso\Script\Test03.ms" 
 
 
	rollout test02 "test02"
	(	
 
		group ".max" (
		button btn_SaveMaxBatch "Batch copy" align:#right toolTip:"Current version useless and 3 previous versions!"
		)
 
		label BatchNumberLoading "No Value" align:#right across:3
		label BatchNumberSeparate "/" align:#center width:10
		label BatchNumberTotal "No Value" align:#left
		Progressbar loading color: [169,38,158]  height:20 align:#right 
 
		on btn_SaveMaxBatch pressed do 
		(
			fileIn PathBatchMAX
		)	
 
	) -- end rollout
	createDialog test02 220 120
)
Clearlistener()
 
(	
	thePath = getSavePath()--get a path dialog to specify the path
	if thePath != undefined do--if the user did not cancel
	(
		theFiles = getFiles (thePath+"\\*.max") --collect all max files in the dir.
		theFilesNumber=theFiles.count
		theFilesCurrent=theFilesNumber-theFilesNumber
 
		print (theFilesCurrent as string + "/" + theFilesNumber as string)
 
		for f in theFiles do-- go through all of them
		(
			loadMaxFile f--load the next file
 
	-----------------------------------------------------------
	-- MAKE SOME SCRIPTED CHANGES TO THE SCENE HERE...
	-----------------------------------------------------------
 
		-----------------------------------------
		-- SAVE MAX START
		-----------------------------------------
 
-- 		temp_node = box()
-- 		temp_node.name = substituteString maxfilename ".max" ""
-- 		fileName = temp_node.name
-- 		delete temp_node					
-- 		saveMaxFile (MaxFilePath+fileName+"_new.max") useNewFile:false
-- 		print (fileName) 
 
		-----------------------------------------
		-- SAVE MAX END
		-----------------------------------------	
 
		-----------------------------------------
		-- COUNT StART
		-----------------------------------------	
		theFilesCurrent=theFilesCurrent +1
 
		fileNameCurrent=substituteString f thePath ""
		-----------------------------------------
		-- COUNT END
		-----------------------------------------	
		print (theFilesCurrent as string + "/" + theFilesNumber as string)
		print (fileNameCurrent as string + " SAVE")
 
		::test02.BatchNumberTotal.text= theFilesNumber as string 
		::test02.BatchNumberLoading.text= theFilesCurrent as string 
 
 
		)--end f loop
 
	  resetMaxFile #noPrompt --at the end, you can reset
-- 	  BatchNumberTotal=theFiles 
	)--end if
 
 
)

Or make the theFilesNumber and theFilesCurrent global so both script to have access to them.

Comment viewing options

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