Can't Decompress
Sarah Reichelt
sarah.reichelt at gmail.com
Sat Apr 29 17:31:38 EDT 2006
On 4/30/06, Bill Marriott <wjm at wjm.org> wrote:
> I created a new stack with a single field and two buttons:
>
> Button 1
> --------
> on mouseUp
> put "D:\Desktop\Put It Here" into saveFolder
> put "My Data File.xyz" into saveFileName
> put "binfile:" & saveFolder & "\" & saveFileName into saveURL
> answer saveURL
> put fld 1 into URL saveURL
> put compress(URL saveURL) into URL saveURL
> end mouseUp
>
> Button 2
> --------
> on mouseUp
> put "D:\Desktop\Put It Here" into loadFolder
> put "My Data File.xyz" into loadFileName
> put "binfile:" & saveFolder & "\" & loadFileName into loadURL
>
> put decompress(URL loadURL) into URL loadURL
> put URL loadURL into fld 1
> end mouseUp
>
> I've put the stack up on RevOnline for you to try. User MerryOtter.
>
> Clicking Button 1 saves a file that is compressed properly. (I can even
> extract it with 7zip). Clicking Button 2 gives me the error:
>
> Type: decompress: string is not compressed data
> Object: Button 2
> Line: put decompress(URL loadURL) into URL loadURL
>
> What am I doing wrong? No matter what I do I can't get decompress to work.
> Rev 2.6.1 on Windows XP. (I hope I'm not missing something basic like I did
> with my last post...)
Hi Bill,
Using your demo stack, I couldn't even get the save to work, but I
finally got both working. You had left a few typos in so that the path
names didn't include the file name and mixed loadFolder & saveFolder,
but I think the main problem was that you were using Windows style "\"
(back slashs) for you path dividers, while Rev uses Unix style "/".
Another problem may be avoided by using 2 files: one for the plain
text and one for the compressed text. Unless you need the plain text
version as well, I would compress & decompress the field data without
using an intermediate text file.
This is on Mac OS X, not WIndows, but try these scripts:
Compress button:
on mouseUp
put specialFolderPath("Desktop") & "/Put It Here" into saveFolder
put "My Data File.xyz" into saveFileName
put "binfile:" & saveFolder & "/" & saveFileName into saveURL
put compress(fld 1) into URL saveURL
end mouseUp
Decompress button:
on mouseUp
put specialFolderPath("Desktop") & "/Put It Here" into loadFolder
put "My Data File.xyz" into loadFileName
put "binfile:" & loadFolder & "/" & loadFileName into loadURL
put decompress(URL loadURL) into fld 1
end mouseUp
HTH,
Sarah
More information about the use-livecode
mailing list