Subscribe Bookmark RSS Feed

User Entered Values to Column values using JSL

adel922

New Contributor

Joined:

May 14, 2017

I am new to JSL Scripting.

I am trying to populate a column using entries from a panel box.

In part of my code below, I am trying to get the value entered ,34, to populate a column named Price Code. However, when I run this code an empty column is returned.

I have tried using Get Values (Num) in place of Set Values(Num) and I still get an empty Price Code column.

 

dataTable = New Table( "Data Table",
Add Rows( 3 ),
New Column( "Customer Name",
Character,
"Nominal",
Set Values( {"Jane", "Scott", "Abby"} )
),
New Column( "Dollar Amount",
"Continuous",
Set Values( [2002, 1323, 1954] )
)
);

popUp = New Window ("Number", << modal(),
        Panel Box("Enter a Number", lineup box ( N col (1)),
            number = Number edit box (34), ),
        Panel Box ("Actions", H List Box (  Button Box ("OK", keep_going = 1;                    
                    Num = :number << Get;),
           Button Box ("Cancel", keep_going = 0)   ),   ),
);

dataTable << New Column("Price Code",Numeric, "Continuous", Set Values(Num));

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

This is a simple 2 issue problem.  

1.  When you referenced

Num = :number << Get;

You are scoping the variable number wrong, ":" in front of the variable, tells JSL to look for a column named "Number" in a data table.  If you either leave it blank, or specify "::" it will look for a memory variable.

2.  If you want the scaler value from the memory variable "NUM" to be populated in all rows of the table you need to specify:

dataTable << New Column( "Price Code", Numeric, "Continuous", Set each Value( Num ) );

So the complete script would be:

Names Default To Here( 1 );
dataTable = New Table( "Data Table",
	Add Rows( 3 ),
	New Column( "Customer Name", Character, "Nominal", Set Values( {"Jane", "Scott", "Abby"} ) ),
	New Column( "Dollar Amount", "Continuous", Set Values( [2002, 1323, 1954] ) )
);

popUp = New Window( "Number",
	<<modal(),
	Panel Box( "Enter a Number", Lineup Box( N Col( 1 ) ), number = Number Edit Box( 34 ) ),
	Panel Box( "Actions",
		H List Box(
			Button Box( "OK",
				keep_going = 1;
				Num = number << Get;
			),
			Button Box( "Cancel", keep_going = 0 )
		), 

	), 

);

dataTable << New Column( "Price Code", Numeric, "Continuous", Set each Value( Num ) );

 

Jim
3 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

This is a simple 2 issue problem.  

1.  When you referenced

Num = :number << Get;

You are scoping the variable number wrong, ":" in front of the variable, tells JSL to look for a column named "Number" in a data table.  If you either leave it blank, or specify "::" it will look for a memory variable.

2.  If you want the scaler value from the memory variable "NUM" to be populated in all rows of the table you need to specify:

dataTable << New Column( "Price Code", Numeric, "Continuous", Set each Value( Num ) );

So the complete script would be:

Names Default To Here( 1 );
dataTable = New Table( "Data Table",
	Add Rows( 3 ),
	New Column( "Customer Name", Character, "Nominal", Set Values( {"Jane", "Scott", "Abby"} ) ),
	New Column( "Dollar Amount", "Continuous", Set Values( [2002, 1323, 1954] ) )
);

popUp = New Window( "Number",
	<<modal(),
	Panel Box( "Enter a Number", Lineup Box( N Col( 1 ) ), number = Number Edit Box( 34 ) ),
	Panel Box( "Actions",
		H List Box(
			Button Box( "OK",
				keep_going = 1;
				Num = number << Get;
			),
			Button Box( "Cancel", keep_going = 0 )
		), 

	), 

);

dataTable << New Column( "Price Code", Numeric, "Continuous", Set each Value( Num ) );

 

Jim
adel922

New Contributor

Joined:

May 14, 2017

Thank you so much txnelson

adel922

New Contributor

Joined:

May 14, 2017

Thank you so much txnelson.