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
 Add column only if it doen't already exist
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

leonardo.a027

Argentina
9 Posts

Posted - 05/09/2017 :  6:07:55 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi.
I am trying to add columns only when it doesn't exist. I am trying to use the option:
worksheet -v
but when the code moves to the second sheet, it copies the data to the first one and not the current one. My code looks like this:

newbook MelaninIndex;
range Area = [MelaninIndex]Sheet1!2;
range Name = [MelaninIndex]Sheet1!1;
win -a DatosMelanina;
int jj = 1;

doc -e LW
{
    string str =wks.name$;
    range Reflectance = Col(2);
    worksheet -v logR;
    range logR1 = logR;
    logR1              = -log(Reflectance);
    
    range linex = Col(1)[5:10];
    worksheet -v Line1;
    range line1 = Line1;
    line1       = linex;
    range liney = Col(3)[5:10];
    worksheet -v Line2;
    range line2 = Line2;
    line2       = liney;
    
    wks.col      = 4;
    wks.col.type = 4;
    
    worksheet -v XFit;
    worksheet -v FitData;
    fitLR iy:=(4,5) oy:=(col(XFit),col(FitData));
    range Fit    = FitData;
    integrate Fit;
    Area[jj]    = integ.area/100;
    Name[jj]$   = str$;
    jj++;
}

I am using windows 10 and OriginPro 2016

Echo_Chu

China
Posts

Posted - 05/10/2017 :  06:04:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Tough I can not reproduce the same error as you. I can see you did not correctly define the new created column to be a range. I am not sure whether your problem is because of this.

For example, it should be range logR1 = col(logR), instead of range logR1 = logR

Please see the updated code as below.

range Area = [MelaninIndex]Sheet1!2;
range Name = [MelaninIndex]Sheet1!1;
win -a DatosMelanina;
int jj = 1;

doc -e LW
{
    string str =wks.name$;
    range Reflectance = Col(2);
    worksheet -v logR;
    range logR1 = col(logR);
    logR1 = -log(Reflectance);
    
    range linex = Col(1)[5:10];
    worksheet -v Line1;
    range line1 = col(Line1);
    line1       = linex;
    range liney = Col(3)[5:10];
    worksheet -v Line2;
    range line2 = col(Line2);
    line2       = liney;
    
    wks.col      = 4;
    wks.col.type = 4;
    
    worksheet -v XFit;
    worksheet -v FitData;
    fitLR iy:=(4,5) oy:=(col(XFit),col(FitData));
    range Fit    = col(FitData);
    integrate Fit;
    Area[jj]    = integ.area/100;
    Name[jj]$   = str$;
    jj++;
}

Go to Top of Page

leonardo.a027

Argentina
9 Posts

Posted - 05/11/2017 :  12:15:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That must have been the problem since now it works just fine. Thanks a lot for the help :)!!
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