Save/Load stack from Archive/Zip
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Save/Load stack from Archive/Zip
Greetings everyone,
I was wondering if anyone knows if its possible to (and how):
* create a stack in memory, add some images to the stack and save the stack into an Archive/zip
* load a stack from an archive/zip into memory with all its content
If "yes you can" is the answer, will I be able to use this stack and access its content on the stand alone application?
Many thanks in advance,
- Miguel
I was wondering if anyone knows if its possible to (and how):
* create a stack in memory, add some images to the stack and save the stack into an Archive/zip
* load a stack from an archive/zip into memory with all its content
If "yes you can" is the answer, will I be able to use this stack and access its content on the stand alone application?
Many thanks in advance,
- Miguel
Re: Save/Load stack from Archive/Zip
Hi Miguel,
Yes you can.
Check out "create stack" and "revZipOpenArchive" in the dictionary.
Using "copy" you can then place an image on the new stack. Now you are going to want to keep track of the new images on the new stack so after the copy:
Now where are you going to store that info?
Saving stack:
Fun!
Simon
Yes you can.
Check out "create stack" and "revZipOpenArchive" in the dictionary.
Using "copy" you can then place an image on the new stack. Now you are going to want to keep track of the new images on the new stack so after the copy:
Code: Select all
put the ID of the last image of stack "Test"
Saving stack:
Code: Select all
save stack "Test" as (specialFolderPath("desktop") & "/test.rev")
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Save/Load stack from Archive/Zip
wait I got lost 
I have a XML in memory (that I already save/load on the archive) and when I add the image to the stack I will store the img ID on the XML.
this is to get the ID of the img I just added to the stack without having to dig it up from all imgs on that stack, correct?
this is to store the stack on disc correct?
could I add it to my archive like this?
Many thanks,
- Miguel

I have a XML in memory (that I already save/load on the archive) and when I add the image to the stack I will store the img ID on the XML.
Code: Select all
put the ID of the last image of stack "Test"
Code: Select all
save stack "Test" as (specialFolderPath("desktop") & "/test.rev")
could I add it to my archive like this?
Code: Select all
revZipAddItemWithData myArchive , "stack.rev", myStack
- Miguel
Re: Save/Load stack from Archive/Zip
Hi Miguel,
Yeah I think you get it.
Here is the zip lesson;
http://lessons.runrev.com/s/lessons/m/4 ... 5-zip-tool
"revZipOpenArchive pZipFile, "write""
Simon
Yeah I think you get it.
Here is the zip lesson;
http://lessons.runrev.com/s/lessons/m/4 ... 5-zip-tool
"revZipOpenArchive pZipFile, "write""
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Save/Load stack from Archive/Zip
Hi everyone,
I got some time to return to this topic and was trying to implement this as suggested, however I'm having some issues.
I'm able to store a file with some text on the Archive file, BUT ... I'm not being able to store the stack on the Archive file.
This creates a test.rev file inside the ARchive containing the name of my stack (like if it was a normal txt file)
Isn't it Possible to copy/save a stack into an Archive without saving it to disk first ???
How can I do it
Note: I'm able to add the stack to the Archive IF I have a physical file on disk sing the script bellow but I really would like to do it without having to create a file on disk
Many thanks in advance,
- Miguel
I got some time to return to this topic and was trying to implement this as suggested, however I'm having some issues.
I'm able to store a file with some text on the Archive file, BUT ... I'm not being able to store the stack on the Archive file.
This creates a test.rev file inside the ARchive containing the name of my stack (like if it was a normal txt file)
Code: Select all
global gameSupportStack -- this containsthe name of the stack I want to store
revZipAddUncompressedItemWithData projectPath, "test.rev", "gameSupportStack"
How can I do it
Note: I'm able to add the stack to the Archive IF I have a physical file on disk sing the script bellow but I really would like to do it without having to create a file on disk
Code: Select all
put (specialFolderPath("desktop") & "/support_stack.rev") into tFilePath
save stack gameSupportStack as tFilePath
revZipAddUncompressedItemWithFile projectPath, "gameSupportStack.rev", tFilePath
Many thanks in advance,
- Miguel
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Save/Load stack from Archive/Zip
The Zip external is nice, but if you're only compressing a single file you can use the built-in GZip support in the compress function:
I'll wager you can guess the name of the function needed to decompress the data. 
Code: Select all
put url ("binfile: "& tPathToSomeFile) into tData
put compress(tData) into tCompressedData

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Save/Load stack from Archive/Zip
Actually I'm adding more than one file to the archive. The stack is just another one I would like to add.
Any ideas?
- Miguel
Any ideas?

- Miguel
Re: Save/Load stack from Archive/Zip
So, my ultimate question is:
- Miguel
- Is it possible to add a stack directly to an Archive without saving it to a file first?
- Is it possible to load a stack in an Archive, directly into memory, without saving it to disk first?
- Miguel