Subscribe Bookmark RSS Feed

Sectioning or Segmenting Code in JSL

LEDmaker

New Contributor

Joined:

Jun 19, 2017

I would like to execute my code in segments. Reasons include:

 

(1) I would like to interact with the plots or data tables in the middle of the script

(2) I would like to execute only part of my code, e.g. the segment for plotting while skipping the rest.

 

This can be done by using stop functions and/or by highlighting code that I want to run, but this becomes unwieldy and annoying as my program grows.

 

I'd like to know if there is a function like in Matlab that allows me to section the code and then run by section?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Another method that can be used is to segment your code in Expr() sections.  The code would look something like

a=Expr(
     section a code
    );
b=Expr(
     section b code
    );
c=Expr(
     section c code
     );
// To run the code from the b expr 
b;
Jim
5 REPLIES
markbailey

Staff

Joined:

Jun 23, 2011

Are you asking about subroutines? See Help > Books > Scripting Guide and read about expressions and user functions.

JMP does not work in two different, separate modes. Interactive behavior is still available when a script is running.

You can also associate subroutines with objects in the user interface. This way, your script can present initial results but provide additional computation as needed.

Learn it once, use it forever!
ian_jmp

Staff

Joined:

Jun 23, 2011

To make things more manageable in the editor, you could use code folding, maybe with user-defined keywords. Also, you could split your code over multiple files and use 'Include()', though this may not help readability. And of course, defining your own JSL functions helps to tame code and also makes it more maintainable.

txnelson

Super User

Joined:

Jun 22, 2012

Solution

Another method that can be used is to segment your code in Expr() sections.  The code would look something like

a=Expr(
     section a code
    );
b=Expr(
     section b code
    );
c=Expr(
     section c code
     );
// To run the code from the b expr 
b;
Jim
LEDmaker

New Contributor

Joined:

Jun 19, 2017

Thanks very much! The combination of code folding and using expressions has helped me both manage the code appearance and execute specific blocks of code much more easily.

Craige_Hales

Staff

Joined:

Mar 21, 2013

I frequently select the block of text I want to run and use the "Enter" key on the numeric keypad to run the selection. (Not the return key!)

Craige