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
 Reference last rows using a variable
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Clairekun

Germany
175 Posts

Posted - 06/29/2022 :  6:20:08 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2018b
Operating System: Win10

Hello,

I have a code where I need to add 3 columns to every worksheet and assign a long name and formula to all of them.

The problem is that not all worksheets have the same number of columns. I tried the following, which didn't work:

int ncols = wks.ncols;
col(ncols-2)[L]$ = "Pressure";

This created a new column instead of using the 3rd to last.

How could I do this?

Thank you.

Edited by - Clairekun on 06/29/2022 6:21:10 PM

Clairekun

Germany
175 Posts

Posted - 06/29/2022 :  7:19:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I found a way, although there might be a better method.

int end3 = wks.ncols-2; //Assign a different variable to preferred columns
int end2 = wks.ncols-1;
int end1 = wks.ncols;

wcol(end3)[L]$ = "Pressure"; //Use variables in wcol instead of col
wcol(end2)[L]$ = "Time";
wcol(end1)[L]$ = "Temperature";
Go to Top of Page

aplotnikov

Germany
169 Posts

Posted - 06/30/2022 :  03:30:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
col($(ncol-2))[L]$="Pressure"
wks.col$(ncol-2).lname$="Pressure"
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 06/30/2022 :  11:03:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Much better, thanks!!
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