与红/ REBOL
字类型的处理块参数调用时:与红/ REBOL
f [(h test) (h test2)]
我想:
"<p><h1>test</h1><h1>test2</h1></p>"
相反,我得到:
"<h1>test2</h1></p>"
我不能看看为什么我的代码不起作用。请注意,我想在下面使用g函数,因为我有几个像函数一样的函数,每个函数都会调用g来分解它们。所以不要摆脱它,这是故意的。
html: copy ""
emit: func [code] [repend html code]
f: func [param [block!]] [
html: copy ""
emit: func [code] [repend html code]
emit <p>
foreach p param [
emit p
]
emit </p>
return html
]
g: func ['arg [string! word!] /local html] [
return h :arg
]
h: func ['arg [string! word!]] [
either word? arg [
text: to-string arg
][
text: arg
]
html: copy ""
emit: func [code] [repend html code]
print text
emit <h1>
emit text
emit </h1>
return html
]
f [(h test) (h test2)]
更新:
现在我得到了红色的错误: 脚本错误:HTML是不是在指定的上下文
f: func[param [block!] /local html][
html: copy ""
emit: func [code] [repend html code]
emit <p>
foreach p param [
emit p
]
emit </p>
return html
]
g: func['arg [string! word!] /local html][
return h :arg
]
h: func['arg [string! word!] /local html][
either word? arg [text: to-string arg][
text: arg
]
html: copy ""
emit: func [code] [repend html code]
print text
emit <h1>
emit text
emit </h1>
return html
]
f [(h test) (h test2)]
好吧,这里一稍微优化版本为红色和雷博尔没有本功能或功能
emit: func [code html] [repend html code]
f: func[param [block!] /local html][
html: copy ""
emit <p> html
foreach p param [
emit p html
]
emit </p> html
return html
]
g: func['arg [string! word!] l][
return h :arg
]
h: func['arg [string! word!] /local html text][
either word? arg [text: to-string arg][
text: arg
]
html: copy ""
print text
emit <h1> html
emit text html
emit </h1> html
return html
]
>>f [ [h test] [h test2]]
test
test2
== "<p><h1>test</h1><h1>test2</h1></p>"
你的问题是无处不在,新的全球html: copy ""
使用初始化已经发布的html。如果你让本地与规范块手动或通过与本功能在Rebol2或功能红色更换FUNC/本地HTML,它应该工作
>>f [ [h test] [h test2]]
test
test2
== "<p><h1>test</h1><h1>test2</h1></p>"
>>
我已经更新代码,使本地HTML看到上面,但红色我得到脚本错误:HTML不在指定的上下文 – user310291
它在红色,如果你使用函数。你必须定义** html **,**发布** a.s.o.在相同的情况下 – sqlab
很好用[]和()非常感谢:) – user310291