Zlib: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m Created page with 'placeholder'
 
imported>StDoodle
No edit summary
Line 1: Line 1:
placeholder
{{TOCright}}
{{DISPLAYTITLE:zlib.ash}}
 
Behold, a single function library containing most of zarqon's most useful functions, which will be used by most of his scripts. He grew tired of tweaking a function that was in multiple scripts and making sure he had changed them all. ''It would be nice'', he thought in his customary italics, ''to have it in just one place''.
 
In choosing which functions to include, he have tried to select only those functions which are a) super useful, or 2) needed by another of the included functions. It's a bit less efficient in terms of individual scripts, but in terms of repeated code across a family of scripts it is far simpler.
 
 
{{Function|
name=excise|
return_type=string|
parameter1={{Param|string|source}}|
parameter2={{Param|string|start}}|
parameter3={{Param|string|end}}|
p1desc=The original {{pspan|source}} string|
p2desc={{pspan|start}} after this string|
p3desc={{pspan|end}} before this string|
}}
This function returns a portion of the {{pspan|source}} string, from after the first occurrence of {{pspan|start}} to just before the first occurrence of {{pspan|end}}. If either {{pspan|start}} or {{pspan|end}} are missing, it will return an empty string. You can also supply either {{pspan|start}} or {{pspan|end}} as blank strings to specify the actual start or end of the {{pspan|source}} string.
 
 
{{Function|
name=normalize|
return_type=string|
parameter1={{Param|string|mixvar}}|
parameter2={{Param|string|type}}|
p1desc={{pspan|mixvar}} is the string to normalize|
p2desc={{pspan|type}} is the datatype to normalize to|
}}
Returns {{pspan|mixvar}}, normalized to the specified mafia {{pspan|type}}, which can be any primitive type or ASH datatype constant. For example, normalized("badger", "familiar") would return "Astral Badger".
 
 
<h2>More Information</h2><p>See the thread for ZLib on the mafia forum [http://kolmafia.us/showthread.php?2072 here].</p>

Revision as of 23:17, 28 November 2010


Behold, a single function library containing most of zarqon's most useful functions, which will be used by most of his scripts. He grew tired of tweaking a function that was in multiple scripts and making sure he had changed them all. It would be nice, he thought in his customary italics, to have it in just one place.

In choosing which functions to include, he have tried to select only those functions which are a) super useful, or 2) needed by another of the included functions. It's a bit less efficient in terms of individual scripts, but in terms of repeated code across a family of scripts it is far simpler.


string excise(string source ,string start ,string end )

  • The original source string
  • start after this string
  • end before this string

This function returns a portion of the source string, from after the first occurrence of start to just before the first occurrence of end. If either start or end are missing, it will return an empty string. You can also supply either start or end as blank strings to specify the actual start or end of the source string.


string normalize(string mixvar ,string type )

  • mixvar is the string to normalize
  • type is the datatype to normalize to

Returns mixvar, normalized to the specified mafia type, which can be any primitive type or ASH datatype constant. For example, normalized("badger", "familiar") would return "Astral Badger".


More Information

See the thread for ZLib on the mafia forum here.