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
 Set Value

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
nbo10 Posted - 11/26/2008 : 6:00:53 PM
Origin Ver.8 and SR (Select Help-->About Origin):
Operating System:xp

I have a column that I use as a flag, it's either p or s. I want to set the value of another column depending on the value of the flag column. How do I do this, I've tried the following code in the "Before formula scripts" but it doesn't run properly.
[code]
if( Col(A)[i] == p)
{
a=Col(CenterX);
b=Col(CenterY);
Col(SpotAngleSan) =atan(a/b);
}

if( Col(A)[i] == s)
{
a=Col(CenterY);
b=Col(CenterX);
Col(SpotAngleSan) =atan(a/b);
}
[\code]
3   L A T E S T    R E P L I E S    (Newest First)
nbo10 Posted - 11/27/2008 : 10:39:56 AM
I just changed to using either a 0 or 1 for p or s, and everything works out.
nbo10 Posted - 11/27/2008 : 10:37:33 AM
What format does the flag column need to be in?

Thanks for the help but the formula dont evaluate to the expected values. It always always evaluates last formula. When I use the line
(col(A)=="p") ? atan(col(CenterX)/col(CenterY)) : atan(col(CenterY)/col(CenterX))
It always evaluates
atan(col(CenterY)/col(CenterX))
I've tried all combination's of label, disregard, x on the flag column with no change
VincentLiu Posted - 11/27/2008 : 04:39:40 AM
You may copy and paste following codes to "Before formula scripts" to set values. Please note that if p and r are characters, please add "" in the scripts. Here we assume p and r are characters.


int i;
for (i=1;i<=wks.maxrows;i++)
{
 if( Col(A)[$(i)] == "p")
 {
   a=Col(CenterX)[$(i)]; 
   b=Col(CenterY)[$(i)];
   Col(SpotAngleSan)[$(i)] =atan(a/b);
 }
 else
 {
   a= Col(CenterY)[$(i)];
   b= Col(CenterX)[$(i)];
   Col(SpotAngleSan)[$(i)] =atan(a/b);
 }
}


For the flag column has only two values p or s, there is another way to solve the problem. You can past the following code in the Column formula (which is in the middle panel of Set Values dialog.):

(col(A)=="p") ? atan(col(CenterX)/col(CenterY)) : atan(col(CenterY)/col(CenterX))

For the computation speed may be slower when you use loop in "Before formula scripts", we recommend you to use the second way to Set Values.

Best regards,
Vincent Liu
OriginLab Technical Services


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