5.4 Advanced output
Committed Output : the output stream, a magical place that queues up each word you write in a rule output.
So, output does two things. It queues up tokens to send to the user, which may be discarded if the rule ultimately fails. And it can call out to various functions. Things those functions may do are permanent, not undone if the rule later fails.
^reuse, ^gambit, ^respond
Output cannot have rules in it :
u: GREETING ( ~emohello )
if ($username) {
Hi $username !
} else {
I don't believe we've met, what's your name?
# a: (_*) So your name is '_0?
}
a: (_*) So your name is '_0? Formatted double quotes ( Active/Format String ) : The active string ^"xxx" string is a format string. The system will remove the ^ and the quotes and put it out exactly as you have
it,
Json Active Strings : ^'{ "test" : "my \"value\" \x" }
Functional Strings :
Loop Construct - loop or ^loop : Allows you to repeat script.
If Construct - if or ^if :
Pattern If : Eg. if (pattern bingo _*1 ~helo ) { ... }
Quoting : '$name will print $name .
Outputting underscores :
Response Controlinput :
Output Macros : Eg. Outputmacro: name (^arg1 ^arg2 ...)
Sharing function definitions :
Save-Restore locals :
Output Macros vs ^reuse() :
System Functions :
Randomized Output Revisited [ ] :
本文探讨了高级输出管理的概念,包括如何使用输出流来排队发送给用户的令牌,并介绍了多种输出控制方式,如格式化字符串、功能字符串及输出宏等。此外,还讨论了规则失败后的输出处理及如何通过各种内置功能实现更为复杂的输出逻辑。
2217

被折叠的 条评论
为什么被折叠?



