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

标签 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
        ] 
    ] 
] 

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

最佳答案

看看 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
            ]
        ]
    ]
]

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

关于rebol - 聊天应用程序如何实时读取文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37004598/

相关文章:

dll - 如何使用 LibFFI 支持构建 Rebol 的 "Ren-C"分支?

rebol - `context` 和 `object` 和有什么区别?

rebol - 如何删除rebol上的默认标题栏?

module - Rebol模块中的单词是如何绑定(bind)的?

rebol - 在 REBOL 中动态地将单词添加到上下文中

ssl - 什么可能是这个 : ** Command Error: SSL Error: error:14077410:SSL routines:SSL23_GET_SERVER_HEL LO:sslv3 alert handshake failure 的原因

parsing - Rebol:如何将相同的解析规则应用于从 Windows 剪贴板粘贴的多行

rebol - 如何通过添加函数来扩展对象,然后使用 self 访问原始对象?

url-routing - Rebol 3 方案中的用户/密码