Hi everybody,
I need a way (like getfile()) to select multiple files. The user is supposed to be able to easily pick up one or more files (txt in my case). Files are not necessary in the same director/drive.
Any word is welcome.
Thanks.
The first block of code is setting up the control, so can be called from whatever event/method you choose. You will need to supply your own values for the properties, in particular .cInitialDirectory, which is where the dialog will start.
WITH THISFORM.cusCommonDialog
.lAllowMultiSelect = .T.
.cFileName = []
.cInitialDirectory = ALLTRIM(USER.s_folder)
.cTitlebarText = [Select source files]
.aFilterList[1,1] = [Source (bmp,doc,gif,jpg)]
.aFilterList[1,2] = [*.bmp;*.doc;*.gif;*.jpg;*.jpeg]
.nFileCount = 0
.ShowDialog()
ENDW
The second block of code is retrieving the path\filenames of the selected files into a table/cursor, and should follow the first block.
It should be :-
WITH THISFORM.cusCommonDialog
[tab]IF .nFileCount > 0
[tab][tab]FOR i = 1 TO ALEN(.aFileNames,1)
[tab][tab][tab]INSERT INTO AUTO_CREATE (filename) VALUES (UPPER(SYS(5));
[tab][tab][tab][tab]+ LOWER(ADDBS(SYS(2003)));
[tab][tab][tab][tab]+ LOWER(.aFileNames[1,i])
[tab][tab]ENDF
[tab]ELSE
[tab][tab]MESSAGEBOX([No file(s) selected])
[tab]ENDI
ENDW
You can then browse the table/cursor and see what you've got.
WITH THISFORM.cusCommonDialog
IF .nFileCount > 0
FOR i = 1 TO ALEN(.aFileNames,1)
INSERT INTO AUTO_CREATE (filename) VALUES (UPPER(SYS(5));
+ LOWER(ADDBS(SYS(2003)));
+ LOWER(.aFileNames[1,i])) && <-- I needed ato add another close bracket here)
ENDF
ELSE
MESSAGEBOX([No file(s) selected])
ENDI
ENDW
I get the error message !! What am I doing wrong here !
OK Chris, Thanks again and sorry to take so long to get back.
It works. .. and it is good....
For those of you with normal IQ I'll summarize the steps that I did to get to a working example.
Create a blank form
Add a command button
Then do <alt> Tools -> Component Gallery -> Foundation Classes -> Dialogs -> Common Dialog (right click) -> Add control to form (or you can copy and paste)
On the form Right click on the control which is called _COMDLG Right click properties --> select rename and call it CusCommonDialog
Pleased to hear all is well - on reviewing the code posted, (as ever in a hurry), there is incorrect code of which should you should be aware.
INSERT INTO AUTO_CREATE (FileName) VALUES (UPPER(SYS(5)) ;
[tab]+ LOWER(ADDBS(SYS(2003)));
[tab]+ LOWER(.aFileNames[1,i]))
should be
INSERT INTO AUTO_CREATE (FileName) VALUES ;
[tab](ADDBS(.cusCommonDialog.cFilepath);
[tab]+ LOWER(.aFileNames[1,i]))
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.