<?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: Name Unresolved &amp;amp; Deleted Object Reference in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/RE-Name-Unresolved-amp-Deleted-Object-Reference/m-p/62409#M33652</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/8582"&gt;@cwillden&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for the help. I was supposed to have a tag to make my text bold which was why I used Markup but I realised I took them out. I changed the throws and text boxes to captions just for consistency. Thanks again for the explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jul 2018 12:13:02 GMT</pubDate>
    <dc:creator>Jaz</dc:creator>
    <dc:date>2018-07-10T12:13:02Z</dc:date>
    <item>
      <title>RE: Name Unresolved &amp; Deleted Object Reference</title>
      <link>https://community.jmp.com/t5/Discussions/RE-Name-Unresolved-amp-Deleted-Object-Reference/m-p/62345#M33600</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm basically trying to access a variable that's been created within a function. I'm trying to print that variable outside of the function but keep getting name unresolved / deleted reference 'Glue' errors. I basically have a function for a button which creates a new window and stores the value of&amp;nbsp;lf inside that function and window creation. I want to be able to print the value of&amp;nbsp;lf but I'm not sure how. Any suggestions would be appreciated. Another question is that when I print lf inside of the OKscript1 function, it isn't printed to the log. Is that because OKscript1 isn't a function but an Expr? Also, when I&amp;nbsp;run the program the first time after selecting a file, I get a name unresolved error. But when I run it again and select a different file and view the log then the previous file I had selected before exiting appears in the log. Any ideas as to why? I think its probably either a really simple thing I've overlooked or something to do with my scoping?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;mainWindow = New Window("Instruction Tagger",
	ob = Outline Box("Instruction Tagger",
		Border Box(Left(3), top(2),
			V List Box(
				H List Box( 
					Panel Box("Please choose one of the following options:", &amp;lt;&amp;lt;Markup(1),  
						Button Box("Tag a Single File", singleFileButton1("Tag Instructions to Data") ),
						Button Box( "Tag Multiple Files", singleFileButton1("Tag Instructions to Data") ), 
						Text Box("Note: a button to tag the data will appear automatically after you have selected the measurement &amp;amp; PFD files. ")
					)
				)
			)
		)
	)
);  



singleFileButton1 = Function({x}, 
mainWindow &amp;lt;&amp;lt; Close Window; 
choosingFilesWindow = New Window(x,   
	ob = Outline Box("Select Your Files: ", 
		Border Box (Left(3), top(2)), 
			vDisplay = V List Box( 
				H List Box(
					Panel Box("Please select one of the options below to choose your measurement &amp;amp; PFD file: ", &amp;lt;&amp;lt;Markup(1), 
						Button Box("Select Measurement File", selectMeasurementFileButton("Select Measurement File")), 
						Button Box("Select PFD File", selectPFDFileButton("Select PFD File")), 
						Lineup Box (N Col(2), Spacing(3)), 
						Panel Box("Files Added",
						CB = Check Box({"Measurement file added", "PFD file added"},&amp;lt;&amp;lt;Set(1,0),&amp;lt;&amp;lt;Set(2,0),&amp;lt;&amp;lt;Enable Item(1,0),&amp;lt;&amp;lt;Enable Item(2,0))),
						Text Box("Note: The relevant check-boxes above will be ticked once the file has been added.",&amp;lt;&amp;lt; Set Wrap( 500 )),
						hidden = Button Box("Commence tagging")))))));
selectMeasurementFileButton = Function({y}, 
title = y;
lbWidth = 220;
nc=12;
selectedDir = Pick Directory();
fileList = Files In Directory( selectedDir );
fileSelected = {};

// *********************************************************************************
// Build custom dialog in a window
// *********************************************************************************
win1 = New Window( "Select Files",
	Border Box( Left( 3 ), top( 2 ),
		V List Box(
			H List Box(
				Panel Box( "Available Files ", ListData = List Box( fileList, width( lbWidth ), nLines( Min( nc, 12 ) ) ) ),
				Panel Box( "Selected File ",
					Lineup Box( N Col( 2 ), Spacing( 3 ),
						Button Box( "File To Tag", ListF &amp;lt;&amp;lt; Append( ListData &amp;lt;&amp;lt; GetSelected ) ),
						ListF = List Box( fileSelected, width( lbWidth ), nLines( 5 ), Numeric )
					)
				),
				Panel Box( "Action",
					Lineup Box( N Col( 1 ),
						okButton = Button Box( "OK", OKScript1),
						Button Box( "Cancel",
							//win1 &amp;lt;&amp;lt; CloseWindow;
							Throw();
						),
						Text Box( " " ),
						Button Box( "Remove", RemoveScript1)
					)
				)
			)				// End of HListBox
		)					// End of VListBox
	)						// End of BorderBox
);							// End of NewWindow



); // End of button function 

