我有這樣的代碼:爲什麼REBOL佈局似乎是持久的?
REBOL [Title: "Employee list"]
screen1: does [
emp-list: [
"Amy" 1
"Bob" 2
"Carrie" 3
]
gui-layout: [ text "click your name" ]
foreach [emp-name emp-id] emp-list [
append gui-layout compose/deep [
box (emp-name) [screen2 (emp-id)]
]
]
view layout gui-layout
]
screen2: func [emp-id] [
choice-list: [
"A" 11
"B" 22
]
gui-layout: [
box "<-- back to names" [screen1]
text reform ["clicked id " emp-id ", now choose below"]
]
foreach [choice-name choice-id] choice-list [
append gui-layout compose/deep [
box (choice-name) [print [(emp-id) (choice-id)]]
]
]
view layout gui-layout
]
screen1
現在,如果你點擊然後有人點擊「後退」,菜單增長。 (如果你點擊其他人,第二個菜單也會增長。)我發現的一個解決方法(?)是在view layout gui-layout
之前將clear emp-list
修正爲第一個屏幕。然而,如果我在那裏,我可以看到它不是emp-list
,它正在增長。怎麼會這樣?
每個系列我也試過'之前清除gui-layout',並使用'has'(或'screen2'的'function')製作本地和本地佈局,但這些都不能達到只畫一個新的lis每次都是。 – Kev