public static IP5Any Warn(Runtime runtime, P5Array args) { // TODO handle empty argument list when $@ is set and when it is not var message = new System.Text.StringBuilder(); for (var it = args.GetEnumerator(runtime); it.MoveNext(); ) message.Append(it.Current.AsString(runtime)); if (message.Length > 0 && message[message.Length - 1] != '\n') message.Append(string.Format(" at {0:S} line {1:D}.\n", runtime.File, runtime.Line)); var stderr = runtime.SymbolTable.GetGlob(runtime, "STDERR", true); stderr.Handle.Write(runtime, message.ToString()); return new P5Scalar(runtime, 1); }
public static P5Scalar JoinList(Runtime runtime, P5Array array) { var iter = array.GetEnumerator(); var res = new System.Text.StringBuilder(); bool first = true; iter.MoveNext(); var sep = iter.Current.AsString(runtime); while (iter.MoveNext()) { if (!first) res.Append(sep); first = false; res.Append(iter.Current.AsString(runtime)); } return new P5Scalar(runtime, res.ToString()); }