cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
robot
Level VI

Insert contents of Parse expression rather than variable name into New Script

I am looking to extend @Craige_Hales excellent answer from Insert contents of variable/expression rather than variable name into New Script by combining script, but have not worked out the syntax.  Any ideas to get this to work?

 

I am using JMP 18.1.2

 

Names Default To Here( 1 );

dt = New Table( "My Table" );

e1 = Expr(
	Print( "Run some code." )
);

e2 = Expr(
	Print( "Run some other code." )
);

e3 = Expr(
	Parse( Eval Insert( "\[
	^e1^;
	^e2^;
]\" ) )
);

// These work.
Eval( Eval Expr( dt << New Script( "Test 1", Expr( Name Expr( e1 ) ) ) ) );
Eval( Eval Expr( dt << New Script( "Test 2", Expr( Name Expr( e2 ) ) ) ) );

// This does not work.
Eval( Eval Expr( dt << New Script( "Test 3", Expr( Name Expr( e3 ) ) ) ) );
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Insert contents of Parse expression rather than variable name into New Script

Print your e3 to see what it contains

 

Name Expr(e3) = Parse(Eval Insert("
	^e1^;
	^e2^;
"));

This possibly does what you are looking for

 

Names Default To Here(1);

dt = New Table("My Table");

e1 = Expr(Print("Run some code."));

e2 = Expr(
	Print("Run some other code.")
);

e3 = Parse(Eval Insert("\[
	^Name Expr(e1)^;
	^Name Expr(e2)^;
]\"));

Eval(Eval Expr(dt << New Script("Test 3", Expr(Name Expr(e3)))));

I would generally avoid using Parse as it is a nightmare to debug

 

 

Names Default To Here(1);

dt = New Table("My Table");

e1 = Expr(Print("Run some code."));

e2 = Expr(
	Print("Run some other code.")
);

e3 = EvalExpr(
	Expr(Name Expr(e1));
	Expr(Name Expr(e2));
);

Eval(Eval Expr(dt << New Script("Test 3", Expr(Name Expr(e3)))));

 

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Insert contents of Parse expression rather than variable name into New Script

Print your e3 to see what it contains

 

Name Expr(e3) = Parse(Eval Insert("
	^e1^;
	^e2^;
"));

This possibly does what you are looking for

 

Names Default To Here(1);

dt = New Table("My Table");

e1 = Expr(Print("Run some code."));

e2 = Expr(
	Print("Run some other code.")
);

e3 = Parse(Eval Insert("\[
	^Name Expr(e1)^;
	^Name Expr(e2)^;
]\"));

Eval(Eval Expr(dt << New Script("Test 3", Expr(Name Expr(e3)))));

I would generally avoid using Parse as it is a nightmare to debug

 

 

Names Default To Here(1);

dt = New Table("My Table");

e1 = Expr(Print("Run some code."));

e2 = Expr(
	Print("Run some other code.")
);

e3 = EvalExpr(
	Expr(Name Expr(e1));
	Expr(Name Expr(e2));
);

Eval(Eval Expr(dt << New Script("Test 3", Expr(Name Expr(e3)))));

 

 

-Jarmo
robot
Level VI

Re: Insert contents of Parse expression rather than variable name into New Script

Excellent!

Recommended Articles