cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Theresa
Level IV

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
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

ian_jmp
Level X

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

9 REPLIES 9
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
ian_jmp
Level X

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.

Theresa
Level IV

Re: How to folding the code?

thanks all for your kindly help
Theresa
Level IV

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.




Theresa
Level IV

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
				)
			)
		);
	);
);
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

 

 

 

rc_hertzy
Level III

How to stop code folding

In Script Editor preferences, code folding in unchecked. Yet every script I open is folded in the middle so bottom half of the editor window is blank. I want to see the entire window of code. If I drag the fold to the bottom, save, reopen, the fold is there again.

How can I turn off code folding? JMP Pro 15.2, Mac. 

Re: How to stop code folding

Is this really a folding issue? It sounds to me like you might have the embedded log turned on. Could you share a screen capture to confirm? If it is the embedded log, right-click in the scripting window and uncheck the Show Embedded Log option.

Dan Obermiller
rc_hertzy
Level III

Re: How to stop code folding

Thank you Dan!  That was it, as the attached screen clip shows.  I hope someone adds that tip to the help on code folding- how to turn it off.  -Rick