User:Belove/AOM Sample Rename Patterns: Difference between revisions

m
(→‎replacegreedy() / replacegreedyi(): optimizations; fixed for length(find)=0 to 1; documentation++)
 
(One intermediate revision by the same user not shown)
Line 123: Line 123:
| <pre>replacegreedy('[1 2  5    8        ]', '  ', ' ')</pre> || <pre>[1 2 5 8 ]</pre>
| <pre>replacegreedy('[1 2  5    8        ]', '  ', ' ')</pre> || <pre>[1 2 5 8 ]</pre>
|}
|}
== To-do and ideas ==
* bitand(uint1, uint2) As Boolean
* bitor(uint1, uint2) As Boolean
* bitxor(uint1, uint2) As Boolean
* fileversion(F) As Number - supporting above version 6.  May depend on bitand().
* v(F) As String ('&#39;, 'v2', 'v3',...) - Depends on fileversion().
* iscensored(F) As Boolean - Depends  maybe on bitand().
* isuncensored(F) As Boolean - Depends  maybe on bitand().
* centag(F) ['[UNCEN]' or '[CEN]' or '&#39;] As String
* Specific-purpose functions to handle extra spaces in a non-generalized way, illegal filename characters, general filename cleanup.
* Rounding functions.
* left(string, characters As Number) As String - Like limit(string, number), but supports number < 1 by returning '&#39; (limit() returns the whole text).
* right(string, characters) As String - Like left(), but right()!
* replacemid(string, start, length, insert text) As String (modified string) - length can be 0 to just insert text, or longer to replace it.
* findnext(find, start, text) As Number (position) | Boolean (False if not found)
* findlast(find, start, text) As Number (position) | Boolean (False if not found) - searches right-to-left for find in text, but start and position are still relative to start of text.
* count(seperator, text) - Count seperated values in text.
* counte(seperator, text) - Count seperated values in text ignoring escaped seperators.
* escape(character, text)
* unescape(character, text)
* splite(seperator, text, part number) - Like split(), but ignores escaped (doubled) seperators, and returns part unescaped.  Depends on unescape().
* joine(seperator, text1, text2) - Like join(), but escapes seperator found in texts and is limited to two text parameters.
* cbool(string | number) & etc.
* coladd(collection, item name | False | '&#39;, value) As String (collection) - adds or replaces named value in collection, creating collection if necessary, while storing the data type; if item name is boolean False or '&#39; then item can only be referenced by index; limitations: can't support objects, floats are coerced to decimals.  Collection stored in a String beginning with marker indicating it's a collection, followed by item count, item names, and finally item data type/value pairs.  Optionally sort the index by item name for efficiency (if it is worth it and possible).  Collections could be used to implement scope and call stacks.  E.g., At beginning of functions add collection of local variables' existing values to a stack collection.  At end of function, restore all values.  Could complicate collection structure further to implement shared scope, if needed.
* colremove(collection, item name | item number) As String (collection)
* colget(collection, item name | item number) As String (value)
* colcount(collection) As Number (item count)
* colitem(collection, item name | item number) As {Number (item number) | String (item name) | Boolean (False)} - Returns item number if passed a valid item name, item name if passed a valid item number and item is named, '&#39; if passed unnamed item number, False if passed invalid name or invalid number).
* colsort(collection) As String (collection) - e.g. bubble sort (if sorting is even possible to implement).
* Possibly add functions to manipulate one, two, and three-dimensional arrays respectively.  Could be wrappers for (nested) collections without item names.
* replacerepeat_(): Add anti-infinity test (find_len <=(<?) replace_len)
* replacerepeati_()
* repeatgreedy(): Replace matches that begin _before_ the match string by having it build a larger starting buffer up to offset_max = (find_len * 2) - 1 with new_text_len = min(offset_max - 1, text_len - 1) & replacing with for(text_pos, new_text_len + 1, text_len) then replacing {without appending to new_text} for(new_text_pos, new_text_pos + 1, new_text_pos + find_len) {roughly} & therefore consider calling a new function replacegreedy_internal_replace() that handles the instructions in the loop other than appending text if it would reduce redundancy & consider only returning output at end (always storing in new_text), rather than outputting return text in several if() clauses as now -- to make function behavior easier to understand.
* Structure my AOM wiki page to group general-purpose and applied functions seperately.
* Move this wiki page.
* Add a table to compare outputs of test suite of {text, find, replace} with each internal and custom replace function, as results will differ.
* Add most useful and tested applications to main documentation (possibly eliminating or reducing dependencies and use of function() for simplicity)
* Document _ line continuation, + concatenation operator, Mod modulo operator, ^ exponent operator (if indeed supported), whether < and > (etc.) work as string comparison operators, strtoint(), replacerepeat() misbehavior, False as default value for unset variables -- including objects, and other built-in features still undocumented, in main documentation.
13

edits

MediaWiki spam blocked by CleanTalk.
MediaWiki spam blocked by CleanTalk.