如何实时读取聊天应用程序的文件?

lec*_*uck 5 rebol rebol3 rebol2

我正在尝试在Rebol中编写一个基于单个文本文件的简单聊天应用程序.什么是"实时"读取该文件的最佳方式?现在我已经得到了它:

    t1: text 600x300 wrap green black font-name font-fixed  rate 1 feel[
    engage: func [face action event][
        if action = 'time [
            face/text: read chatText
            show face
        ] 
    ] 
] 
Run Code Online (Sandbox Code Playgroud)

文本字段每秒都会随文件内容一起更新.即使有多个用户,这也有效,但每个用户每秒都会读取整个文件.有没有更好的方法来做这种事情?

end*_*o64 2

看一下info?功能。你可以这样做:

REBOL []
chat-file: %file.txt
file-info: info? chat-file
update-date: file-info/date

view layout [
    t1: text read chat-file 600x300 wrap green black font-name font-fixed  rate 1 feel [
        engage: func [face action event] [
            if all [
                action = 'time
                file-info: info? chat-file
                update-date < file-info/date
            ] [
                update-date: file-info/date
                face/text: read chat-file
                show face
            ]
        ]
    ]
]
Run Code Online (Sandbox Code Playgroud)

但如果您要从多个应用程序写入该文件,则需要小心。