revZipExtractItemToVariable multiple times to same variable

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
billhemsley
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 22
Joined: Wed Sep 21, 2011 12:24 pm

revZipExtractItemToVariable multiple times to same variable

Post by billhemsley » Sun May 26, 2013 4:24 pm

Something I can't fathom out is happening with revZipExtractItemToVariable when I try to extract twice to the same variable (using 6.0.1).

The first time works fine, but the second time returns the error "ziperr,illegal variable":

Code: Select all

revZipExtractItemToVariable myArchive, itemInMyArchive1, myVariable
// Do some stuff here
revZipExtractItemToVariable myArchive, itemInMyArchive2, myVariable
However, if I use two variables as follows there's no error:

Code: Select all

revZipExtractItemToVariable myArchive, itemInMyArchive1, myVariable1
// Do some stuff here
revZipExtractItemToVariable myArchive, itemInMyArchive2, myVariable2
Note that deleting the variable after the first use of revZipExtractItemToVariable doesn't seem to help.

If you're wondering, I want to do this so that I can loop through the items in a zip archive, getting the content of each item into a variable, then doing things with that content.

Can anyone explain what's going on (or suggest a good workround)?

Bill

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4168
Joined: Sun Jan 07, 2007 9:12 pm

Re: revZipExtractItemToVariable multiple times to same varia

Post by bn » Sun May 26, 2013 8:10 pm

Hi Bill,

some externals have an unusual way of filling variables:
from the dictionary

Syntax:
revZipExtractItemToVariable archivePath, itemName, variableName

Examples:
revZipExtractItemToVariable tArchive, "myZippedItem", "tItemData"

So from that I assume what happens is that your myVariable is used as a string for the variable in the first time since it is empty and as a variable the second time around. But it should be a variableNAME and not the variable itself.

if you do:
put "" into myVariable
revZipExtractItemToVariable myArchive, itemInMyArchive1, "myVariable"
// Do some stuff here
revZipExtractItemToVariable myArchive, itemInMyArchive2, "myVariable"

it should work. Note that in my example the name of the variable is in quotes and the variable is declare before by "put "" into myVariable".
Also note that "itemInMyArchive1" probably works for the same reason as "myVariable" works for the first time.

Not tested but worth a try.
Kind regards
Bernd

billhemsley
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 22
Joined: Wed Sep 21, 2011 12:24 pm

Re: revZipExtractItemToVariable multiple times to same varia

Post by billhemsley » Mon May 27, 2013 10:21 am

Hi Bernd,

Works perfectly! Thank you.

I note that, at least in my code, it's not necessary (though doubtless better practice!) to declare the variable first for it to work. So it's quoting the variable name that does it.

Thanks again,

Bill

Post Reply