Getting the type code of a file under OSX

Eric Chatonet eric.chatonet at sosmartsoftware.com
Sat Jul 30 10:49:58 EDT 2005


Hi all who follow this thread,

This list is great since it forces us to try to reach excellence :-)
I thought I have posted the last one.
No ;-)
It does work but can be more elegant:

function CreatorAndType pFilePath
   local tDefaultFolder,tFile,tCreatorType
   -----
   if the platform <> "MacOs" then return "Error: filetype not  
supported"
   put the defaultFolder into tDefaultFolder
   set the itemdel to slash
   set the defaultFolder to item 1 to -2 of pFilePath
   put the detailed files into tFile
   filter tFile with urlEncode(item -1 of pFilePath) & ",*"
   set the defaultFolder to tDefaultFolder
   set the itemDel to comma
   put item 11 of tFile into tCreatorType
   if tCreatorType = empty then return "Error: could not determine  
the filetype"
   return char 1 to 4 of tCreatorType,char 5 to 8 of tCreatorType
end CreatorAndType

Have a nice week-end,

Best Regards from Paris,

Eric Chatonet.

Le 30 juil. 05 à 16:24, Eric Chatonet a écrit :

> I should not have thought that such a tiny problem could go so far :-)
> Error management is the key of good software...
> So, I propose another approach:
> As usual, is this one the last one?
> :-)
>
> function CreatorAndType pFilePath
>   local tDefaultFolder,tFile,tCreatorType
>   -----
>   if the platform <> "MacOs" then return "Error: filetype not  
> supported"
>   put the defaultFolder into tDefaultFolder
>   set the itemdel to slash
>   set the defaultFolder to item 1 to -2 of pFilePath
>   put the detailed files into tFile
>   filter tFile with urlEncode(item -1 of pFilePath) & ",*"
>   set the defaultFolder to tDefaultFolder
>   set the itemDel to comma
>   if last char of tFile = comma then return "Error: could not  
> determine the filetype"
>   return char 1 to 4 of item -1 of tFile,char 5 to 8 of item -1 of  
> tFile
> end CreatorAndType


----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        eric.chatonet at sosmartsoftware.com/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------




More information about the use-livecode mailing list