【问题标题】:How to fix this gnuplot error to handle key presses?如何修复此 gnuplot 错误以处理按键?
【发布时间】:2021-06-02 21:10:34
【问题描述】:

我正在尝试为我的 gnuplot 脚本提供基本的键盘交互。 对于gnuplot 5.4 patchlevel 1,我相信我将MOUSE_CHAR 用作documented,但是使用下面最简单的脚本,无论我按什么键都会出错。

while (1) {
    pause mouse keypress
    show variable MOUSE_

    if (exists("MOUSE_CHAR")) {
        if (MOUSE_CHAR == "w") {
            print "w"
        }
    }             # <-- line 114

    replot
}

输出显示按下了正确的键,例如:

        MOUSE_KEY = 119
        MOUSE_CHAR = "w"

        MOUSE_KEY = 114
        MOUSE_CHAR = "r"

但在我得到之后立即

"hrtp.gp" line 114: Non-numeric string found where a numeric expression was expected

【问题讨论】:

    标签: keyboard gnuplot mouse numeric


    【解决方案1】:

    字符串相等的测试是eq 而不是==,所以你需要if (MOUSE_CHAR eq "w") { print "w" }

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-16
    • 1970-01-01
    • 1970-01-01
    • 2020-02-22
    • 2014-03-01
    • 2012-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多