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 for Programming
 LabTalk Forum
 If-else Statement

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
tanosca Posted - 09/27/2006 : 07:26:58 AM
Origin Version (Select Help-->About Origin):
Operating System:

Labtalk Script

I am new to OriginLab, and I would like some help please on a simple if-else statement.

if Col(A) < 0
{
Col(B) = 2+2;
}
else
{
Col(B) = 7;
}

The above statement doesn't work at all. If I include a "For" statement, I get results, but not what I'm expecting. Origin seems to find the first condition of the "IF" (let's say a negative value) and applies that calculation to all elements in the dataset regardless of sign, it completely ignores the else. Can you assist please.

for (i=1; i <=4; i++)

if (Col(A) < 0 )
{
Col(B)[i] = 2+2;
}
else
{
Col(B)[i] = 7;
}

Thank you
3   L A T E S T    R E P L I E S    (Newest First)
merlin1401 Posted - 11/16/2010 : 09:18:51 AM
I want to integrate the Heaviside-function into my fitting. It is compiled successfully but doesn't do the right thing. Who knows how to fix this problem? The source-code is the following:

#pragma warning(error : 15618)
#include <origin.h>
#include <math.h>
#include <stdio.h>

void _nlsfDeconv_1(

double A, double x0, double y0, double t, double G,

double x,

double& y)
{
double z;
double temp;

temp = (y0+A*exp(G^2/(16*ln(2)*t^2))*exp(-(x-x0)/t));
if(x-x0<0.0){z==0.0;} else {z==1.0;};
y =z*temp;
}
tanosca Posted - 10/02/2006 : 2:09:00 PM
Sorry for the delay in sending my thxs.

Hi:

the test condition should be included in the parentheses:

if (Col(A) < 0)
{
Col(B) = 2 + 2;
}

In this case, the left value of the test condition is the first cell value of column A. So the above scripts equals to

if (Col(A)[1] < 0)
{
Col(B) = 2 + 2;
}

Larry
OriginLab Technical Services
[/quote]
larry_lan Posted - 09/27/2006 : 07:40:25 AM
Hi:

the test condition should be included in the parentheses:

if (Col(A) < 0)
{
Col(B) = 2 + 2;
}

In this case, the left value of the test condition is the first cell value of column A. So the above scripts equals to

if (Col(A)[1] < 0)
{
Col(B) = 2 + 2;
}

Larry
OriginLab Technical Services

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