Page 1 of 1
Save/Load stack from Archive/Zip
Posted: Tue Dec 17, 2013 2:35 pm
by palanolho
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
Re: Save/Load stack from Archive/Zip
Posted: Wed Dec 18, 2013 9:57 am
by Simon
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:
Code: Select all
put the ID of the last image of stack "Test"
Now where are you going to store that info?
Saving stack:
Code: Select all
save stack "Test" as (specialFolderPath("desktop") & "/test.rev")
Fun!
Simon
Re: Save/Load stack from Archive/Zip
Posted: Wed Dec 18, 2013 1:41 pm
by palanolho
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.
Code: Select all
put the ID of the last image of stack "Test"
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?
Code: Select all
save stack "Test" as (specialFolderPath("desktop") & "/test.rev")
this is to store the stack on disc correct?
could I add it to my archive like this?
Code: Select all
revZipAddItemWithData myArchive , "stack.rev", myStack
Many thanks,
- Miguel
Re: Save/Load stack from Archive/Zip
Posted: Wed Dec 18, 2013 10:48 pm
by Simon
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
Re: Save/Load stack from Archive/Zip
Posted: Sun Jun 01, 2014 6:45 pm
by palanolho
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)
Code: Select all
global gameSupportStack -- this containsthe name of the stack I want to store
revZipAddUncompressedItemWithData projectPath, "test.rev", "gameSupportStack"
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
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
Re: Save/Load stack from Archive/Zip
Posted: Sun Jun 01, 2014 10:04 pm
by FourthWorld
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:
Code: Select all
put url ("binfile: "& tPathToSomeFile) into tData
put compress(tData) into tCompressedData
I'll wager you can guess the name of the function needed to
decompress the data.

Re: Save/Load stack from Archive/Zip
Posted: Sun Jun 01, 2014 11:43 pm
by palanolho
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
Re: Save/Load stack from Archive/Zip
Posted: Mon Jun 02, 2014 7:38 pm
by palanolho
So, my ultimate question is:
- 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?
Many thanks in advance,
- Miguel