JSL question - returning a character string into a new column based on values within another columnI almost have this; but can't seem to get it generated in a JSL script. The formula editor is doing almost exactly what I want... but when attempting to do it in a script... I can't seem to get it to work.
Desired result is in column 2; I apply the formula shown in the column editor to get the desired result.

//This is what I input into formula editor and it works fine;
item_lst = Words( Substitute( :Input, "/", "/;" ), ";" );
result_str = "";
For( i = 1, i <= N Items( item_lst ), i++,
If( item_lst[i] == "/",
result_str = result_str || "N",
result_str = result_str || "Y"
)
);
result_str;
When I try to create a new column within a JSL script and the I get the result in column 3. I seem to be nesting incorrectly and I can't seem to find this...
Here is the jsl code. Any help would be much appreciated.
da = Current Data Table();
da <<NEW column=""></NEW>
Automation and ScriptingRe: JSL question - returning a character string into a new column based on values within another columnHi Jim... I could swear I did that before... the number of times I checked my semicolons, commas and parentheses...
that said... I thank you... it works perfectly now...
not sure how I spent so much time on this. Too late.
Re: JSL question - returning a character string into a new column based on values within another columnYour issue was that you had ")" in a couple of incorrect places. Here is your code with my modifications
da = Current Data Table();
da << New Column( "Keystring", Character );
:Keystring << Set Formula(
item_lst = Words( Substitute( :Input, "/", "/;" ), ";" );
result_str = "";
For( i = 1, i <= N Items( item_lst ), i++,
If( item_lst[i] == "/",
result_str = result_str || "N",
result_str = result_str || "Y"
)
);
result_str;
);