Author Topic: Scripting problem: converting folder to folderS  (Read 998 times)

ubacher

  • Oldtimer
  • ****
  • Posts: 2379
Scripting problem: converting folder to folderS
« on: March 30, 2015, 11:32:16 AM »
I have problems with the following code:
Quote

Dim to_folders As New IMFolders  ' NEW causes: server can not create object
   Dim fld As IMFolder
   Set fld = Database.Folders("D:\Foto Cache")
   Set to_folders(1) = fld          ' convert folder to folders since needed in next step
   Set to_folders = Database.SelectFoldersDialog ( to_folders,)

the NEW statement for IMFolders causes an error message server can not create object
Is this a bug? Do I need it?
I think without the new my conversion from folder fldto folders to_folders will not work.
Or I do something wrong. Help appreciated.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Scripting problem: converting folder to folderS
« Reply #1 on: March 30, 2015, 12:55:34 PM »
You cannot create a folders collection. This class is declared as non-createable by intention.
IMFolders is only used to retrieve data from the database.

ubacher

  • Oldtimer
  • ****
  • Posts: 2379
Re: Scripting problem: converting folder to folderS
« Reply #2 on: March 30, 2015, 02:29:33 PM »
This leaves the question how to correctly convert a folder into folders -
since I need to (want to) put a starting folder for the SelectFoldersDialog.

i.e. I have a folder - it is the starting folder I want. But SelectFoldersDialog accepts only a IMFolders argument.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Scripting problem: converting folder to folderS
« Reply #3 on: March 30, 2015, 04:34:05 PM »
The idea is to use the methods SelectedFolders to get an initialized folders collection. There is no way you can create a folders collection from a script and just stuff arbitrary folders in to make up some sort of initial selection. If the available methods are not sufficient, you can only start with an empty selection. As always, if you want changes or addition, add a feature request. I don't plan to make changes to scripting soon, though. Especially since I already added several new methods for the next release, some for your purposes I think. So now I will concentrate on other things.

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1463
  • I'm too damn old to act my age.
Re: Scripting problem: converting folder to folderS
« Reply #4 on: March 30, 2015, 07:20:14 PM »
This leaves the question how to correctly convert a folder into folders -
since I need to (want to) put a starting folder for the SelectFoldersDialog.

i.e. I have a folder - it is the starting folder I want. But SelectFoldersDialog accepts only a IMFolders argument.

I'm on my lunch break now and don't have the time now to study what you're doing but maybe the attached script will give you a few ideas.



[attachment deleted by admin]

ubacher

  • Oldtimer
  • ****
  • Posts: 2379
Re: Scripting problem: converting folder to folderS
« Reply #5 on: March 31, 2015, 01:41:06 AM »
I found the way to do it:
Instead of database.SelectFoldersDialog I now use Application.SelectFolderDialog
So there is no need to use IMFolders.

Thank you John - your script gave me the hint.