cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
hogi
Level XII

Parse in substitute

In Substitute, if I don't have a fixed number of symbols, is it possible to use a for loop and parse to generate the symbol names?

Something is wrong here:

 

myExpr=Expr(sum());
For( i=1, i<=10, i++, Insert Into (myExpr,parse("__x"||Char(i)||"__")));
Show(NameExpr(myExpr));
For( i=1, i<=10, i++, substitute (Name Expr(myExpr),parse("__x"||Char(i)||"__"),parse("y"||Char(i))));
Show(NameExpr(myExpr));
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Parse in substitute

You aren't updating the value of myExpr

Names Default To Here(1);

myExpr = Expr(Sum());
For(i = 1, i <= 10, i++,
	Insert Into(myExpr, Parse("__x" || Char(i) || "__"))
);
Show(Name Expr(myExpr));
For(i = 1, i <= 10, i++,
	myExpr = Substitute(Name Expr(myExpr), Parse("__x" || Char(i) || "__"), Parse("y" || Char(i)))
);
Show(Name Expr(myExpr));
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Parse in substitute

You aren't updating the value of myExpr

Names Default To Here(1);

myExpr = Expr(Sum());
For(i = 1, i <= 10, i++,
	Insert Into(myExpr, Parse("__x" || Char(i) || "__"))
);
Show(Name Expr(myExpr));
For(i = 1, i <= 10, i++,
	myExpr = Substitute(Name Expr(myExpr), Parse("__x" || Char(i) || "__"), Parse("y" || Char(i)))
);
Show(Name Expr(myExpr));
-Jarmo
hogi
Level XII

Re: Parse in substitute

oh, so close!