Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PUTFILE() and extensions
Message
From
21/05/2018 10:27:51
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01660196
Message ID:
01660218
Views:
79
>>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.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform