Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PUTFILE() and extensions
Message
 
 
To
21/05/2018 12:07:34
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01660196
Message ID:
01660229
Views:
46
>>>>>But I don't see that there's a way to add a description unless it's one of registered types - for that you'd have to use common dialog object. But since both xls and xlsx are registered type, Putfile('some text','','xls;xlsx') should work and display the type description in the lower combo. Doesn't do that in my case because I don't have the Office installed on my fox box.
>>>>
>>>>That was not my question. I was simply looking for the Putfile() dialog to show all files (on the current drive and folder) of the specified extensions. For example, if you have putfile("aa","", "abc;def"), the dialog (where you would enter or select a file) would show all files that have extension "abc" and "def". The only way I was able to do it (again, to make all files appear in the dialog) was by using the wild card asterisk (putfile("aa","", "xls*"). But what I found is when specifying the wild card and then entering any name (e.g. Test1), I was getting error message "Wrong File Name". Therefore, I ended up using the approach of putting both extensions and separating them with the vertical line. So the customer can choose which files he/she wants to see (either XLS or XLSX). Type description was not in the consideration.
>>>
>>>Well I saw that you mentioned description in your attempt, so I added that to the request, mainly because in these 20+ years I never managed to get it right. Now I see that putfile() doesn't even have the capability, and that the examples I saw were about CommonDialog. So now the serbian spite gets fired up and here's the format:
>>>
>>>
>>>
tcExt="Excel|*.xls|Ini file|*.ini|a DBF|*.dbf|Log file|*.log"
>>>
>>>oDlg=Newobject("commondialog", "myclasslib.vcx")
>>>* the class is just a plain form which hosts the control, no code, just 
>>>*	ShowWindow = 1
>>>*	AutoCenter = .T.
>>>
>>>With oDlg.OleControl
>>>	.Filename="  "
>>>	.Defaultext= Getwordnum(tcExt,4,"|")
>>>	.DialogTitle="Save"
>>>	.initdir= Set("dire")
>>>	.Filter=tcExt
>>>	.ShowSave()
>>>	If Not Empty(.Filename)
>>>		lcFullfilename=Fullpath(.Filename)
>>>	Endif
>>>Endwith
>>>
>>>And save your breath, this doesn't show all the listed extensions either. It just looks nicer. And the .defaultext property does nothing, it still shows the first extension listed and none other. Also, the examples at https://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx say that a semicolon should be used as delimiter, but then that each string in the list must be null terminated. I know we usually don't send null terminated strings to API calls, so I guessed the fox-to-api interface handles that for us. So I tried several combinations of commas, pipes and semicolons for delimiters between and inside pairs... and I had a real WTF moment when I put the pipe for both and all of a sudden it worked. Go figure.
>>
>>What is the commondialog in your library? I am not familiar with such class.
>
>Said in the comment - just an empty form with an olecontrol with OleClass=MSComDlg.CommonDialog.1, no code in it.

Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform