cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar

"Name Unresolved" error with use of custom function

Hello,

 

I'm attempting to define and use a custom function within a JMP script . Will that run ok? As of now when it gets to the line to call the function (JSload) I get the following error in the log.

 

Name Unresolved: JSload in access or evaluation of 'JSload' , JSload( temp ) /*###*/

 

I am passing the function a character string "temp" (a file name with proper path for an xlsx file) and attempting to use the Open command to import that file's contents into a data table. I think though that it is getting caught on the initial call to the function. Here is the script and function function as of now. The variable "temp" appears to be made correctly (checked in the log file).

 

The code for the Open command comes from a "save script" after an initial data import done manually.

 

 

Thanks,

Joe

================================================

 

For( index1 = 1,index1 <= 1, index1++,

  temp = (filepath||filelist[index1]);

  JSload(temp);

);

 

JSload = Function({temp},

Open(

  temp,

  Worksheets( "Sheet1" ),

  Use for all sheets( 1 ),

  Concatenate Worksheets( 0 ),

  Create Concatenation Column( 0 ),

  Worksheet Settings(

  1,

  Has Column Headers( 1 ),

  Number of Rows in Headers( 1 ),

  Headers Start on Row( 1 ),

  Data Starts on Row( 2 ),

  Data Starts on Column( 1 ),

  Data Ends on Row( 0 ),

  Data Ends on Column( 0 ),

  Replicated Spanned Rows( 1 ),

  Suppress Hidden Rows( 1 ),

  Suppress Hidden Columns( 1 ),

  Suppress Empty Columns( 1 ),

  Treat as Hierarchy( 0 )

  );

);

1 ACCEPTED SOLUTION

Accepted Solutions
Eric_Hill
Staff

Re: Name Unresolved error with custom function

Hey, Joe,

Actually, I think reusing the variable "temp" is not the problem, because JMP is saying that "JSload" is what it can't find.  I think the problem is that your function is defined *after* you call it.  In JMP, your function needs to be defined before you call it.  Move the "JSload = function({temp},...)" section to before the for loop and I suspect it will work.

Also, it appears you are missing a closing paren and semicolon at the end of the function definition.

This version works for me:

 

filepath = "c:\users\public\temp\";

fileList = {"myTest.xlsx"};

JSload = Function({temp},

  Open(

    temp,

    Worksheets( "Sheet1" ),

    Use for all sheets( 1 ),

    Concatenate Worksheets( 0 ),

    Create Concatenation Column( 0 ),

    Worksheet Settings(

      1,

      Has Column Headers( 1 ),

      Number of Rows in Headers( 1 ),

      Headers Start on Row( 1 ),

      Data Starts on Row( 2 ),

      Data Starts on Column( 1 ),

      Data Ends on Row( 0 ),

      Data Ends on Column( 0 ),

      Replicated Spanned Rows( 1 ),

      Suppress Hidden Rows( 1 ),

      Suppress Hidden Columns( 1 ),

      Suppress Empty Columns( 1 ),

      Treat as Hierarchy( 0 )

    );

  );

);

For( index1 = 1,index1 <= 1, index1++,

  temp = (filepath||filelist[index1]);

  JSload(temp);

);

HTH,

Eric

View solution in original post

3 REPLIES 3
jerry_cooper
Staff (Retired)

Re: Name Unresolved error with custom function

Hi Joe,

The issue is that you are using the “temp” variable name for your filepath and for the argument in your function definition. If you replace the two instances of “temp” in your function statement with a different, unused variable name, your script should work.

-Jerry

Eric_Hill
Staff

Re: Name Unresolved error with custom function

Hey, Joe,

Actually, I think reusing the variable "temp" is not the problem, because JMP is saying that "JSload" is what it can't find.  I think the problem is that your function is defined *after* you call it.  In JMP, your function needs to be defined before you call it.  Move the "JSload = function({temp},...)" section to before the for loop and I suspect it will work.

Also, it appears you are missing a closing paren and semicolon at the end of the function definition.

This version works for me:

 

filepath = "c:\users\public\temp\";

fileList = {"myTest.xlsx"};

JSload = Function({temp},

  Open(

    temp,

    Worksheets( "Sheet1" ),

    Use for all sheets( 1 ),

    Concatenate Worksheets( 0 ),

    Create Concatenation Column( 0 ),

    Worksheet Settings(

      1,

      Has Column Headers( 1 ),

      Number of Rows in Headers( 1 ),

      Headers Start on Row( 1 ),

      Data Starts on Row( 2 ),

      Data Starts on Column( 1 ),

      Data Ends on Row( 0 ),

      Data Ends on Column( 0 ),

      Replicated Spanned Rows( 1 ),

      Suppress Hidden Rows( 1 ),

      Suppress Hidden Columns( 1 ),

      Suppress Empty Columns( 1 ),

      Treat as Hierarchy( 0 )

    );

  );

);

For( index1 = 1,index1 <= 1, index1++,

  temp = (filepath||filelist[index1]);

  JSload(temp);

);

HTH,

Eric

Re: Name Unresolved error with custom function

Thanks Eric. That was the trick!

Joe