The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 convert NANUM to 0 via script
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

DmitriyElets

Russia
1 Posts

Posted - 11/10/2018 :  1:02:55 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 9.0

How can I convert NANUM to number (for ex. 0) using script window (set column values window) in the way, that allows to work with result as with number/column/dataset?

If I write something like
ISNA(col(AR1)) ? 0 : col(AR1)
it set 0 in the cells, corresponding to NANUM values.

But if I don't want to make new column every time for NANUM->0 converted values and write something like
2*ISNA(col(AR1)) ? 0 : col(AR1)
or do mote complicated expressions, then I get an error: "Math cannot be performed on Text column"

I know how to do in in OriginC, but may be somebody knows the way to do it via script window functions?

Edited by - DmitriyElets on 11/10/2018 1:03:16 PM

nick_n

Finland
125 Posts

Posted - 11/10/2018 :  3:55:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Try:

int ii, jj;

loop (jj, wks.c1, wks.c2)
{
	loop (ii, 1, wks.maxrows)
	{
		string currCell$=wcol(jj)[ii]$;
		if (currCell$=="" || currCell$=="--") wcol(jj)[ii]=0;
	}
}


It will replace NANUM with 0 in selected columns. Best regards,

Nikolay
Go to Top of Page

couturier

France
291 Posts

Posted - 11/10/2018 :  4:25:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can save 1 loop with this:

int jj;
loop (jj, wks.c1, wks.c2)
{
	range rCol=$(jj);
	rCol=rCol==0/0?0:rCol;
}
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 11/11/2018 :  09:18:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
However, that will work faster:
int jj;
loop (jj, wks.c1, wks.c2)
{
	wcol(jj)=treplace(wcol(jj), 0/0, 0, 2);
}


Nikolay
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000