cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • See how to interactively organize and restructure data for analysis. Register for May 29 webinar, 2pm US ET.

Discussions

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

unable to pass string to function

Hi,

I am trying to pass to string to function, but its no working.

could someone advise what I do wrong?

 

 

// function
C_SC_PC_func2 = Function( 
    {SheetName, selSRM}, 
    {}, 
);

//call function
C_SC_PC_func2( "string1", "string2" );

 

 

 

2 REPLIES 2
txnelson
Super User

Re: unable to pass string to function

I am not seeing an issue. Below is your code, with a Show() function, that gives results that indicates the string variables are passed in.

// function
C_SC_PC_func2 = Function( {SheetName, selSRM},
	{};
	Show( sheetname, selsrm );
);

//call function
C_SC_PC_func2( "string1", "string2" );
sheetname = "string1";
selsrm = "string2";
Jim
Craige_Hales
Super User

Re: unable to pass string to function

@AdirZig  - you want the comma, not the semicolon, to make a list of local variables in the function. (Your list was empty, and I often start my function definitions with an empty list too.)

// function
C_SC_PC_func2 = Function( {SheetName, selSRM},
	{i,j}, // use comma
	i=3;
	j=4;
	Show( sheetname, selsrm );
);

//call function
i = j = 0;
C_SC_PC_func2( "string1", "string2" );
show(i,j);

JMP looks at the function function to see if it has three arguments. If it does, and the second argument is a list, it is a list of local variables. If you use a semicolon (making two arguments to function), it becomes a statement in the function body that is evaluated and thrown away.

Craige

Recommended Articles