Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- How to loop using a function

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Sep 21, 2018 5:37 AM
(4835 views)

The difference between Function() and Expr(). After msharp answered my question yesterday, i realized that i have been doing this all wrong. Currently every output whether it is a Graph Plot or Distribution had its own individual Expr() with 3 different iterations inside of it. In a nutshell, that is ~ 20 Expr() scripts. The ability to use a Function would cut that down to one graph plot script and one distribution script. What i am having difficulty doing is now looping through the function.

I have attached the sample data table, a sample of just one of the expressions i use to graph plot and the start of a function script. I would apprecaite any help in solving this problem. I can use the solution to this problem and apply to many others. You can run the original script to understand what i am trying to do..

Thank you

P.S if you have the time i am trying to combine the 3 journals into a single journal. I am trying to back into a script that posted on this thread

https://community.jmp.com/t5/Discussions/Combine-multiple-journals-into-one-journal/td-p/6129

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

First off, if you are going to pursue JSL coding, you need to thourthly read the Scripting Guide

Help==>Books==>Scripting Guide

Below is a reworking of your script to illustrate how to loop using a function and how to keep all of the output in the same output journal. I know it is not exactly what you need, but it should give you a good start on how to do what you want

```
Names Default To Here( 1 );
dt = Current Data Table();
doGraphPlot = Function(
{dt, Xaxis, Yaxis, Grby, chnl},
Eval(
Substitute(
Expr(
gb = dt << Graph Builder(
invisible,
where( dt:Channel == __chnl__ ),
size( 600, 400 ),
show control panel( 0 ),
variables(
Y( Eval( Yaxis ) ),
X( Eval( Xaxis ) ),
Group X( Eval( Xgrby ) ),
Overlay( :RowCol )
),
elements( smoother( X, Y, legend( 19 ), lambda( 0.0001 ) ) )
)
),
Expr( __chnl__ ), chnl
)
);
Report( gb )[Outline Box( 1 )] << set title( "Channel = " || Char( chnl ) );
);
jjrn = New Window( "Data Plot - Output_1 vs Input", <<Journal );
dtsum = dt << Summary( Group( :Channel ), invisible ); //
Yaxis = Expr(
Column( dt, "Output_1" )
);
Xaxis = Expr( Column( dt, "Input" ) );
Xgrby = Expr(
Column( dt, "wafer_number" )
);
For( i = 1, i <= N Row( dtsum ), i++,
chnl = dtsum:Channel[i];
doGraphPlot( dt, Yaxis, Xaxis, Xgrby, chnl );
jjrn << append( Report( gb ) );
gb << close window;
);
Yaxis = Expr(
Column( dt, "Output_3" )
);
Xaxis = Expr( Column( dt, "Input" ) );
Xgrby = Expr(
Column( dt, "wafer_number" )
);
For( i = 1, i <= N Row( dtsum ), i++,
chnl = dtsum:Channel[i];
doGraphPlot( dt, Yaxis, Xaxis, Xgrby, chnl );
jjrn << append( Report( gb ) );
gb << close window;
);
Close( dtsum, nosave );
```

Jim

2 REPLIES 2

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

First off, if you are going to pursue JSL coding, you need to thourthly read the Scripting Guide

Help==>Books==>Scripting Guide

Below is a reworking of your script to illustrate how to loop using a function and how to keep all of the output in the same output journal. I know it is not exactly what you need, but it should give you a good start on how to do what you want

```
Names Default To Here( 1 );
dt = Current Data Table();
doGraphPlot = Function(
{dt, Xaxis, Yaxis, Grby, chnl},
Eval(
Substitute(
Expr(
gb = dt << Graph Builder(
invisible,
where( dt:Channel == __chnl__ ),
size( 600, 400 ),
show control panel( 0 ),
variables(
Y( Eval( Yaxis ) ),
X( Eval( Xaxis ) ),
Group X( Eval( Xgrby ) ),
Overlay( :RowCol )
),
elements( smoother( X, Y, legend( 19 ), lambda( 0.0001 ) ) )
)
),
Expr( __chnl__ ), chnl
)
);
Report( gb )[Outline Box( 1 )] << set title( "Channel = " || Char( chnl ) );
);
jjrn = New Window( "Data Plot - Output_1 vs Input", <<Journal );
dtsum = dt << Summary( Group( :Channel ), invisible ); //
Yaxis = Expr(
Column( dt, "Output_1" )
);
Xaxis = Expr( Column( dt, "Input" ) );
Xgrby = Expr(
Column( dt, "wafer_number" )
);
For( i = 1, i <= N Row( dtsum ), i++,
chnl = dtsum:Channel[i];
doGraphPlot( dt, Yaxis, Xaxis, Xgrby, chnl );
jjrn << append( Report( gb ) );
gb << close window;
);
Yaxis = Expr(
Column( dt, "Output_3" )
);
Xaxis = Expr( Column( dt, "Input" ) );
Xgrby = Expr(
Column( dt, "wafer_number" )
);
For( i = 1, i <= N Row( dtsum ), i++,
chnl = dtsum:Channel[i];
doGraphPlot( dt, Yaxis, Xaxis, Xgrby, chnl );
jjrn << append( Report( gb ) );
gb << close window;
);
Close( dtsum, nosave );
```

Jim

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to loop using a function

Thank you Mr. Nelson,

I really appreciate the help you and the community provides. I must tell you that coding in general is very new and hard for me. You are talking to a person who got a 'C' in C++ and ran with it. For every hour that i spend coding, I spend 3 hours reading the Scripting Guide, using the Scripting Index and of course reading through the forums. Due to my ignorance with coding in general and then trying to translate that into JSL, I spend a significant amount of time on my own time learning. I am usual spending my time reading code that was posted here and try to back into with what i am trying to do. I am signing up for the webinars to learn more and espically get a handle on JMP 14 when it rolls out in the very near future. I apologize if i am asking too many questions and seeking help more than any other individuals.

With that said, thanks again for your help.

Article Labels

There are no labels assigned to this post.