Computer Science Canada

File Type info

Author:  Carey [ Wed Mar 19, 2008 3:08 pm ]
Post subject:  File Type info

Is there a way in Turing to get the string associated with an extension? Ex. get "Microsoft word document" from ".doc". I could just hard-code it into a library file, but file types differ on each computer. Is there a way to get the information when the program starts up?

Author:  Sean [ Wed Mar 19, 2008 3:10 pm ]
Post subject:  Re: File Type info

Have you looked into the import function?

Author:  Mackie [ Wed Mar 19, 2008 5:54 pm ]
Post subject:  RE:File Type info

Vilament, I think you misunderstood. To answer your question. There is no function to do that. If you have the name in a string already in a string you could probably just collect the file extension running backwards through the string and collecting every letter before you run into a period.

Author:  TheGuyWhoGotOn [ Fri Mar 21, 2008 11:39 am ]
Post subject:  Re: RE:File Type info

Mackie @ Wed Mar 19, 2008 5:54 pm wrote:
Vilament, I think you misunderstood. To answer your question. There is no function to do that. If you have the name in a string already in a string you could probably just collect the file extension running backwards through the string and collecting every letter before you run into a period.


It sounds like he want something like

code:

File := File(* - 4 .. *)
if File = ".doc" then
put "kewl"
end if


Or will that not work?

Author:  Tony [ Fri Mar 21, 2008 12:49 pm ]
Post subject:  Re: File Type info

Carey @ Wed Mar 19, 2008 3:08 pm wrote:
string associated with an extension? ... differ on each computer.

The association is on the OS level. That is, I can configure the system to open .doc documents with Notepad. Or even one specific .doc document, while leaving the rest with default. There might be OS API for this information, but such is generally not available to Turing.

Author:  Carey [ Tue Mar 25, 2008 11:11 am ]
Post subject:  RE:File Type info

Crap. [moves on to C++] Well thanks anyway.


: