to get full path in listbox

this is good scripter source .
that is directory list box script.

when i select list box item ,i would like to know full path name .

first of all , pls make directory in c

c:temp - a - aa
- b - bb
- c - cc
- d - dd

 
 
------------------------------------------------------------------------
 
materialib_path = "c:\\temp\\"
 
paths_array = #()
paths_array_list = #()
current_files = #()
bitmap_count = #()
 
fn matlist a b = ()
fn get_info = ()
 
 
 
 
fn build_paths path count =
(
	count = count + 1
	append paths_array path 
	append paths_array_list count
	dir_array = GetDirectories (path  + "*")
	if dir_array.count > 0 then
	(
		for i = 1 to dir_array.count do
		(
			build_paths dir_array[i] count
		)
	)
 
	return paths_array
)
 
fn makeoffsets li =
(
	list = deepcopy li
	for i = 1 to list.count do
	(
		ins = ""
		level = 1
		while level < paths_array_list[i] do
		(
			level = level + 1
			ins = ins + "     "
		)
		list[i] = ins + list[i]
	)
	return list
)
 
fn format_list list =
(
	r = deepcopy  list
	if r.count != 0 then
	(
		for i = 1 to r.count do
		(
			l = r[i]
			res = filterString l "\\"
			r[i] = res[(res.count)]
		)
	)
	return r
)
 
fn format_extensions list = 
(
	r = deepcopy list
	for i = 1 to r.count do
	(
		r[i] = (filterString r[i] ".")[1]
	)
	return r
)
 

rollout materialib_rollout "111_materiaLIB v0.2" width:300 height:910
(
	listbox lbx1 "categories:" pos:[2,24] width:160 height:55 items:#("ddd", "eee")
 
 
 
	on materialib_rollout open do 
	(
 
		matlist 1 materialib_rollout
 
		paths_array = #()
		build_paths materialib_path 0
		lbx1.items =  makeoffsets (format_list paths_array)
 
 
 
 
 
	)
 
	on lbx1 selected sel do
	(
		matlist sel materialib_rollout
 
		paths_array = #()
		ssss = #()
		build_paths materialib_path 0
		lbx1.items =  makeoffsets (format_list paths_array)
 
 
 
	)
	on lbx1 doubleClicked sel do
	(
 
	)
 
on lbx2 selected sel do
	(
 
 
 
 
 
	)
 
 
 
 
on lbx2 doubleClicked sel do
	(
 
	)
 
)
 
fn matlist sel materialib_rollout =
(
	try
	(
 
	)
	catch
	(
 
	)
)
 
fn get_file_count file =
(	
 
)
 
 
 
fn get_info sel materialib_rollout =
(
		try
		(
 
		)
		catch 
		(
 
		)
 
 
		try
		(
 
		)
		catch
		(
			try
			(
 
			)
			catch
			(
 
 
			)
		)
 
 
 
 
 
 
 
)
 
 
 
createdialog materialib_rollout style:#(#style_minimizebox, #style_titlebar, #style_sysmenu)
 
 

Comments

Comment viewing options

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

.

I doubt that someone will check your code. Use

"["code"]" "["/code"]"

without the quotes and paste the cede between the tags so it can be readalbel.

You can solve your problem this way:
- create one array that contains the name of the folders(as in your example - "temp")
- create another array that contains the full paths to the folders.
Example:
pathsArr = #("temp", "matLib_01", "matLib_02")
fullPathsArr = #("c:\temp", "C:\myFolder\matLib_01","D:\matLib_02")

pathsArr will be shown in the listbox. When you select an item in the listbox somewere in the UI will be displayed the approriate path from the fullPathsArr. So:
the first item is selected - show the first element from the fullPathsArr
the 7-th item is selected - show the 7-th element from the fullPathsArr

Listbox and multilistbox can't shows tooltips, so you have to use another way to show the full path(show it in the label or in the edittext control).

dussla's picture

that folder is random

i can't array
because i will use random folder , i can;t array

folder tree is very complex
so i can't make always

example )
there is root folder - sub folder (20 pers) - sub folder (20 pers).....

i can't make array manualy

can i make automatic array about a certain folder ?
sorry my poor english

miauu's picture

.

See what the FORMAT will prints in the listener and try to udenrstand what I had suggest you in my previous post.
There is no need to create the arrays manualy. The script will create them for you.

