<?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: Finding the correct format of name jsl in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780275#M96227</link>
    <description>&lt;P&gt;I think this does what you are looking for. I used Eval(Substitute()) because it is usually a bit easier to read what it is doing directly from the code. I also separated evaluation from the expression building, so you can print it if you wish to see what it looks like. For Each loops can also be debugged by setting current row to specific value as long as you have correct table as current data table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt1 = Open("$DOWNLOADS/DATAtable1.jmp");
dt2 = Open("$DOWNLOADS/DATAtable2.jmp");
//Row() = 2;
For Each Row(
	dt2, 
	
	process_value = :Process;
	first_offset = :first_OFFSET;
	second_offset = :second_OFFSET;
	third_offset = :third_OFFSET;

	If(
		(Char(first_offset) != "." &amp;amp; Char(first_offset) != "") | (Char(second_offset) != "." &amp;amp;
		Char(second_offset) != "") | (Char(third_offset) != "." &amp;amp; Char(third_offset) != ""), 

		new_column_name = process_value || "_offset";
		col_expr = Substitute(
			Expr(dt1 &amp;lt;&amp;lt; New Column(new_column_name, Numeric, Continuous, Formula(
				If(:Supplier == "FIRST",
					_processval_ + _firstoffset_
				, :Supplier == "SECOND",
					_processval_ + _secondtoffset_
				, :Supplier == "THIRD",
					_processval_ + _thirdoffset_
				, // else
					_processval_
				)
			))),
			Expr(_processval_), Name Expr(AsColumn(dt1, process_value)),
			Expr(_firstoffset_), first_offset,
			Expr(_secondtoffset_), second_offset,
			Expr(_thirdoffset_), third_offset
		);
		//show(col_expr);
		new_col = Eval(col_expr);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1723127657808.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66970i7497D1A027E8B913/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1723127657808.png" alt="jthi_0-1723127657808.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Aug 2024 14:35:21 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-08-08T14:35:21Z</dc:date>
    <item>
      <title>Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780244#M96211</link>
      <description>&lt;P&gt;HI!&lt;/P&gt;
&lt;P&gt;I've made a jsl script which is the following one :&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each Row(
	dt_fichier3, 
// Lire la valeur de la colonne "Process" et les offsets
	process_value = :Process;
	first_offset = :first_OFFSET;
	second_offset = :second_OFFSET;
	third_offset = :third_OFFSET;

// Vérifier et assigner les valeurs des offsets si elles ne sont pas vides ou "."
	If(
		(Char(first_offset) != "." &amp;amp; Char(first_offset) != "") | (Char(second_offset) != "." &amp;amp;
		Char(second_offset) != "") | (Char(third_offset) != "." &amp;amp; Char(third_offset) != ""), 

// Créer une nouvelle colonne dans le fichier1 si elle n'existe pas encore
		new_column_name = process_value || "_offset";
		dt_fichier1 &amp;lt;&amp;lt; New Column(new_column_name, Numeric, Continuous);



// Définir la formule pour la nouvelle colonne
		Column(dt_fichier1, new_column_name) &amp;lt;&amp;lt; Set Formula(
			Eval(
				Eval Expr(
					If(:Supplier == "FIRST",
						:Expr(process_value) + Expr(:first_OFFSET),
						If(:Supplier == "SECOND",
							:Expr(:Process) + Expr(:second_OFFSET),
							If(
								:Supplier == "THIRD",
									:Expr(:Process) + Expr(:third_OFFSET),
								,
									:Expr(:Process) // Valeur par défaut si aucun fournisseur ne correspond
							)
						)
					)
				)
			)
		);
	);

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;Edit (2024-08-08 jthi): Added jsl formatting&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the problem is that the formula doesn't work because the column name appeart in the column info-&amp;gt;Formula as "Column_name" or it should be "Column-name"n, I trid to use Name() function but it did not work :(&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:02:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780244#M96211</guid>
      <dc:creator>PercentileBat71</dc:creator>
      <dc:date>2024-08-08T13:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780254#M96212</link>
      <description>&lt;P&gt;Build the formulas using expression evaluation &lt;LI-MESSAGE title="Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute" uid="48998" url="https://community.jmp.com/t5/JSL-Cookbook-Archived/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/m-p/48998#U48998" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;. This is usually my preferred method (or Eval(Substitute()) and NameExpr(AsColumn())&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

col1 = "height";
col2 = "weight";

new_col = Eval(EvalExpr(dt &amp;lt;&amp;lt; New Column("mycol", Numeric, Continuous, Formula(
	Expr(NameExpr(AsColumn(dt, col1))) * Expr(NameExpr(AsColumn(dt, col2)))
))));

new_col &amp;lt;&amp;lt; get formula;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:05:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780254#M96212</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-08T13:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780255#M96213</link>
      <description>&lt;P&gt;Right,&lt;/P&gt;
&lt;P&gt;But for example after the script compiled, if i take one column to see what its formula looks like I've got this :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(:Supplier == "FIRST",
	"Column_Name" + 4,
	If(:Supplier == "SECOND",
		"Column_Name" + 5,
		If(:Supplier == "THIRD",
			"Column_Name" + (-10),
			"Column_Name"
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which doesn't work because it should be like that to work :&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(:Supplier == "FIRST",
	"Column_Name"n + 4,
	If(:Supplier == "SECOND",
		"Column_Name"n + 5,
		If(:Supplier == "THIRD",
			"Column_Name"n + (-10),
			"Column_Name"n
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How do I modified my script then ? Thank you :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:27:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780255#M96213</guid>
      <dc:creator>PercentileBat71</dc:creator>
      <dc:date>2024-08-08T13:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780258#M96215</link>
      <description>&lt;P&gt;You are missing : from you columns, in your original script you have to modify at least these :Expr(:Process). I would also suggest using column names instead of references such as process_value = :Process (process_value = "Process" is what I prefer to use).&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:28:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780258#M96215</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-08T13:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780260#M96216</link>
      <description>&lt;P&gt;I don't get you,&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use&amp;nbsp;&lt;SPAN&gt;process_value = "Process" then it will become a string and it won't take the column name.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Moreover, what do I nedd to change in these&amp;nbsp;&amp;nbsp;:Expr(:Process)?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:33:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780260#M96216</guid>
      <dc:creator>PercentileBat71</dc:creator>
      <dc:date>2024-08-08T13:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780262#M96218</link>
      <description>&lt;P&gt;I did show one technique to turn those (strings) back to columns inside formulas in my earlier reply.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:35:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780262#M96218</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-08T13:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780263#M96219</link>
      <description>&lt;P&gt;Ah... Using :Process is correct in that location as you are using For Each Row loop. Still same method apply to convert those values you get from the columns back into columns&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:41:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780263#M96219</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-08T13:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780264#M96220</link>
      <description>&lt;P&gt;Could you apply it to my script, I don't get it pls&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:42:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780264#M96220</guid>
      <dc:creator>PercentileBat71</dc:creator>
      <dc:date>2024-08-08T13:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780265#M96221</link>
      <description>&lt;P&gt;If you can provide your data tables I can provide better examples.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 13:44:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780265#M96221</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-08T13:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780272#M96225</link>
      <description>&lt;P&gt;Here is the data&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 14:12:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780272#M96225</guid>
      <dc:creator>PercentileBat71</dc:creator>
      <dc:date>2024-08-08T14:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the correct format of name jsl</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780275#M96227</link>
      <description>&lt;P&gt;I think this does what you are looking for. I used Eval(Substitute()) because it is usually a bit easier to read what it is doing directly from the code. I also separated evaluation from the expression building, so you can print it if you wish to see what it looks like. For Each loops can also be debugged by setting current row to specific value as long as you have correct table as current data table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt1 = Open("$DOWNLOADS/DATAtable1.jmp");
dt2 = Open("$DOWNLOADS/DATAtable2.jmp");
//Row() = 2;
For Each Row(
	dt2, 
	
	process_value = :Process;
	first_offset = :first_OFFSET;
	second_offset = :second_OFFSET;
	third_offset = :third_OFFSET;

	If(
		(Char(first_offset) != "." &amp;amp; Char(first_offset) != "") | (Char(second_offset) != "." &amp;amp;
		Char(second_offset) != "") | (Char(third_offset) != "." &amp;amp; Char(third_offset) != ""), 

		new_column_name = process_value || "_offset";
		col_expr = Substitute(
			Expr(dt1 &amp;lt;&amp;lt; New Column(new_column_name, Numeric, Continuous, Formula(
				If(:Supplier == "FIRST",
					_processval_ + _firstoffset_
				, :Supplier == "SECOND",
					_processval_ + _secondtoffset_
				, :Supplier == "THIRD",
					_processval_ + _thirdoffset_
				, // else
					_processval_
				)
			))),
			Expr(_processval_), Name Expr(AsColumn(dt1, process_value)),
			Expr(_firstoffset_), first_offset,
			Expr(_secondtoffset_), second_offset,
			Expr(_thirdoffset_), third_offset
		);
		//show(col_expr);
		new_col = Eval(col_expr);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1723127657808.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66970i7497D1A027E8B913/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1723127657808.png" alt="jthi_0-1723127657808.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 14:35:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-the-correct-format-of-name-jsl/m-p/780275#M96227</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-08T14:35:21Z</dc:date>
    </item>
  </channel>
</rss>

