git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6820 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Bukz
2012-06-04 03:39:22 +00:00
parent 276c7839a5
commit acb5f1f544
+22 -26
View File
@@ -10,23 +10,24 @@ islists = [
result $bool
]
hasQuotePair = [
bool = 0
got_open_quote = -1
got_close_quote = -1
loop r (strlen $arg1) [
if (testchar (substr $arg1 $r 1) 8) [
if (= $got_open_quote -1) [
got_open_quote = $r
] [
got_close_quote = $r
break;
]
countQuotes = [
numquotes = 0
loop q (strlen $arg1) [
if (testchar (substr $arg1 $q 1) 8) [
+= numquotes 1
]
]
result $numquotes
]
getQuotePosition = [
open_q = -1
loop h (strlen $arg1) [
if (testchar (substr $arg1 $h 1) 8) [
open_q = $h
break
]
]
if (&& (!= $got_open_quote -1) (&& (!= $got_close_quote -1) (!= $got_open_quote $got_close_quote))) [
result 1
] [ result 0 ]
]
reverseString = [
@@ -66,7 +67,7 @@ MDArray_New_Subarray = [
]
MDArray_Get_Bracket_Positions = [
open_bracket_pos = (+ (strpos $arg1 $arg2) (strlen $arg2))
open_bracket_pos = (+ (strpos $arg1 $arg2) (+ (strlen $arg2) 1))
close_bracket_pos = -1
loop i (- (strlen $arg1) $open_bracket_pos) [
@@ -87,18 +88,13 @@ MDArray_Get = [
if (!= $close_bracket_pos -1) [
+= open_bracket_pos 1 // skip the bracket itself when extracting the subarray with the line below
-= close_bracket_pos 1
subarray = (substr $mdarray $open_bracket_pos (- $close_bracket_pos $open_bracket_pos))
subarray = (substr $subarray 2 (- (strlen $subarray) 3)) // trim brackets/whitespace from the subarray
subarray = (substr $subarray 1 (- (strlen $subarray) 1)) // trim first quotation from the subarray
subarray = (substr $subarray 0 (- (strlen $subarray) 1)) // trim last quotation from the subarray
// double check that the first and last chars of the subarray are not quotations
firstchar = (substr $subarray 0 1)
lastchar = (substr $subarray (- (strlen $subarray) 1) 1)
// trim quotations
if (! (hasQuotePair $subarray)) [ // only if its not a multi-word elements array
if (testchar $firstchar 8) [ subarray = (substr $subarray 1 (- (strlen $subarray) 1)) ]
if (testchar $lastchar 8) [ subarray = (substr $subarray 0 (- (strlen $subarray) 1)) ]
if (<= (countQuotes $subarray) 2) [ // quotes need to be trimmed from single-list subarrays
getQuotePosition $subarray
subarray = (substr $subarray (+ $open_q 1))
subarray = (substr $subarray 0 (- (strlen $subarray) 1))
]
if (= $arg3 -1) [