The solution:

 
------------------------------------------------------------------------
 
materialib_path = "D:\\"
 
paths_array = #()
paths_array_list = #()
current_files = #()
bitmap_count = #()
 
fn matlist a b = ()
fn get_info = ()
 
 
 
 
fn build_paths path count =
(
	count = count + 1
	append paths_array path 
	append paths_array_list count
	dir_array = GetDirectories (path  + "*")
	if dir_array.count > 0 then
	(
		for i = 1 to dir_array.count do
		(
			build_paths dir_array[i] count
		)
	)
 
	return paths_array
)
 
fn makeoffsets li =
(
	list = deepcopy li
	for i = 1 to list.count do
	(
		ins = ""
		level = 1
		while level < paths_array_list[i] do
		(
			level = level + 1
			ins = ins + "     "
		)
		list[i] = ins + list[i]
	)
	return list
)
 
fn format_list list =
(
	r = deepcopy  list
	if r.count != 0 then
	(
		for i = 1 to r.count do
		(
			l = r[i]
			res = filterString l "\\"
			r[i] = res[(res.count)]
		)
	)
	return r
)
 
fn format_extensions list = 
(
	r = deepcopy list
	for i = 1 to r.count do
	(
		r[i] = (filterString r[i] ".")[1]
	)
	return r
)
 

rollout materialib_rollout "111_materiaLIB v0.2" width:300 height:910
(
	edittext et_showFullPath "" text:"" 
	listbox lbx1 "categories:" pos:[2,24] width:160 height:55 items:#("ddd", "eee")
 
	on materialib_rollout open do 
	(
 
		matlist 1 materialib_rollout
 
		paths_array = #()
		build_paths materialib_path 0
		format ": % \n" paths_array
		format ": % \n" (format_list paths_array)
		format ": % \n" (makeoffsets (format_list paths_array))
		lbx1.items =  makeoffsets (format_list paths_array) 
	)
 
	on lbx1 selected sel do
	(
		et_showFullPath.text = paths_array[sel]
	)
	on lbx1 doubleClicked sel do
	(
 
	)
 
	on lbx2 selected sel do
	(
 
	)
 
	on lbx2 doubleClicked sel do
	(
 
	) 
)
 
fn matlist sel materialib_rollout =
(
	try
	(
 
	)
	catch
	(
 
	)
)
 
fn get_file_count file =
(	
 
)
 
 
 
fn get_info sel materialib_rollout =
(
		try
		(
 
		)
		catch 
		(
 
		)
 
 
		try
		(
 
		)
		catch
		(
			try
			(
 
			)
			catch
			(
 
 
			)
		)
 
 
 
 
 
 
 
)
 
 
 
createdialog materialib_rollout style:#(#style_minimizebox, #style_titlebar, #style_sysmenu)
 
dussla's picture

really really really thank you , one more questio n

really thank you

can i ask question more ?

if i put file list in listbox

example)

i put list box item
with using getFiles (paths_array[sel]+"*.*")

after that
when i select item , how can i item extension ?
what item's file extention is ms or jpg or bmp .....

can you understand ?

miauu's picture

.

IF you use the same code then add another editText control and when you click on an item in the listbox this will show the file type(extension) in the textbox.

et_fileType.text = getFilenameType paths_array[sel]
dussla's picture

sorry many ask , there is ask also

sorry my many ask
i tried many time , but my skill is not good

1)
current_files = getFiles (paths_array[sel]+"*.max|*.jpg")

why does that work ?

2)

about tree structre

there is directory

temp-aaa-bfff
temp-bbb-deee
temp-ccc-eeee

i would like to show 2 level tree only in listbox

example) list box showing

temp
aaa
bbb
ccc

it is tree level skill
can you understand my word ?
sorry many ask again ~

miauu's picture

.

Because getFiles can have only one file extension as parameter.
You have to use:

getFiles (paths_array[sel]+"*.max")

or

getFiles (paths_array[sel]+"*.jpg")

or

getFiles (paths_array[sel]+"*.*")

and then separating the files by their extension.

dussla's picture

really thank you

really really really sorry
can i ask again

list box 1 can key arrow down up

but
list box2 can;t not that

can i get reason ?

miauu's picture

.

Post the code.

dussla's picture

that solved

sorry
work is good
because of function error , that did not work
now work well
really really thank you

Comment viewing options

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