Hi,
I have pdf files in folders on OS X server.
Popupmenus load folderitems and user selects and an url path is generated that way.
Listbox is populated with pdf files and displayed in html viewer when user clicks cell.
I’ve added a checkbox to the listbox and want the user to change the name of the checked files.
So I have an url path to a file but in the language reference i cannot find a way to change the name of the file.
Does anybody knows there is a way to do this ?
thanks
marco
dim i As integer
// Toggle all CheckBoxes in Selected column when header is pressed
for i=0 to listbox1.LastIndex
if listbox1.CellCheck(i,0) = false then
//do nothing
else
dim f as folderitem
dim s as string
s = textfield1.text + “/” + cstr((listbox1.cell (row,0)))
//f.URLPath = s
// F.name = “test”
end if
next i
When you add a row to your listbox, set the RowTag to the FolderItem, and then get the FolderItem back when you want to rename it.
e.g.
Dim f As FolderItem = GetOpenFolderItem("") ' get a folderitem
Dim lastindex As Integer
Listbox1.AddRow(f.Shellpath)
lastindex = Listbox1.LastIndex
Listbox1.RowTag(LastIndex) = f
Then in your renaming code just reverse the process to get the FolderItem back, so you don’t need to worry about parsing shell paths at all:
dim f as folderitem = Listbox1.RowTag(row)
Thanks Andrew I ve tried the row tag.
Problem is the customer wants to use the checkbox in the list box to automatically rename several pdf’s.
So i’ve to loop through the listbox and that code cannot retrieve the row.
So the listbox can contains filename ( text) , row tag , pathtypeurl and somehow I have to find rename the file.
The manual and language ref always uses the getopenfolderitem to get the file but thats not an option because that way it is more faster to rename the files in the finder.
This code is used in popupfield to load the dir to the listbox:
Dim f As FolderItem
f = new FolderItem(s, FolderItem.PathTypeURL)
//HTMLViewer1.LoadURL s
If f Is Nil Then
Return
End If
listbox1.DeleteAllRows
Dim count As Integer = f.Count
For i As Integer = 1 to count
Dim f2 As FolderItem = f.Item(i)
If f2 <> Nil Then
listbox1.AddRow(f2.Name)
//Dim lastindex As Integer
//lastindex = Listbox1.LastIndex
//Listbox1.RowTag(LastIndex) = f2
dim row as integer
listbox1.rowtag(row) = f2
End If
Next
Seems the path string is not added to the listbox.
But i don’ t understand why
If f2 <> Nil Then
listbox1.addRow(f2.name,path)
End If
Next
Use the ListBox.LastIndex property to get the row of the most recently-added row, as in my first post’s code:
listbox1.AddRow(f2.Name)
Dim lastindex As Integer
lastindex = Listbox1.LastIndex
Listbox1.RowTag(LastIndex) = f2
Thank you very much Andrew.
This works perfect ! ( I used in test app same string to rename and because i din’t check for errors the os didn’t rename because file already existed )