cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
kaushik
Level I

If & Go to statement

I want to write a script such that if a particular condition is true move ahead and if false then move back to a particular label in the script. how to do that. please help.

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: If & Go to statement

JSL does not have a GOTO statement.  You can do what you want with a WHILE loop, CONTINUE and BREAK.

An example of what you want to do would be helpful.

View solution in original post

7 REPLIES 7
sunilzood
Level I

Re: If & Go to statement

Hi, Please share an example or sample data.

pmroz
Super User

Re: If & Go to statement

JSL does not have a GOTO statement.  You can do what you want with a WHILE loop, CONTINUE and BREAK.

An example of what you want to do would be helpful.

robust1972
Level IV

Re: If & Go to statement

does it mean the jmp script has to be ran from beginning to end? Not like other language can skip few blocks/lines or go back to certain places prior to if clause?

Jeff_Perkinson
Community Manager Community Manager

Re: If & Go to statement

As @pmroz points out there are many Conditional functions that can be used to control the flow of execution of a program.

 

 

If you can post an example of the problem you're trying to solve with GOTO perhaps we can show you how to tackle it.

-Jeff
kaushik
Level I

Re: If & Go to statement

This is what i did and it works

 

a = 0;
tableExpr = Expr(  ) ;
If( a >= 1, //Condition
      Print( "Condition is true." )  //Then
,
      tableExpr  //Else
);

If condition is true then proceed else it will execute set of expressions defined earlier in the script.

ram
ram
Level IV

Re: If & Go to statement

I guess you dont want to wrap entire jsl code in if or while condition. instead whenever exception occurs it should skip a block. well, since no goto exist in jsl, if you work through function here is a work around. use a dummy for loop and conditional break inside a function. 

 

for(i=1,i<=1,i++,
  bar=12;
  break();
  bar=15;
);
show(bar);
David_Burnham
Super User (Alumni)

Re: If & Go to statement

goto.PNG

source: xkcd.com

-Dave

Recommended Articles