GraphBoxes 的数量可变。如何识别我要将点击发送到哪个 GB?nw = new window("graphs", vlb = v list box());
dirname = "jpegs";
set default directory(dirname);
foreach({jpeg}, files in directory(dirname), // dexter.jpg, samurai_jack.jpg, spongebob.jpg
img = new image(jpeg);
msg = eval insert("\!"^jpeg^\!"");
h = graphbox(
<<ADD image=""></ADD>The above gives me
3 graphboxes :white_heavy_check_mark:</img>with three correctly rendered images, :white_heavy_check_mark:</img>but StatusMsg always sends "Spongebob.jpg". (Without the evalinsert(), just sending jpeg to StatusMsg, it throws an error.)
I want StatusMsg to give me the name of the image whose graphbox I clicked on.
Basically, I can kinda sorta imagine two routes:
1. Eval and related functions? I still haven't dug into that side of JSL very deeply.
2. Xpath? Maybe log the image name in a List; index will correspond with the frame box number.
<LINGO-LABS id="lingo-labs-797481" slang="en-US" mode="UPDATE"><LINGO-LABEL>自动化和脚本</LINGO-LABEL></LINGO-LABS>回复:GraphBox 数量可变。如何识别我要将点击发送到哪个 GB?每当用户点击图像时,捕鼠器就会收到调用的命令
statusmsg( variablename)
So: it will execute statusmsg( variablename), check for the current content of variablenamea and display it.
正如您注意到并尝试的那样:您必须以某种方式强制对变量进行评估。
问题:
将结果存储在另一个变量( msg )中会遇到同样的问题——只是另一个变量名。
您想要做什么:
对于每个图像预先评估图像名称和触发器,例如
statusmsg("samurai_jack.jpg")在 90% 的情况下,这种预评估可以通过Eval(Eval Expr()) 完成。
对于其余的,使用Eval(Substitute())
JMP 中的表达式处理:Tipps 和 Trapdoors
Eval (Eval Expr( h=graphbox(
<<ADD image=""></ADD>
回复:GraphBox 数量可变。如何识别我要将点击发送到哪个 GB?哈哈,我明白了
foreach({jpeg}, files in directory(jpegs),
img = new image(jpeg);
h = Eval(
Eval Expr(
graphbox(
<<ADD image=""></ADD>It's not clear to me why `jpeg` needs the expr() and `img` doesn't, though. Both of those vars are 'born' on a per-loop basis
回复:GraphBox 数量可变。如何识别要将点击发送到哪个 GB?是的,这在 JSL 中是一个相当大的问题。不幸的是,没有文档说明哪些参数被求值 - 哪些参数只是被“传输”。有时很难找出答案:
Head 是否评价了它的论点?
我向 JMP 支持部门寻求了一份评估/不评估其参数的函数官方列表。不幸的是,没有这样的列表。
另一种方法: 在 JSL 编辑器中使用一些高级语法突出显示 - 该函数是否评估它的参数?
我希望它将在后续版本中实现....
实际上,JSL 中的许多(!!!)函数在使用它们之前并不会评估(部分)它们的参数。
这个办法非常的厉害!
最突出的“刚转学”例子:
New column (.... Formula(<U>Expression gets just transferred</U>))
对于 Mouse Trap 来说也是如此。
如果你再想一想 - JMP 非常好心地没有对参数进行求值:)
您希望在用户点击图像时更改状态消息 - 而不是在执行代码时。
另一方面:要将图像添加到窗口,JMP 必须打开图像文件 - 并且要这样做:查看变量。
注意:有时,用 Eval(argument) 替换参数会有所帮助。
有时。
这里:没有。