cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
BooBee
Level III

Practicing on JSL for a newbie - Unexpected "{". Perhaps there is a missing ";" or ",".

Hi,

 

I'm practising on JSL to select a .jmp file to open through a file dialog window. If the user did not make a selection, to exit.

However, I'm getting the below error:

 

Unexpected "{". Perhaps there is a missing ";" or ",".

Line 7 Column 21: if (Is Missing(fn)) ►{

The remaining text that was ignored was

{exit();}Open(fn);

 

My script below:

// Open a dialog to choose a .jmp file to open

// Get the filename of the .jmp file to open
fn = Pick File("Select a .jmp file to open", "", {"JMP Files|jmp;jsl;jrn", "All Files|*"}, 1, 1, "Default Filename.jmp");

// If the user did not select a file, exit the script
if (Is Missing(fn)) {
    exit();
}

// Open the selected file
Open(fn);

Appreciate if any one can point out what I'm missing here.

 

Thank you.

2 REPLIES 2
jthi
Super User

Re: Practicing on JSL for a newbie - Unexpected "{". Perhaps there is a missing ";" or ",".

You are using incorrect syntax ( use ( instead of } and ) instead of }, also end your expressions with ;).

 

You should go through Scripting Guide (jmp.com) while learning JSL. There are also courses regarding JSL, like here Introduction to the JMP Scripting Language Course , there is also material provided by JSL Scripters Club users group JMP Scripters Club - JMP User Community.

-Jarmo
txnelson
Super User

Re: Practicing on JSL for a newbie - Unexpected "{". Perhaps there is a missing ";" or ",".

I suggest that you take the time to read the Scripting Guide.  You will find it an efficient way to learn the structures and syntax of JSL.

Concerning your code:

Your If() statement syntax is incorrect.  The form of an If() statement is:

If( condition1, result1, <condition2, result2>,...,<elseResult>)

The error statement you received points to Line 7, Colum 21, the "{";  Your If() function has a condition but no result.

If (Is Missing(fn))

It has a condition, but the second ")" closes out the statement.  JMP then incounters the "{" and doesn't know what to do with it.  I believe what you really want is:

If( Is Missing( fn ),
	Exit(), 
	// Else Open the selected file
	Open( fn )
);

I may also suggest that you may want to think long and hard about using

Exit()

it terminates JMP.

You may want to just stop the execution of the script, but leave the user with the JMP  session remaining open.  To do this, use the 

Throw()

function.

Jim