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
 Add column only if it doen't already exist

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
leonardo.a027 Posted - 05/09/2017 : 6:07:55 PM
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
2   L A T E S T    R E P L I E S    (Newest First)
leonardo.a027 Posted - 05/11/2017 : 12:15:46 PM
That must have been the problem since now it works just fine. Thanks a lot for the help :)!!
Echo_Chu Posted - 05/10/2017 : 06:04:29 AM
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++;
}


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