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
 All Forums
 Origin Forum
 Origin Forum
 conditional copy of String Array elements. how?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
eathiele Posted - 09/11/2012 : 4:59:03 PM
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!
2   L A T E S T    R E P L I E S    (Newest First)
eathiele Posted - 09/12/2012 : 3:45:13 PM
So far, so good!

Thank you so much, Hideo!!
Hideo Fujii Posted - 09/11/2012 : 6:32:32 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000