BookmarkSubscribeSubscribe to RSS Feed

How to search in column headers?


Community Trekker


Jul 9, 2011


I am new in JSL scripting and I want to know how to search in column headers.

Basically, I used data table prepared by other person that I need to analyze. Before I start analysis, I change the column headers through script.

However, sometimes the data table does not have the specific header I am chaging and the JSL script will abort.

Here my a part of my code:

col=Column("%L(i)_MRR"); col<<Set Name("irawLossMRR");

col=Column("%L(i)_QSNR - Production_Avg."); col<<Set Name("irawLossQSNR");

My probelm: If there is no "%L(i)_MRR" column header, the script will abort and will not execute the next command.

Requirement: How to show pop-up screen to show a message: "No %L(i)_MRR column" and proceed with the next command.

- marknight -


Super User


Jun 23, 2011

You would use something like the following:

dt = open("$sample_data\Big");

col_names = dt << Get Column Names(String);

if (!contains(col_names, "first name"),

      dlg = dialog("Column not found",

            "Warning column [first name] not found",




Note that the contains function is case sensitive.




Community Trekker


Jul 5, 2011

It sounds like he wants to display the error message, but continue with the remainder of the column rename functions.  You could do this with a modal dialog (requires you to click "OK" before the script will proceed) or a caption window (does not stop script or require a response), depending on your preference.  In the below examples, "old_name" refers to the column name you want to locate and replace and "new_name" refers to the name you want to replace it with.

col_names = dt << get column names(string);

if ( !contains( col_names, "old_name" ),

      dlg = dialog( "No old_name column",

          button( "Cancel" ), button( "OK" ) ),

             If( dlg["Button"] == -1, Throw() ),

       Column( "old_name" ) << Set Name( "new_name" )


To use the non-modal caption command:

col_names = dt << get column names(string);

if ( !contains( col_names, "old_name" ),

        Caption( {x,y}, "No old_name column" );

        Wait( 2 );

        Caption( remove ),

    Column( "old_name" ) << Set Name( "new_name" )


x and y in the caption refer to display coordinates, so if your display resolution is 1024 x 768, using {500,350} will give you a caption window that is roughly in the middle of your screen.  You can also alter the time of the 'wait' command if the message is displaying too long (or not long enough).

You'll need to repeat the conditional for each column, replacing "old_name" and "new_name" each time.