ZLib -- Zarqon's useful function library

Thank you... is this something that will have to be done with every update from now on? Just want to be prepared. :)
 
No. That problem was because of an incompatibility between the two versions. You shouldn't see the problem with the next version unless zarqon purposefully tries to screw with you.

I think I should also mention this particular update in the thread:

You can now type "zlib vars" in the CLI to see all your current script settings. This is quite useful since you can also set vars using the CLI. ("zlib settingname = value")

I must have downloaded that too quickly because my version of : 9 didn't support that. Then I downloaded it again and now it works. I guess I got the beta version. ;)

Nice new feature.
 
Last edited:
@Braska: You would have to do it once per script per character at the most (although, I didn't have to do this). To be totally safe, you could just open your settings file(s) and delete everything that starts with "_version_".

unless zarqon purposefully tries to screw with you.

I'm flattered you would consider that possibility. :D
 
Last edited:
Last page, zarqon said this about the update problem:

The previous version stored the local script's version in the property, the new version stores the current version's. You need to clear that property. Try this.

Code:
[COLOR="Olive"]> set _version_zlib =[/COLOR]

_version_zlib =>

[COLOR="#808000"]> zlib[/COLOR]

Checking for updates (running ZLib ver. : 9)...
_version_zlib => : 9
You have a current version of ZLib.
 
Could he just add that as a CLI_execute? Otherwise I think he's in for a headache as more and more users update and ask the same question.

I realize there would be additional code checks to ensure this doesn't run when it isn't necessary, but it may be worthwhile in the long run.
 
zarqon, you'd have been better off if check_version() checked to see if the strings were identical, rather than if the old string is blank. That's some troubled code.
 
zarqon, just to torment you a little more:

Code:
string excise(string source, string start, string end) {
   matcher result = create_matcher(start+"(.+?)"+end, source);
   if(result.find()) return result.group(1);
   return "";
}
And since you were wondering, programmers like regexes because they are both elegant and obscure. That's a rare combination.
 
What are you talking about? It first checks to see if they are identical.

Speaking of troubled, what a troubled world is this, wherein scripters may freely post dangerous regexes as if they were but words, words without the power to attack and devour innocents.
 
Sorry, I should probably paste a warning before releasing another regex into the wild like that. But it really is just a cute and simple regex. They hardly ever get more harmless than this one.

What are you talking about? It first checks to see if they are identical.
Never mind. My mind zoned out and I have no idea what I was thinking at the time. Anyway, this shouldn't cause trouble again after people manage the update to this version.
 
As the standard joke goes: You have a problem, and you've decided to use a regex to solve it. Now, you have two problems...

This is NOT at all equivalent to excise():
matcher result = create_matcher(start+"(.+?)"+end, source);
Consider what would happen if start or end contained any regex metacharacters. To safely include arbitrary text, you'd need to build the regex like this:
"\\Q" + start + "\\E(.+?)\\Q" + end + "\\E"
...but even that would fail if start or end happened to contain a "\E"...
 
Good point. So, I suppose first start and end would have to be checked to see if they contain \E and have \ inserted appropriately to cancel it? I guess it is far safer just to leave his excise exactly as he wrote it.

At least those characters shouldn't show up in check_version().
 
woo new bug, sorry Zarqon

Code:
[864] Goatlet
Encounter: dairy goat
Strategy: C:\Users\AustinCPC\Desktop\KoL Shit\ccs\sputnik1.ccs [default]
Round 0: sputnik1 wins initiative!
New Version of ZLib Available: : 8
Upgrade ZLib from : 9 to : 8 here: http://kolmafia.us/showthread.php?t=2072
Countdown: 5 seconds...
Countdown: 4 seconds...
Reclaimed 10528 KB of memory
Countdown: 3 seconds...
KoLmafia declares world peace.
You're on your own, partner.
 
zarqon, you really should have compared thisver to ver, not to get_property("_version_"+prop) if the program has already been run today. I see what you were thinking, but it completely falls apart on update.
 
Last edited:
To solve this problem, which will only happen when updating to version 9 for the first time, type "set _version_zlib =" in the CLI.

Now. I'm done with this one. If people can't read the thread, where the solution has already been presented THREE TIMES, I don't mind letting them suffer a 25-second wait every time ZLib is called.

Bale: I compare to get_property because ver does not exist the second time it's run. It also saves server hits, and other than this one-time problem, which I did not anticipate but which has an easy fix, it will not be an issue.
 
I know why you did that. It was elegant. It's just that when I see so many people struggling with an update it troubles me.

Anyway, the problem will go away on its own 1 day after they update.
 
Now. I'm done with this one. If people can't read the thread, where the solution has already been presented THREE TIMES, I don't mind letting them suffer a 25-second wait every time ZLib is called.

Sorry to bring this demon up again... but let's say some backwards and unassuming individual did not keep his versions up to date (me!).

Code:
New Version of ZLib Available: : 6
Upgrade ZLib from : 9 to : 6 here: http://kolmafia.us/showthread.php?t=2072
Countdown: 5 seconds...
Countdown: 4 seconds...
Countdown: 3 seconds...
Countdown: 2 seconds...
Countdown: 1 second...
Waiting completed.

> set_version_zlib=

Unable to invoke set_version_zlib=

Clearly set_version_zlib was not added for the version I am running. Can someone explain how I can fix this? Sorry to be a pain :(
 
Sorry to bring this demon up again... but let's say some backwards and unassuming individual did not keep his versions up to date (me!).

Code:
New Version of ZLib Available: : 6
Upgrade ZLib from : 9 to : 6 here: http://kolmafia.us/showthread.php?t=2072
Countdown: 5 seconds...
Countdown: 4 seconds...
Countdown: 3 seconds...
Countdown: 2 seconds...
Countdown: 1 second...
Waiting completed.

> set_version_zlib=

Unable to invoke set_version_zlib=

Clearly set_version_zlib was not added for the version I am running. Can someone explain how I can fix this? Sorry to be a pain :(

It's set _version_zlib=. There should be a space before the first underscore.
 
Last edited:
Back
Top