Page 1 of 1

revZipExtractItemToVariable multiple times to same variable

Posted: Sun May 26, 2013 4:24 pm
by billhemsley
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

Re: revZipExtractItemToVariable multiple times to same varia

Posted: Sun May 26, 2013 8:10 pm
by bn
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

Re: revZipExtractItemToVariable multiple times to same varia

Posted: Mon May 27, 2013 10:21 am
by billhemsley
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