Hi shehzaad.kaka,
I was able to get this to work by building an expression with eval, parse, and eval insert. Since you said you are new to JSL I imagine this will look pretty cryptic, so let me step though two important pieces of this.
The first thing I did was moved setting the formula to it's own part, separate from creating the column. This is so we can focus on building an expression for just setting the column formula. The bulk of this is what Eval(Parse(EvalInsert( ))); is doing. EvalInsert is a neat tool to take a string and substitute in variables or functions of variables. The way to designate that you want a substitution is by wrapping ^ ^ around the function or variable. For instance:
g = "World";
h = EvalInsert("Hello ^g^ ");
Caption(h);
h in this case would be equal to "hello world", which is what will be displayed in a caption box with the code above.
In your situation, I used evalInsert for the column names:
:Name("^"AA_"||bc^")
If we pull this apart it will be more clear
:Name(" ^ "AA_" || bc ^ ")
The :Name() function requires quoted text, so there are quotes at the start and end by the parentheses. Next, we have the ^ ^ wrapped around your concatenation. Evalinsert processes that and the :Name() function is left with a quoted string of AA_140. EvalInsert will substitute everywhere something is wrapped in ^ ^. There is one special complication which is that our expression we are building needs to have quotes in it, but we have to use quotes to designate the string itself. To handle this, we can tell JMP each quotation mark is actually meant to be the quote character (rather than a part of JMP syntax) by prepending each quote with \! (slash-bang) or do as I have done below and put \[ after the starting quote, and ]\ before the final quote. This "escapes" all the quotes in the expression we are building.
Next, Parse() converts the character string into a JSL expression, and finally Eval() runs the JSL expression, assigning the formula to the column.
I hope this helps!
Julian
ps: your code didn't have the underscores for the column names so I added those.
dt2 = current data table();
b = 140;
bc = char(b);
print(b);
print(bc);
dt2 << New Column("range"||bc||"v1",
Numeric,
Formula(b)
);
// dt2 = current data table();
dt2 << New Column("Range",
Numeric,
);
eval(parse(EvalInsert(
"\[
:Range << Set Formula( Maximum(:Name("^"AA_"||bc^"), :Name("^"BB_"||bc^"), :Name("^"CC_"||bc)^") - Minimum(:Name("^"AA_"||bc^"), :Name("^"BB_"||bc^"), :Name("^"CC_"||bc^"))
)
]\")));