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
 How use a string as range index?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

islan

Switzerland
6 Posts

Posted - 10/03/2013 :  09:07:38 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi

I'am new to OriginLab and try to work on some data.

My question is; why do I get 2 different results by write the same code?

1. range rPGain = [Book2]1!Col(59);

2. int GS = -1+rHS[76]*6; (=59)
range rPGain = [Book2]1!Col(GS);

For the first example I get a number as output but for the second example I get only a - as output.


And how can I make the second example working?

Thanks islan :)

Edit - I try to rephrase my problem:

I have to "Books" one is a database and in the oter I work with new data. For calculations I need information from the database, but it is not always the same column I need.

So how can one implement a variable column number in the range command?
i.e.

int ColumnNumber = x;
range database = [Book2]1!Col(ColumnNumber);

Or is there an other way to do it?

Thanks

Ursina

i.e.

Edited by - islan on 10/07/2013 09:17:32 AM

greg

USA
1378 Posts

Posted - 10/07/2013 :  2:27:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The COL( ) function can take numbers OR column names as an argument.
When you said
range rPGain = [Book2]1!Col(GS);
Origin was looking for a column named "GS".

We also have the WCOL( ) function which ONLY expects a number. If text is passed to the function then we assume it is a numeric variable and interpret the value as the column number.

So,
int ColumnNumber = x;
range database = [Book2]1!WCol(ColumnNumber);
should work.
Go to Top of Page

islan

Switzerland
6 Posts

Posted - 10/08/2013 :  03:58:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Greg

thanks it works!

Ursina
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