REBOL布局:如何自动创建布局单词-单词没有上下文? [英] REBOL layout: How to create layout words automatically - word has no context?

查看:95
本文介绍了REBOL布局:如何自动创建布局单词-单词没有上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用REBOL/View 2.7.8 Core,我想通过自动将单词分配给各种布局项目来预先准备视图布局,如以下示例所示. 代替

Using the REBOL/View 2.7.8 Core, I would like to prepare a view layout beforehand by automatically assigning words to various layout items, as in the following example. Instead of

prepared-view: [across 
                cb1: check 
                label "Checkbox 1"
                cb2: check
                label "Checkbox 2"
                cb3: check
                label "Checkbox 3"
                cb4: check
                label "Checkbox 4"
                ]
    view layout prepared-view

因此,我希望自动创建单词cb1cb5,例如:

I would thus like the words cb1 thru cb5 to be created automatically, e.g.:

prepared-view2: [ across ]
    for i 1 4 1 [
        cbi: join "cb" i
        cbi: join cbi ":"
        cbi: join cbi " check"
        append prepared-view2 to-block cbi
        append prepared-view2 [
        label ]
        append prepared-view2 to-string join "Checkbox " i 
        ]
    view layout prepared-view2

但是,尽管difference prepared-view prepared-view2在被解析的块(== [])中显示没有差异,但是第二个脚本导致错误:

However, while difference prepared-view prepared-view2 shows no differences in the block being parsed (== []), the second script leads to an error:

    ** Script Error: cb1 word has no context
    ** Where: forever
    ** Near: new/var: bind to-word :var :var

我已经花了数小时试图理解为什么,而且我认为新词需要以某种方式绑定到特定的上下文,但是我还没有找到解决该问题的任何方法.

I've spent hours trying to understand why, and I think somehow the new words need to be bound to the specific context, but I have not yet found any solution to the problem.

我需要做什么?

推荐答案

bind prepared-view2 'view  
view layout prepared-view2

创建正确的绑定.

这是动态创建布局的另一种方法

And here's another way to dynamically create layouts

>> l: [ across ]
== [across]
>> append l to-set-word 'check
== [across check:]
>> append l 'check
== [across check: check]
>> append l "test"
== [across check: check "test"]
>> view layout l

然后您可以使用循环创建不同的变量以添加到您的布局中.

And then you can use loops to create different variables to add to your layout.

这篇关于REBOL布局:如何自动创建布局单词-单词没有上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