// *********************************************************************************
// Do this when the user hits OK
// ********************************************************************************* 
OKScript1 = Expr( 
	//win1 &amp;lt;&amp;lt; CloseWindow; 
	//Names Default To Here(1);
	lf = ListF &amp;lt;&amp;lt; Get Items;  
	if (lf != {} &amp;amp; N Items(lf) == 1 , CB &amp;lt;&amp;lt; Set(1,1); Throw("Success: Measurement file has been added."),CB &amp;lt;&amp;lt; Set(1, 0)); 
	if(Try(N Items(lf) &amp;gt; 1), Throw ("Error: Please only select one measurement file. Alternitavely, go back and select 'Tag Multiple Files'. "));
	if(Try(N Items(lf) &amp;lt; 1), Throw ("Error: Please select one measurement file.Alternitavely, go back and select 'Tag Multiple Files'.")); 
); 

print(lf); 

print(lf); &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 14:02:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/RE-Name-Unresolved-amp-Deleted-Object-Reference/m-p/62345#M33600</guid>
      <dc:creator>Jaz</dc:creator>
      <dc:date>2018-07-09T14:02:51Z</dc:date>
    </item>
    <item>
      <title>RE: Name Unresolved &amp; Deleted Object Reference</title>
      <link>https://community.jmp.com/t5/Discussions/RE-Name-Unresolved-amp-Deleted-Object-Reference/m-p/62403#M33647</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/12049"&gt;@Jaz&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I patched up the indentation on this script because it was hard to follow.&amp;nbsp; I also removed the &amp;lt;&amp;lt;Markup(1) stuff because&amp;nbsp;you didn't have any html tags in your text anyway and it was causing warning messages.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple issues here:&amp;nbsp; When you run the script, it's going to run those "print(lf)" lines you had at the bottom before the user even does anything with the dialogs.&amp;nbsp; "lf" doesn't even exist yet when you're asking JMP to print it.&amp;nbsp; You have to put it within the OKScript1 expression so that line of code is run only when the user presses OK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You also cannot close the window before you get the items from ListF because ListF won't exist anymore.&amp;nbsp; You did have that line of code commented out, so I'm not sure if that was causing your "deleted object reference" error or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script below seems to work.&amp;nbsp; I get no errors and&amp;nbsp;print(lf) is working.&amp;nbsp; It showed the files I selected in a list in the log.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;mainWindow = New Window("Instruction Tagger",
	ob = Outline Box("Instruction Tagger",
		Border Box(Left(3), top(2),
			V List Box(
				H List Box( 
					Panel Box("Please choose one of the following options:",  
						Button Box("Tag a Single File", singleFileButton1("Tag Instructions to Data") ),
						Button Box( "Tag Multiple Files", singleFileButton1("Tag Instructions to Data") ), 
						Text Box("Note: a button to tag the data will appear automatically after you have selected the measurement &amp;amp; PFD files. ")
					)
				)
			)
		)
	)
);  



