Skip to content

Commit ceb9bca

Browse files
v2.1.8 : Added Split to List Options
1 parent b07627b commit ceb9bca

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

EZCode/EZCode.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2678,8 +2678,29 @@ Var DoList(string[] parts, int _index, string keyword, bool global = false)
26782678
ErrorText(parts, ErrorTypes.missingVar, keyword, name);
26792679
}
26802680
break;
2681+
case "split":
2682+
try
2683+
{
2684+
var = getVar(name);
2685+
if (var.isSet && var.isArray())
2686+
{
2687+
string value = getString_value(parts, _index + 2)[0];
2688+
string splitter = getString_value(parts, _index + 3)[0];
2689+
string[] allvalues = value.Split(splitter);
2690+
var.set(array: allvalues);
2691+
}
2692+
else if (!var.isArray())
2693+
{
2694+
ErrorText(parts, ErrorTypes.custom, custom: $"Expected a list variable");
2695+
}
2696+
}
2697+
catch
2698+
{
2699+
ErrorText(parts, ErrorTypes.custom, custom:$"Error splitting values to list");
2700+
}
2701+
break;
26812702
default:
2682-
ErrorText(parts, ErrorTypes.custom, custom: $"Expected 'new', 'add', 'equals', 'remove', 'destroy' or 'clear'");
2703+
ErrorText(parts, ErrorTypes.custom, custom: $"Expected 'new', 'add', 'equals', 'remove', 'destroy', 'split' or 'clear'");
26832704
break;
26842705
}
26852706
var.Method = currentmethod != null && !global ? currentmethod.Name : "";

0 commit comments

Comments
 (0)