<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Variable number of GraphBoxes. How can I identify which GB I'm sending clicks to? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797519#M97336</link>
    <description>&lt;P&gt;Whenever a user clicks on an image, mousetrap gets the order to call&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;statusmsg( variablename)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So: it will execute&amp;nbsp;&lt;CODE class=" language-jsl"&gt;statusmsg( variablename)&lt;/CODE&gt;, check for the current content of &lt;CODE class=" language-jsl"&gt;variablename&lt;/CODE&gt;&amp;nbsp;and display it in the status bar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you noticed and tried to:&lt;BR /&gt;You have to force the variable to be evaluated somehow before using it in the expression.&lt;BR /&gt;&lt;BR /&gt;The issue:&lt;BR /&gt;storing the result in another variable (&lt;FONT face="courier new,courier"&gt;msg&lt;/FONT&gt;) leaves you with the same issue - just another variable name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you want to do:&amp;nbsp;&lt;/P&gt;&lt;P&gt;For every image pre-evaluate the image name and trigger e.g.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;statusmsg("samurai_jack.jpg")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In 90% of the cases, this pre-evaluation can be done via &lt;FONT face="courier new,courier"&gt;Eval(Eval Expr()).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;For the remaining ones, use &lt;FONT face="courier new,courier"&gt;Eval(Substitute())&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="Expression Handling in JMP: Tipps and Trapdoors" uid="747728" url="https://community.jmp.com/t5/Discussions/Expression-Handling-in-JMP-Tipps-and-Trapdoors/m-p/747728#U747728" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval (Eval Expr( h=graphbox(
			&amp;lt;&amp;lt;Add Image(
				image( img ),
				bounds( top( 90 ), Left( 10 ), Bottom( 10 ), Right( 90 ) )
			),
			mouse trap(	
				statusmsg( Expr(jpeg) )
			)

	)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2024 15:37:14 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2024-09-10T15:37:14Z</dc:date>
    <item>
      <title>Variable number of GraphBoxes. How can I identify which GB I'm sending clicks to?</title>
      <link>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797481#M97333</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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(
			&amp;lt;&amp;lt;Add Image(
				image( img ),
				bounds( top( 90 ), Left( 10 ), Bottom( 10 ), Right( 90 ) )
			),
			mouse trap(
				
				statusmsg( msg )
			)

	);
	vlb&amp;lt;&amp;lt;append( h )
	
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above gives me&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;3 graphboxes :white_heavy_check_mark:&lt;/img&gt;&lt;/LI&gt;&lt;LI&gt;with three correctly rendered images, :white_heavy_check_mark:&lt;/img&gt;&lt;/LI&gt;&lt;LI&gt;but StatusMsg always sends "Spongebob.jpg". (Without the evalinsert(), just sending jpeg to StatusMsg, it throws an error.)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I want StatusMsg to give me the name of the image whose graphbox I clicked on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I can kinda sorta imagine two routes:&lt;/P&gt;&lt;P&gt;1. Eval and related functions? I still haven't dug into that side of JSL very deeply.&lt;/P&gt;&lt;P&gt;2. Xpath? Maybe log the image name in a List; index will correspond with the frame box number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 15:14:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797481#M97333</guid>
      <dc:creator>mtowle419</dc:creator>
      <dc:date>2024-09-10T15:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of GraphBoxes. How can I identify which GB I'm sending clicks to?</title>
      <link>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797519#M97336</link>
      <description>&lt;P&gt;Whenever a user clicks on an image, mousetrap gets the order to call&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;statusmsg( variablename)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So: it will execute&amp;nbsp;&lt;CODE class=" language-jsl"&gt;statusmsg( variablename)&lt;/CODE&gt;, check for the current content of &lt;CODE class=" language-jsl"&gt;variablename&lt;/CODE&gt;&amp;nbsp;and display it in the status bar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you noticed and tried to:&lt;BR /&gt;You have to force the variable to be evaluated somehow before using it in the expression.&lt;BR /&gt;&lt;BR /&gt;The issue:&lt;BR /&gt;storing the result in another variable (&lt;FONT face="courier new,courier"&gt;msg&lt;/FONT&gt;) leaves you with the same issue - just another variable name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you want to do:&amp;nbsp;&lt;/P&gt;&lt;P&gt;For every image pre-evaluate the image name and trigger e.g.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;statusmsg("samurai_jack.jpg")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In 90% of the cases, this pre-evaluation can be done via &lt;FONT face="courier new,courier"&gt;Eval(Eval Expr()).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;For the remaining ones, use &lt;FONT face="courier new,courier"&gt;Eval(Substitute())&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="Expression Handling in JMP: Tipps and Trapdoors" uid="747728" url="https://community.jmp.com/t5/Discussions/Expression-Handling-in-JMP-Tipps-and-Trapdoors/m-p/747728#U747728" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval (Eval Expr( h=graphbox(
			&amp;lt;&amp;lt;Add Image(
				image( img ),
				bounds( top( 90 ), Left( 10 ), Bottom( 10 ), Right( 90 ) )
			),
			mouse trap(	
				statusmsg( Expr(jpeg) )
			)

	)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 15:37:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797519#M97336</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-09-10T15:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of GraphBoxes. How can I identify which GB I'm sending clicks to?</title>
      <link>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797520#M97337</link>
      <description>&lt;P&gt;Lol I figured it out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;foreach({jpeg}, files in directory(jpegs),
	img = new image(jpeg);

	h = Eval(
		Eval Expr(
			graphbox(
				&amp;lt;&amp;lt;Add Image(
					image( img ),
					bounds( top( 90 ), Left( 10 ), Bottom( 10 ), Right( 90 ) )
				),
				mouse trap(
					statusmsg( expr(jpeg) )
				)
			);
		)
	);
	vlb&amp;lt;&amp;lt;append( h )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 15:27:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797520#M97337</guid>
      <dc:creator>mtowle419</dc:creator>
      <dc:date>2024-09-10T15:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of GraphBoxes. How can I identify which GB I'm sending clicks to?</title>
      <link>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797533#M97340</link>
      <description>&lt;P&gt;yes ,this is a quite an issue in JSL. Unfortunately, there is no documentation which arguments get evaluated - and which arguments just&amp;nbsp; get "transferred".And sometimes it's not at all easy to find out:&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="Does Head evaluate its argument?" uid="729500" url="https://community.jmp.com/t5/Discussions/Does-Head-evaluate-its-argument/m-p/729500#U729500" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I asked JMP support for an official list of functions which evaluate / don't evaluate their argument. Unfortunately, there no such list.&lt;BR /&gt;Another approach: use some&amp;nbsp;&lt;LI-MESSAGE title="Advanced syntax highlighting in JSL Editor - does the function evaluate it's argument?" uid="729460" url="https://community.jmp.com/t5/JMP-Wish-List/Advanced-syntax-highlighting-in-JSL-Editor-does-the-function/m-p/729460#U729460" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope, it will get implemented with some of the next releases ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, many(!!!) functions in JSL don't evaluate (some of) their arguments before using them.&lt;BR /&gt;This approach is extremely powerful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The most prominent example of "just transferred":&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New column (.... Formula(&lt;U&gt;Expression gets just transferred&lt;/U&gt;))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same holds for Mouse Trap.&lt;BR /&gt;If you think about it again - it's very kind by JMP that it doesn't evaluate the argument : )&lt;BR /&gt;You want to change the status message whenever the user clicks on the image - not at the moment when you execute the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the other hand: to add the image to the Window, JMP has to open the image file - and to do so: look into the variable.&lt;BR /&gt;NB: Sometimes, it helps to replace an argument with Eval(argument).&lt;BR /&gt;Sometimes.&lt;BR /&gt;Here: no.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 15:51:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Variable-number-of-GraphBoxes-How-can-I-identify-which-GB-I-m/m-p/797533#M97340</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-09-10T15:51:26Z</dc:date>
    </item>
  </channel>
</rss>