singleFileButton1 = Function({x}, 
	mainWindow &amp;lt;&amp;lt; Close Window; 
	choosingFilesWindow = New Window(x,   
		ob = Outline Box("Select Your Files: ", 
			Border Box (Left(3), top(2)), 
			vDisplay = V List Box( 
				H List Box(
					Panel Box("Please select one of the options below to choose your measurement &amp;amp; PFD file: ",
						Button Box("Select Measurement File", selectMeasurementFileButton("Select Measurement File")), 
						Button Box("Select PFD File", selectPFDFileButton("Select PFD File")), 
						Lineup Box (N Col(2), Spacing(3)), 
						Panel Box("Files Added",
						CB = Check Box({"Measurement file added", "PFD file added"},&amp;lt;&amp;lt;Set(1,0),&amp;lt;&amp;lt;Set(2,0),&amp;lt;&amp;lt;Enable Item(1,0),&amp;lt;&amp;lt;Enable Item(2,0))),
						Text Box("Note: The relevant check-boxes above will be ticked once the file has been added.",&amp;lt;&amp;lt; Set Wrap( 500 )),
						hidden = Button Box("Commence tagging")
					)
				)
			)
		)
	)
);

selectMeasurementFileButton = Function({y}, 
	title = y;
	lbWidth = 220;
	nc=12;
	selectedDir = Pick Directory();
	fileList = Files In Directory( selectedDir );
	fileSelected = {};

	// *********************************************************************************
	// Build custom dialog in a window
	// *********************************************************************************
	win1 = New Window( "Select Files",
		Border Box( Left( 3 ), top( 2 ),
			V List Box(
				H List Box(
					Panel Box( "Available Files ", ListData = List Box( fileList, width( lbWidth ), nLines( Min( nc, 12 ) ) ) ),
					Panel Box( "Selected File ",
						Lineup Box( N Col( 2 ), Spacing( 3 ),
							Button Box( "File To Tag", ListF &amp;lt;&amp;lt; Append( ListData &amp;lt;&amp;lt; GetSelected ) ),
							ListF = List Box( fileSelected, width( lbWidth ), nLines( 5 ), Numeric )
						)
					),
					Panel Box( "Action",
						Lineup Box( N Col( 1 ),
							okButton = Button Box( "OK", OKScript1),
							Button Box( "Cancel",
								//win1 &amp;lt;&amp;lt; CloseWindow;
								Throw();
							),
							Text Box( " " ),
							Button Box( "Remove", RemoveScript1)
						)
					)
				)				// End of HListBox
			)					// End of VListBox
		)						// End of BorderBox
	);							// End of NewWindow
); // End of button function 

// *********************************************************************************
// Do this when the user hits OK
// ********************************************************************************* 
OKScript1 = Expr( 
	lf = ListF &amp;lt;&amp;lt; Get Items; 
	print(lf);
	win1 &amp;lt;&amp;lt; Close Window; 
	if (lf != {} &amp;amp; N Items(lf) == 1 , CB &amp;lt;&amp;lt; Set(1,1); Throw("Success: Measurement file has been added."),CB &amp;lt;&amp;lt; Set(1, 0)); 
	if(Try(N Items(lf) &amp;gt; 1), Throw ("Error: Please only select one measurement file. Alternitavely, go back and select 'Tag Multiple Files'. "));
	if(Try(N Items(lf) &amp;lt; 1), Throw ("Error: Please select one measurement file.Alternitavely, go back and select 'Tag Multiple Files'.")); 
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'd recommend changing the "Success" if statement at the end.&amp;nbsp; I don't believe that CB &amp;lt;&amp;lt; Set(1,0) is going to be evaluated because you've already used Throw() to stop further processing.&amp;nbsp; Consider replacing Throw() with Caption() in that box.&amp;nbsp; That also makes it so the "success" message doesn't look like an error as it does with Throw().&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 20:55:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/RE-Name-Unresolved-amp-Deleted-Object-Reference/m-p/62403#M33647</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-07-09T20:55:22Z</dc:date>
    </item>
    <item>
      <title>RE: Name Unresolved &amp; Deleted Object Reference</title>
      <link>https://community.jmp.com/t5/Discussions/RE-Name-Unresolved-amp-Deleted-Object-Reference/m-p/62409#M33652</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/8582"&gt;@cwillden&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for the help. I was supposed to have a tag to make my text bold which was why I used Markup but I realised I took them out. I changed the throws and text boxes to captions just for consistency. Thanks again for the explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 12:13:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/RE-Name-Unresolved-amp-Deleted-Object-Reference/m-p/62409#M33652</guid>
      <dc:creator>Jaz</dc:creator>
      <dc:date>2018-07-10T12:13:02Z</dc:date>
    </item>
  </channel>
</rss>

