如何修复此 gnuplot 错误以处理按键?

How to fix this gnuplot error to handle key presses?

我正在尝试为我的 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

字符串相等性测试是 eq 而不是 ==,因此您需要 if (MOUSE_CHAR eq "w") { print "w" }.