cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
hogi
Level XII

Reformat Script - Protect some code?

Reformat Script in JSL Editor is very helpful to get the code with a formatted structure.

 

hogi_0-1698308604175.png

Often it helps to find bugs in the code and to keep the overview.

But sometimes, it's the opposite.
Is there a way to protect code in a specific area from being shuffled by Reformat Script?

hogi_0-1698309509307.png

 

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Recode Column(
	dt:name,
	{Map Value(
		_rcOrig,
		{"ALFRED", "A",
		 "ALICE", "A",
		 "AMY", "A",
		 "BARBARA", "A",
		 "CAROL", "A",
		 "CHRIS", "A",
		 "CLAY", "A",
		 "DANNY", "A",
		 "DAVID", "A",
		 "EDWARD", "A",
		 "ELIZABETH", "B",
		 "FREDERICK", "B",
		 "HENRY", "B",
		 "JACLYN", //missing
		 "JAMES", "B",
		 "JANE", "B",
		 "JEFFREY","B",
		 "JOE","B",
		 "JOHN", "B",
		 "JUDY", "B",
		 "KATIE", "B"
		 },
		Unmatched( _rcNow )
	)},
	Update Properties( 1 ),
	Target Column( :name )
);


 

5 REPLIES 5
jthi
Super User

Re: Reformat Script - Protection some code?

Select only part of your code and then reformat the script

-Jarmo
hogi
Level XII

Re: Reformat Script - Protection some code?

You mean: don't select some code around the protection area such that the remaining code gets consistent, then trigger Reformat Script?
Unfortunately, doesn't seem to work

 

hogi_1-1698310104624.png

 

 

txnelson
Super User

Re: Reformat Script - Protection some code?

Jarmo's suggestion works well, however one has to reformat syntactically valid JSL

txnelson_0-1698311199471.png

results in reformatting only the selected parts of the code

txnelson_1-1698311294967.png

 

Jim
hogi
Level XII

Re: Reformat Script - Protection some code?

Hm, syntactically valid JSL code - reformat works if I delete the code in the (non-selected) protection area.
So, the remainder seems to be OK.

 

I think the actual problem is:

The two pieces of code - above and below the protection area have to be - separately -  syntactically valid JSL code.

 

i.e. the protection area has to be on highest level - e.g. a whole function.

 

another example:

hogi_0-1698311869341.png

 

txnelson
Super User

Re: Reformat Script - Protection some code?

Good catch.

 

There is a work around.  The 

     Advanced=>Comment Block

does not change the structure of the code, it simply comments out a highlighted section of code.  If you Comment Block, then Reformat the JSL and then highlight and 

     Advanced=?Uncomment Block

you will achieve your goal

 

Jim

Recommended Articles