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 for Programming
 LabTalk Forum
 Set Column Values + Before Formula Scripts
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Steffen89

2 Posts

Posted - 02/04/2015 :  1:49:51 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9.0 and 9.1
Operating System: Win7

Hi @ all
I am a beginner in programming with Labtalk. My Problem is to use an if/else Statement in "set Column Values". For Example I have Col(B) with 10 Values from 1 to 10. If the value is smaller than 5 (e.g. 4 3 2 1), I want to calculate Col(B)*Col(B).
If the Value is greater than 5, I want to calculate Col(B)*sqrt(Col(B)+1).
Formula: Col(C)= Col(B)*dN
I wrote the script in that way:
if Col(B) < 5
{
 dN = Col(B);
}
else
{
 dN = sqrt(Col(B)+1);
}

Can Someone explain, what I forgot in this code, please? Maybe the declaration of dN?

Thanks for Helping

lkb0221

China
497 Posts

Posted - 02/04/2015 :  5:35:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can directly write the following syntax in the function body, no before script needed:
col(B)<5? col(B)*col(B):col(B)*sqrt(Col(B)+1)

Edited by - lkb0221 on 02/04/2015 5:36:12 PM
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