Custom file extensions

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Custom file extensions

Post by gyroscope » Wed Dec 31, 2008 2:18 pm

Hi, I'm sure I saw the solution to the following prob some time ago but can't find it:

My first project lets users save certain output to a simple .txt file, as well as read in a .txt file.

Ideally I would like some script to change the extension for the saved and read-in file to .isg, for instance. Still a text file of course, but hopefully (although not absolutely necessary) unable to be read by word processors, Mac TextEdit etc; but more importantly, my app, once the new extension is added, to only show and only recognise files with the .isg extension but still bring it in as a normal plain text file.

Has anyone the script for this please :?:

:)

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Wed Dec 31, 2008 2:38 pm

Code: Select all

put textData into url ("file:" & pathToFile & "filename.isg")

Code: Select all

answer file "specify file" with type "ISG Files|isg|ISGT"
if it <> "" then
  put url ("file:" & it) into field 1
end if
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Dec 31, 2008 2:46 pm

Hi gyroscope,

Usually I make a special file format. For example something like

<app>My App Name</app><version>1.0</version><data>thisIsSomeCompressedOrEncryptedDataInBinaryForm</data>

Using these tags, I can quickly check the format of the file.

The following script will help you to create a script that opens files from the finder. If you check the file format, you don't really need to check the file type.

http://runrev.info/Open%20File%20from%20Finde.htm

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Wed Dec 31, 2008 2:48 pm

Thank you, BvG and Mark, exactly what's needed!

Thanks also for your swift replies.

:)

Post Reply