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
 conditional copy of String Array elements. how?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

eathiele

USA
3 Posts

Posted - 09/11/2012 :  4:59:03 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: 8.5.1 SR2
Operating System: Win7

This is what I have:
Col(A) = an array of string values serving as IDs for each row.
Col(B) = measure of variation

This is what I want:
If (Col(B)>cutoff value), then copy corresponding value in Col(A) to Col(C), else leave blank (or --).

How do I do this? Ternary [i.e., Col(B)>cutoff value?Col(A):] does not work with string values in Col(A). Nor does treplace.

If I set Col(A) as a StringArray (sa) and do

if (Col(B)>cutoff value) sa.CopyTo(Col(C))

it will copy all of Col(A) to Col(C), apparently ignoring the conditional statement.

What am I missing? Though I have virtually no coding experience, it seems like it should be very simple to selectively copy an element from a String Array based on a condition or set of conditions.

Thanks!

Hideo Fujii

USA
1582 Posts

Posted - 09/11/2012 :  6:32:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi eathiele,

I believe, but I may be wrong, the conditional operator works as a numeric operator. So, you wouldn't be able to achieve in this venue.
So, if you use a loop, may be like as follows:

loop(ii,1,wks.maxRows) {if(col(B)[ii]>0.5) col(C)[ii]$=col(A)[ii]$; else col(C)[ii]=1/0;}

Maybe someone can give a better answer.

--Hideo Fujii
OriginLab
Go to Top of Page

eathiele

USA
3 Posts

Posted - 09/12/2012 :  3:45:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
So far, so good!

Thank you so much, Hideo!!
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