Set File Icon?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
cmhjon
Posts: 26
Joined: Tue Aug 04, 2015 11:55 am

Set File Icon?

Post by cmhjon » Wed Jan 10, 2018 4:28 pm

Hello,

Is there a way to set the icon of a file (a Microsoft Word file) for example? After checking the dictionary, there doesn't seem to be a way to do this?

Thank you so much,
Jon :)

Klaus
Posts: 9690
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Set File Icon?

Post by Klaus » Wed Jan 10, 2018 4:36 pm

Hi Jon,

if you mean OUTSIDE of LC, then you might be able to do this in LC via AppleScript on a Mac
and VBScript on WIndows, but not with the build-in means of LC.


Best

Klaus

bogs
Posts: 973
Joined: Sat Feb 25, 2017 10:45 pm

Re: Set File Icon?

Post by bogs » Wed Jan 10, 2018 10:10 pm

I think it can be done inside Lc though, depending on the situation. If your trying for a system wide reset, then I believe Klaus is correct.

Inside Lc, you have to come up with a character to represent the icon you want to use, then set it in the field so it will look like this (field on left and menu button above) -
Image
ImageImage

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4070
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Set File Icon?

Post by jacque » Thu Jan 11, 2018 5:32 pm

Most operating systems use the file extension to determine the icon and the default app that will open the file. Name your file with a ".doc" extension and it should work. Of course, if the file isn't actually a Word file, MS Word won't be able to read it.

Or did you mean you want to show the icon inside a LC stack?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cmhjon
Posts: 26
Joined: Tue Aug 04, 2015 11:55 am

Re: Set File Icon?

Post by cmhjon » Thu Jan 11, 2018 7:24 pm

Hi Jacque,

I am building an app that determines which version of an app a file was built with and then open said file with the appropriate app version (see viewtopic.php?f=7&t=30056).

I have all that working but because I have set several file types to open with my app, the icons of the files being opened with my app are changing to a generic file icon (which I am guessing is expected behavior) so I was trying to figure out a way to set the icon of said file back to the appropriate one.

Cheers,
Jon

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4070
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Set File Icon?

Post by jacque » Fri Jan 12, 2018 6:58 pm

So you're writing the file back to disk? There may be a shell call that will do it, since the user can assign a default app in the Get Info box in Finder, but I don't know what it might be. You may be able to find something with a Google search.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cmhjon
Posts: 26
Joined: Tue Aug 04, 2015 11:55 am

Re: Set File Icon?

Post by cmhjon » Fri Jan 12, 2018 7:42 pm

Other than changing the icon of the file, my app makes no changes to the file whatsoever.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4070
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Set File Icon?

Post by jacque » Sat Jan 13, 2018 2:30 am

If you aren't saving the file then the icon shouldn't change. How are you opening it? Did you try opening for read-only?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”