Add user action evaluator: Concatenate strings

qteditor
Sven Eberhardt 2016-07-31 00:28:02 -04:00
parent 404a578e5c
commit 9b5c39a33f
3 changed files with 16 additions and 0 deletions

View File

@ -206,6 +206,9 @@ func Definition(def)
// String evaluators
AddEvaluator("String", nil, ["$Constant$", ""], "$ConstantHelp$", "string_constant", [def, def.EvalConstant], { Value="" }, { Type="string", Name="$Value$" });
AddEvaluator("String", nil, ["$ValueToString$", ""], "$ValueToStringHelp$", "value_to_string", [def, def.EvalStr_ValueToString], { }, new Evaluator.Any { });
AddEvaluator("String", nil, "$Concat$", "$ConcatHelp$", "string_concat", [def, def.EvalStr_Concat], { Substrings=[] }, { Type="proplist", DescendPath="Substrings", Display="{{Substrings}}", EditorProps = {
Substrings = { Name="$Substrings$", Type="array", Elements=Evaluator.String, DefaultValue={Function="string_constant",Value=""} }
} } );
AddEvaluator("String", nil, "$Variable$", "$VariableHelp$", "integer_variable", [def, def.EvalVariable, C4V_String], { VariableName={Function="string_constant",Value=""} }, variable_delegate);
// Position evaluators
AddEvaluator("Position", nil, ["$ConstantPositionAbsolute$", ""], "$ConstantPositionAbsoluteHelp$", "position_constant", [def, def.EvalConstant], def.GetDefaultPosition, { Type="point", Name="$Position$", Relative=false, Color=0xff2000 });
@ -825,6 +828,13 @@ private func EvalStr_ValueToString(proplist props, proplist context)
return Format("%v", EvaluateValue("Any", props.Value, context));
}
private func EvalStr_Concat(proplist props, proplist context)
{
var result="";
for (var s in props.Substrings) result = Format("%s%s", result, EvaluateValue("String", s, context));
return result;
}
/* Context instance */

View File

@ -196,3 +196,6 @@ Log=Log
LogHelp=Ausgabe einer Debugnachricht.
LogMessage=Nachricht
LogMessageHelp=Der auszugebende Text.
Concat=Zusammensetzen
ConcatHelp=Verbindet mehrere Texte zu einem langen Text.
Substrings=Texte

View File

@ -196,3 +196,6 @@ Log=Log
LogHelp=Output a debug log message.
LogMessage=Message
LogMessageHelp=The text to output.
Concat=Concatenate
ConcatHelp=Concatenates multiple small texts to one long text.
Substrings=Texts