forked from Nivekk/KOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandCallExternal.cs
More file actions
35 lines (26 loc) · 947 Bytes
/
CommandCallExternal.cs
File metadata and controls
35 lines (26 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace kOS
{
[CommandAttribute(@"^CALL ([a-zA-Z0-9]+) ?\((.*?)\)$")]
public class CommandCallExternal : Command
{
public CommandCallExternal(Match regexMatch, ExecutionContext context) : base(regexMatch, context) { }
public override void Evaluate()
{
String name = RegexMatch.Groups[1].Value;
String paramString = RegexMatch.Groups[2].Value;
var parameters = new List<String>();
foreach (String param in Utils.ProcessParams(paramString))
{
Expression subEx = new Expression(param, this);
parameters.Add(subEx.GetValue().ToString());
}
CallExternalFunction(name, parameters.ToArray());
State = ExecutionState.DONE;
}
}
}