在消息中格式化文本
我们已经很久没有说话了。
面对将文本格式化的问题。要求该消息以几行显示,左侧有空格。
下面给出了测试SRIPT。没有选项给出所需的结果。左侧的所有空格和标签都被忽略。请参阅屏幕截图。
我想看到的结果是在脚本的评论行中给出的。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AnyDozer
//@version=5
indicator("Test message for alert")
str1 = "\{" + "\n"
str2 = "\t" + " \"name\": \"___\"," + "\n"
str3 = " \"secret\": \"___\","+ "\n"
str4 = " " + " \"side\": \"buy\"," + "\n"
str5 = " \"symbol\": \"___\"," + "\n"
str6 = " \"open\": {" + "\n"
str7 = " \"amountType\": \"___\"," + "\n"
str8 = " \"amount\": \"___\"" + "\n"
str9 = " }" + "\n"
str0 = "}"
if true
alert(str1+str2+str3+str4+str5+str6+str7+str8+str9+str0, alert.freq_once_per_bar_close)
plot(0)
// {
// "name": "___",
// "secret": "___",
// "side": "buy",
// "symbol": "___",
// "open": {
// "amountType": "___",
// "amount": "___"
// }
// }
We haven't talked for a long time.
Faced with the problem of formatting the text in the message. It is required that the message is displayed in several lines with spaces on the left.
The test sript is given below. No options give the desired result. All spaces and tabs on the left are ignored. See the screenshot.
The result that I would like to see is given in the commented lines of the script.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AnyDozer
//@version=5
indicator("Test message for alert")
str1 = "\{" + "\n"
str2 = "\t" + " \"name\": \"___\"," + "\n"
str3 = " \"secret\": \"___\","+ "\n"
str4 = " " + " \"side\": \"buy\"," + "\n"
str5 = " \"symbol\": \"___\"," + "\n"
str6 = " \"open\": {" + "\n"
str7 = " \"amountType\": \"___\"," + "\n"
str8 = " \"amount\": \"___\"" + "\n"
str9 = " }" + "\n"
str0 = "}"
if true
alert(str1+str2+str3+str4+str5+str6+str7+str8+str9+str0, alert.freq_once_per_bar_close)
plot(0)
// {
// "name": "___",
// "secret": "___",
// "side": "buy",
// "symbol": "___",
// "open": {
// "amountType": "___",
// "amount": "___"
// }
// }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于任何体面的解析器而言,缺少空间不应该是一个问题。我个人从来没有考虑过我的机器人。
无论如何,您可以尝试使用我们用来在用户输入中添加空格的特殊字符。
这是我下面标记的点。

Missing spaces should not be an issue for any decent parser. I personally never think about those for my bots.
Anyways, you can try using a special character that we use to add spaces in user inputs.
The character is not visible on Stackoverflow but you can find it if you check the built-in MACD's source code for example.
It's the dots I marked below.
