Heres what I got, a splitstring sub that makes a global array and populates that array with each string inbetween a defined splitter such as |
Problem is, I get this error when running my macro:
Code: Select all
/varset 'targets[-1]' failed, out of bounds on array
@1609 (SplitString(string varname, string inputstring, string splitter)): /varset ${varname}[${C}] ${inputstring.Left[${i}]}
@262 (Main): /call SplitString targets "${Param0}" "|"
Code: Select all
|----------------------------------------------------------------------------
|SUB: SplitString - A generic string splitter.
|----------------------------------------------------------------------------
Sub SplitString(string varname, string inputstring, string splitter)
|A variable with name in varname will be declared and filled
/declare i int local
/declare i2 int local
/declare c int local
/declare stringcnt int local
/varcalc stringcnt ${inputstring.Count["|"]} + 1
/if (!${Defined[${varname}]}) {
/declare ${varname}[${stringcnt}] string global
} else {
/deletevar ${varname}
/declare ${varname}[${stringcnt}] string global
}
/varset c 1
:nextsubstring
/varcalc i ${inputstring.Find["${splitter}"]} - 1
|/echo ${inputstring}:${splitter} ${inputstring.Find["${splitter}"]}
/if ( ${i}>-1 ) {
|/echo iii: ${inputstring.Length} ${inputstring} ${i}
/varcalc i2 ${inputstring.Length} - ${i} +1
| /varcalc i2 ${inputstring.Length} - ${i} - 1 BUGFIX?????
/varset ${varname}[${c}] ${inputstring.Left[${i}]}
/varcalc c ${c} + 1
|/echo stringarray[${c}] ${inputstring.Left[${i}]}
/varset inputstring ${inputstring.Right[${i2}]}
/goto :nextsubstring
} else {
|/echo stringarray[${c}] ${inputstring}
/varset ${varname}[${c}] ${inputstring}
}
/return
I thought maybe the issue was needing to force the first param in as a string as such:
Code: Select all
/call SplitString "targets" "${Param0}" "|"
Code: Select all
/call SplitString targets "${Param0}" "|"
Also, here is some test input that I've used
/call mac skele|pawn
/call mac lion|spider
/call mac skele
no good on any of em
Am I missing something?
edit: added error message that made me title thread way i did.
edit2: adding in the input i'm using specifically for this particular array error, though i've tried many different entires for testing

