ScriptSpot

Forum topic · General Scripting

Bitarrays (Follow array Problem) [SOLVED]

By 3dwannab · 2015-06-23

Description

I'm trying to figure out why the arrays is not following like it's suppose to or at least I think it should. See code below:


try(destroyDialog test)catch()
 
    rollout test "test"
    (
		
			editText fileinfo_lb "Info/Selected File Info:" height:50 align:#right readOnly:true
			multiListBox maxFiles_mlb "Select Max Files to Process:"
			button browseProcess_bt "Browse Directory" align:#left across:2
			checkBox recurse_cb ":Recursive" checked:true align:#center
			editText processDir_et ":" fieldWidth:780 align:#right
		
			Fn getMaxFiles_fn dir = (
				if recurse_cb.checked then (
					local dir1 = getDirectories (dir + "*")
					for d in dir1 do (
						join dir1 (getDirectories (d + "*"))
					)
					local files = #()
					for f in dir1 do (
						join files (getFiles (f + "/*.max"))
					)
					join files (getFiles (dir + "\*.max"))
					return files
				)else (
					files = (getFiles (dir + "\*.max"))
					return files
				)
			)
		
			on browseProcess_bt pressed do (
				if processDir_et.text == "" then (
					path = getSavePath caption:"Choose Directory for Scripts" initialDir:maxFilePath
					if path != undefined then (
						processDir_et.text = path
						getMaxFiles_fn path
						maxFiles_mlb.items = (getMaxFiles_fn processDir_et.text)
					)
				)
				
				else if processDir_et.text != undefined then (
					path = getSavePath caption:"Choose Directory for Scripts" initialDir:processDir_et.text
					if path != undefined then (
						processDir_et.text = path
						getMaxFiles_fn path
						maxFiles_mlb.items = (getMaxFiles_fn processDir_et.text)
					)
				)	
			)
		
			on maxFiles_mlb selected i do (
				--fileinfo_lb.text = fileNameFromPath (maxFiles_mlb.items[i])
				print maxFiles_mlb.items[i] -- = fileinfo_lb.text as string
				--print (maxFiles_mlb.items[i])
			)
    )

createDialog test 800 270 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

Should:


print maxFiles_mlb.items[i]

Not follow the array and print the name of the currently selected file to the listener?

Thanks in advance

Comments (2)

Thank you

3dwannab · 2015-06-25

I knew I needed to do something with a for loop in there. With this fix it works but it also prints out in the listener sometimes the previous selection then the correct selection. See GIF (BTW I got this handy little screen to GIF app if anyones interested.) Made my day this lol.

screenToGif: http://bit.ly/1LxWCWl

Attachments

`

pixamoon · 2015-06-24

try this:


try(destroyDialog test)catch()
 
    rollout test "test"
    (
 
			editText fileinfo_lb "Info/Selected File Info:" height:50 align:#right readOnly:true
			multiListBox maxFiles_mlb "Select Max Files to Process:"
			button browseProcess_bt "Browse Directory" align:#left across:2
			checkBox recurse_cb ":Recursive" checked:true align:#center
			editText processDir_et ":" fieldWidth:780 align:#right
 
			Fn getMaxFiles_fn dir = (
				if recurse_cb.checked then (
					local dir1 = getDirectories (dir + "*")
					for d in dir1 do (
						join dir1 (getDirectories (d + "*"))
					)
					local files = #()
					for f in dir1 do (
						join files (getFiles (f + "/*.max"))
					)
					join files (getFiles (dir + "\*.max"))
					return files
				)else (
					files = (getFiles (dir + "\*.max"))
					return files
				)
			)
 
			on browseProcess_bt pressed do (
				if processDir_et.text == "" then (
					path = getSavePath caption:"Choose Directory for Scripts" initialDir:maxFilePath
					if path != undefined then (
						processDir_et.text = path
						getMaxFiles_fn path
						maxFiles_mlb.items = (getMaxFiles_fn processDir_et.text)
					)
				)
 
				else if processDir_et.text != undefined then (
					path = getSavePath caption:"Choose Directory for Scripts" initialDir:processDir_et.text
					if path != undefined then (
						processDir_et.text = path
						getMaxFiles_fn path
						maxFiles_mlb.items = (getMaxFiles_fn processDir_et.text)
					)
				)	
			)
 
			on maxFiles_mlb selected i do (
				--fileinfo_lb.text = fileNameFromPath (maxFiles_mlb.items[i])
				for a in maxFiles_mlb.selection do print maxFiles_mlb.items[a] -- = fileinfo_lb.text as string
				--print (maxFiles_mlb.items[i])
			)
    )
 
createDialog test 800 270 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)