Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Theresa
Level III

How to folding the code?

 

I follow the guideline fold the code, but after click it still not fold, don't know why.

 

How to operate through JMP or how to use script to fold the content we want?

 

 

//fold below arguments as one group
dt1 << Delete Rows( 10 ); //deletes row 10
dt1 << Delete Rows( {11, 12, 13} ); //deletes rows 11-13
dt1 << Delete Rows( 8 :: 25 ); //deletes first 20 rows
dt1 << Delete Rows( [1 2 3] );
dt1 << Delete Columns( 3 );
dt1 << Delete Columns( {3, 4} ); //deletes 3,4 columns

//fold below arguments as one group

dt = New Table( "test",
	addrows( 3 ),
	New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
	New Column( "SPCval", numeric, values( {} ) ),
	New Column( "EPval", numeric, values( {1, 2, .} ) ),
	New Column( "lotcomment", character, values( {} ) ), 
);

 

Theresa_0-1583221300564.png

 

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
txnelson
Super User

Re: How to folding the code?

Code folding recognizes Expressions and Functions.  See below

//fold below arguments as one group
zippy = Expr(
	dt1 << Delete Rows( 10 ); //deletes row 10
	dt1 << Delete Rows( {11, 12, 13} ); //deletes rows 11-13
	dt1 << Delete Rows( 8 :: 25 ); //deletes first 20 rows
	dt1 << Delete Rows( [1 2 3] );
	dt1 << Delete Columns( 3 );
	dt1 << Delete Columns( {3, 4} ); //deletes 3,4 columns
	//fold below arguments as one group
	dt = New Table( "test",
		addrows( 3 ),
		New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
		New Column( "SPCval", numeric, values( {} ) ),
		New Column( "EPval", numeric, values( {1, 2, .} ) ),
		New Column( "lotcomment", character, values( {} ) ),

	);
);

 fold.PNG

Jim

View solution in original post

Highlighted
ian_jmp
Staff

Re: How to folding the code?

Adding a little to the reply from @txnelson, you can also add your own folding markers. The JMP Help is always a good resource.

View solution in original post

6 REPLIES 6
Highlighted
txnelson
Super User

Re: How to folding the code?

Code folding recognizes Expressions and Functions.  See below

//fold below arguments as one group
zippy = Expr(
	dt1 << Delete Rows( 10 ); //deletes row 10
	dt1 << Delete Rows( {11, 12, 13} ); //deletes rows 11-13
	dt1 << Delete Rows( 8 :: 25 ); //deletes first 20 rows
	dt1 << Delete Rows( [1 2 3] );
	dt1 << Delete Columns( 3 );
	dt1 << Delete Columns( {3, 4} ); //deletes 3,4 columns
	//fold below arguments as one group
	dt = New Table( "test",
		addrows( 3 ),
		New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
		New Column( "SPCval", numeric, values( {} ) ),
		New Column( "EPval", numeric, values( {1, 2, .} ) ),
		New Column( "lotcomment", character, values( {} ) ),

	);
);

 fold.PNG

Jim

View solution in original post

Highlighted
ian_jmp
Staff

Re: How to folding the code?

Adding a little to the reply from @txnelson, you can also add your own folding markers. The JMP Help is always a good resource.

View solution in original post

Highlighted
Theresa
Level III

Re: How to folding the code?

thanks all for your kindly help
Highlighted
Theresa
Level III

Re: How to folding the code?

One more question, if i have a long script, which need zip 20+ groups, is there a simple way to zip 20* group at one time?

Is this can realize by "Folding Keywords"? I am not so understand "Folding Keywords" mean.




Highlighted
Theresa
Level III

Re: How to folding the code?

 

I see this script  has no Expr() expression, but  fold the needed content together.

Do you know how to group all the needed group by one time? Is "O-dtManu" is the  "Folding Keywords". ?

 

Can you show a example of how to realize below fold job?

Theresa_0-1583282141666.png

 

****You can use below 3 group as a example show to me. Thank you very much.

Names Default To Here( 1 );
Print( "load Func_DT.jsl-------------------" );
New Namespace(
	"O_dtManu"
);
//close files with similar names
O_dtManu:closefile = Function( {fn},
	{Default local},
	Try( Close( Data Table( fn ), nosave ) );
	For( i = 2, i < 30, i++,
		Try( Close( Data Table( fn || " " || Char( i ) ), nosave ), Break() )
	);
);
O_dtManu:closefilelist = Function( {fnlist},
	{Default local},
	ncnt = N Items( fnlist );
	For( i = 1, i <= ncnt, i++,
		fn = fnlist[i];
		Try( Close( Data Table( fn ), nosave ), Try( fn << close window ) );
		For( j = 2, j < 30, j++,
			Try( Close( Data Table( fn || " " || Char( j ) ), nosave ), Break() )
		);
	);
);
//fill missing cell with 0
O_dtManu:fill_miss_0 = Function( {dt, start_col, fillin = 0},
	{Default Local},
	ncnt = N Cols( dt );
	For( k = start_col, k <= ncnt, k++,
		dt_col_type = Column( dt, k ) << get data type();
		If( dt_col_type == "Numeric",
			For( j = 1, j <= N Rows( dt ), j++,
				If( Is Missing( Column( dt, k )[j] ),
					Column( dt, k )[j] = fillin
				)
			)
		);
	);
);
Highlighted
stan_koprowski
Community Manager Community Manager

Re: How to folding the code?

Hi @Theresa,

As both @txnelson and @ian_jmp stated previously JMP will use informative or "keywords" to fold the code at or on your preferred location within the script in addition to the defaults of Expr and Function. 

 

For example, if you would like to fold your code on words, such as, "If", "For", "For Each Row", "While", "Try", "New Window", "V List Box", "H List Box" or even "O_dtManu" then place the words in a JSL list { } and save as jmpKeywords.jsl.

The jmpKeywords.jsl file will need to be saved to a particular directory depending on your OS in order for JMP to apply the code folding to your preferred folding words.

 

custom code folding keywordscustom code folding keywords

 

result after applying custom code folding keywordsresult after applying custom code folding keywords

The next time you start JMP and launch your script the new locations for the code folding should be applied.

cheers,

Stan

 

 

 

Article Labels

    There are no labels assigned to this post.