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
 Forum for Origin C
 Accessing values from textdataset
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peter.cook

UK
356 Posts

Posted - 01/15/2004 :  06:00:29 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I have text (NOT text and numeric) datasets that I want to read values from with Origin C.

My understanding is that I can do this by three methods :

1. GetCell - this is okay if I know the column number! I want though to refer by dataset name so :

2. Dump all data into an array via PutStringArray - I don't want to do this.

3. Loop through all columns and compare names to dataset name, record column number and then use this with GetCell.

It would be alot easier if I could just use GetText with text columns!

I routinely use text columns and would not want to change to text and numeric. This is mainly because of the missing symbol '--' that results.

Can anyone please explain why GetText doesn't work with Text columns and if there is a simpler method than one of the above.

Cheers,

Pete

Mike Buess

USA
3037 Posts

Posted - 01/15/2004 :  08:35:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Pete,

You can use LabTalk's colnum function to find the column number from its name. Perhaps there is an OC equivalent that I don't know about. If not, might be good idea for a later patch or version.

void test(string sColName, int iRowNum)
{
Worksheet wks = Project.ActiveLayer();
double dColNum;
LT_execute("i=colnum(" + sColName + ");");
LT_get_var("i",&dColNum);
string sText;
wks.GetCell(iRowNum,(int) dColNum-1, sText);
out_str(sText);
}

Mike Buess
Origin WebRing Member
Go to Top of Page

peter.cook

UK
356 Posts

Posted - 01/15/2004 :  10:36:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

Thanks. Yes, I keep forgetting how useful LabTalk is!! Hope OriginLab address this - it would be neater.
Your solution does is a bit slicker than mine (3) so will adopt.

However, solution 3 is quicker presumably because of small overhead in LT_execute and LT_get_var?

Cheers,

Pete



Edited by - peter.cook on 01/15/2004 10:43:51 AM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 01/15/2004 :  12:11:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Column is derived from DataObject which is derived from DataObjectBase, which has a method GetIndex();

The following code shows how,

 

void LT_set_cell(string strVal, string strColName = "B", int nRow = 3)
{
Worksheet wks = Project.ActiveLayer();
Column cc = wks.Columns(strColName);
if(cc)
{
int nCol = cc.GetIndex();
wks.SetCell(nRow + 1, nCol, strVal); // use LT indexing in nRow
}
}






CP


Go to Top of Page

peter.cook

UK
356 Posts

Posted - 01/15/2004 :  12:33:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks CP.

Cheers,

pete

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