Notifications
Clear all

[Closed] listbox help

Hi guys,

I’m trying to do something quite simple but i don’t manage so far…I’ve created a rollout with a listBox object, in the listbox im trying to display a set of subfolders that exist in a folder,
and it does work but i’m getting the whole path to those subfolders, instead of only the name of the subfolders, is there any way to do that? I just can’t seem to find it…

any help really appreciated!

cheers
Alex

16 Replies
 lo1
pathConfig.stripPathToLeaf @"C:\folder\subfolder\"
--returns "subfolder\"

or something like will do the same thing…

filenameFromPath "g:/subdir1/subdir2/"

or

filenameFromPath @"g:\subdir1\subdir2\"
1 Reply
 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

Nope, returns “”.

works for me

 lo1

Guess it’s a version issue…

it never worked for me this way. honestly i don’t understand why it works for you.

what can I say magic max ?

thanks for the help guys, both methods worked fine for me!

I have another question, this time more complex i guess? I have a rollout with 3 listbox in it
the first listbox shows a bunch of folders on the hardDrive, let’s say A B and C, I’ve created a button and an editText so you can enter some text, press the button, and a new folder is created on the same location. Now, lets say inside each folder A, B and C there are subfolders, A01, A02, B01,B02 and so on…now when I click on an item of the first listbox ( which shows the folders A B and C, I want the second listbox to show the subfolders in the selected item on the first listbox…is there a way to do that with listbox or should I be looking at something else? I’m a bit lost there…so far I’ve managed to show the folders on the first listbox but I’m not sure how to make that on clicking any item , the second listbox shows those subfolders for that item…

thanks again

If you keep the original directories in an array for example, you can use getDirectories to get their subdirectories. But maybe it would make more sense to use treeview instead.

ok i managed to keep working on this and this is where i am at the moment…

I did work a bit more on this and I’m really confused now…what I’ve done works so far ( thanks to ur help guys ) I’ve managed to create folders and also delete them and the list updates with every action…
now the big question is, If I have some elements created on the left list ( those are folders on the HDD ) and those elements have subfolders in them, how can i get those subfolders to show on the list in the middle? so if there’s a folder called characters on the left, and select it, it should show “character A” “character B” and so on on the middle as long as those folders exist inside the characters folder on the HDD, same for other items, like environments etc…

my guess ( which is probably wrong ) is that it has to do with arrays within arrays? mind to share some light on this if you guys feel like it?

cheers
Alex

here is the code:

try destroyDialog ::projectManager catch()

myAssetTypePath = getDir #scene
myAssetStrip = pathConfig.stripPathToLeaf myAssetTypePath

– Declaring function to update assetType lists
fn updateAssetTypeList =
(
items=#()
AssetTypeSubfolders = GetDirectories (myAssetTypePath +”*”)
for a in AssetTypeSubfolders do
(
a=filterstring a @””
append items a[a.count]
)

projectManager.AssetTypes.items=items
)

–declaring function in dot.net to delete folders
fn deleteFolder folderPath: =
(
local sioDir = dotNetClass “System.IO.Directory”
if (SIODir.Exists folderPath) do SIODir.Delete (folderPath) true
)

rollout projectManager “Asset Manager”
(
listBox AssetTypes “Asset Types” selection: 0 pos:[15,14] width:160 height:20
listBox Assets “Assets” pos:[195,14] width:160 height:20
listBox components “Components” pos:[375,14] width:160 height:20
edittext newAsset “” pos:[13,300] width:160
button createAssetTypes “Create” pos:[15,320] width:80
button deleteAssetTypes “Delete” pos:[95,320] width:80

	on AssetTypes selected nameIndex do
		(
			global index = nameIndex
			print index
			
		)

	on createAssetTypes pressed do
		(
			makeDir ( myAssetTypePath +"\\" + newAsset.text )
			updateAssetTypeList()
		)
	on deleteAssetTypes pressed do
		(
			delete_answer = queryBox "This will DELETE the folder and its contents, are you sure?" title:"Delete Asset type" beep:true
			if delete_answer == true then
				(
					print  AssetTypes.selected
					deleteFolderPath = AssetTypes.selected
					fullPath = myAssetTypePath + "\\" + deleteFolderPath as string
					print fullPath
					deleteFolder folderPath:fullPath
					updateAssetTypeList()
				)
		)

)

createDialog projectManager 550 500
updateAssetTypeList()

Page 1 / 2