decompress

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
Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

decompress

Post by Andycal » Tue Jul 31, 2007 7:07 pm

Anyone know of an example using the decompress function to extract data from a gzip file? Looked at the examples in the docs and I just can't get it to work.

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

Post by Mark » Tue Jul 31, 2007 7:44 pm

Dear Andycal,

You can read the data from a file in the oldfashioned way:

Code: Select all

put "~/desktop/file.gz" into myFile
open file myFile for binary read
read from file myFile until EOF
close file myFile
put decompress(it) into myData
or use the url form:

Code: Select all

put "~/desktop/file.gz" into myFile
put decompress(URL ("binfile:" & myFile)) into myData
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

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Tue Jul 31, 2007 7:48 pm

Hi Mark,

It's getting clearer, but what is the 'myData' variable? Does this put it somewhere on the disk?

Sorry if it's a stupid question, I'm still getting to grips with syntax in RunRev.

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

Post by Mark » Tue Jul 31, 2007 7:56 pm

Dear Andycal,

The variable myData only contains the result of the decompress() function. It contains data. If you want these data to be written back to disk, you have to use the write command or use the put url command.

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

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Tue Jul 31, 2007 7:58 pm

Gotcha! Thanks Mark, I'll go play...

Post Reply