cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
mallen810
Level III

recode script

I am trying to recode data (0 to .) after I pull it in from an sql server using the post querry scipt. I am getting an error at the end of my script. I am able to run the script through on the data table itself but would like this to happen automatically when I put in the data.

 

Here is my scipt.

Add Properties to Table(

{New Script(

"Recode",

Current Data Table() << Begin Data Update;

For Each Row( :purity_2 = Match( :purity_2, 0, ., ., ., :purity_2 ) );

For Each Row( :purity_3 = Match( :purity_3, 0, ., ., ., :purity_3 ) );

For Each Row( :purity_4 = Match( :purity_4, 0, ., ., ., :purity_4 ) );

For Each Row( :plus50_2 = Match( :plus50_2, 0, ., ., ., :plus50_2 ) );

For Each Row( :plus100_2 = Match( :plus100_2, 0, ., ., ., :plus100_2 ) );

For Each Row( :plus140_2 = Match( :plus140_2, 0, ., ., ., :plus140_2 ) );

Current Data Table() << End Data Update;)}

 

Here is the error message:

Unexpected end of input. Perhaps there is a missing "," or ")".

Trying to parse arguments of function "Add Properties to Table".

Line 60 Column 45:   Current Data Table() << End Data Update;)}►

 

Thanks,

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
pmroz
Super User

Re: recode script

You're missing a close parentheses at the end.

Current Data Table() << End Data Update;)});

View solution in original post

pmroz
Super User

Re: recode script

You need to send this as a message to your data table.  Here's one way to do it:

dt = current data table();

dt << Add Properties to Table(
{New Script(
"Recode",
Current Data Table() << Begin Data Update;
For Each Row( :purity_2 = Match( :purity_2, 0, ., ., ., :purity_2 ) );
For Each Row( :purity_3 = Match( :purity_3, 0, ., ., ., :purity_3 ) );
For Each Row( :purity_4 = Match( :purity_4, 0, ., ., ., :purity_4 ) );
For Each Row( :plus50_2 = Match( :plus50_2, 0, ., ., ., :plus50_2 ) );
For Each Row( :plus100_2 = Match( :plus100_2, 0, ., ., ., :plus100_2 ) );
For Each Row( :plus140_2 = Match( :plus140_2, 0, ., ., ., :plus140_2 ) );
Current Data Table() << End Data Update;
)});

View solution in original post

5 REPLIES 5
pmroz
Super User

Re: recode script

You're missing a close parentheses at the end.

Current Data Table() << End Data Update;)});
mallen810
Level III

Re: recode script

That did not work, I got the following message.

Add Properties to Table(
{New Script(
"Recode",
Current Data Table() << Begin Data Update;
For Each Row( :purity_2 = Match( :purity_2, 0, ., ., ., :purity_2 ) );
For Each Row( :purity_3 = Match( :purity_3, 0, ., ., ., :purity_3 ) );
For Each Row( :purity_4 = Match( :purity_4, 0, ., ., ., :purity_4 ) );
For Each Row( :plus50_2 = Match( :plus50_2, 0, ., ., ., :plus50_2 ) );
For Each Row( :plus100_2 = Match( :plus100_2, 0, ., ., ., :plus100_2 ) );
For Each Row( :plus140_2 = Match( :plus140_2, 0, ., ., ., :plus140_2 ) );
Current Data Table() << End Data Update;
)}
) /*###*/;
txnelson
Super User

Re: recode script

I am not really experienced in using the "Add Properties to Table()" however in reading the definition in the Scripting Index, it doesn't appear that what you are trying to do will work.  The following simplification of your script will work

Names Default to Here( 1 );
Current Data Table() << New Script(
	"Recode",
	Current Data Table() << Begin Data Update;
	For Each Row( :purity_2 = Match( :purity_2, 0, ., ., ., :purity_2 ) );
	For Each Row( :purity_3 = Match( :purity_3, 0, ., ., ., :purity_3 ) );
	For Each Row( :purity_4 = Match( :purity_4, 0, ., ., ., :purity_4 ) );
	For Each Row( :plus50_2 = Match( :plus50_2, 0, ., ., ., :plus50_2 ) );
	For Each Row( :plus100_2 = Match( :plus100_2, 0, ., ., ., :plus100_2 ) );
	For Each Row( :plus140_2 = Match( :plus140_2, 0, ., ., ., :plus140_2 ) );
	Current Data Table() << End Data Update;
);
Jim
pmroz
Super User

Re: recode script

You need to send this as a message to your data table.  Here's one way to do it:

dt = current data table();

dt << Add Properties to Table(
{New Script(
"Recode",
Current Data Table() << Begin Data Update;
For Each Row( :purity_2 = Match( :purity_2, 0, ., ., ., :purity_2 ) );
For Each Row( :purity_3 = Match( :purity_3, 0, ., ., ., :purity_3 ) );
For Each Row( :purity_4 = Match( :purity_4, 0, ., ., ., :purity_4 ) );
For Each Row( :plus50_2 = Match( :plus50_2, 0, ., ., ., :plus50_2 ) );
For Each Row( :plus100_2 = Match( :plus100_2, 0, ., ., ., :plus100_2 ) );
For Each Row( :plus140_2 = Match( :plus140_2, 0, ., ., ., :plus140_2 ) );
Current Data Table() << End Data Update;
)});
ih
Super User (Alumni) ih
Super User (Alumni)

Re: recode script

Edit: Ignore this, it is the same as Jim's post, above.

 

You can also send the New Script message directly to the table:

 

dt << New Script(
"Recode 2",
Current Data Table() << Begin Data Update;
For Each Row( :purity_2 = Match( :purity_2, 0, ., ., ., :purity_2 ) );
For Each Row( :purity_3 = Match( :purity_3, 0, ., ., ., :purity_3 ) );
For Each Row( :purity_4 = Match( :purity_4, 0, ., ., ., :purity_4 ) );
For Each Row( :plus50_2 = Match( :plus50_2, 0, ., ., ., :plus50_2 ) );
For Each Row( :plus100_2 = Match( :plus100_2, 0, ., ., ., :plus100_2 ) );
For Each Row( :plus140_2 = Match( :plus140_2, 0, ., ., ., :plus140_2 ) );
Current Data Table() << End Data Update;
);