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 for Programming
 Forum for Origin C
 Accessing values from textdataset

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
peter.cook Posted - 01/15/2004 : 06:00:29 AM
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

4   L A T E S T    R E P L I E S    (Newest First)
peter.cook Posted - 01/15/2004 : 12:33:02 PM
Thanks CP.

Cheers,

pete

cpyang Posted - 01/15/2004 : 12:11:26 PM
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


peter.cook Posted - 01/15/2004 : 10:36:14 AM
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
Mike Buess Posted - 01/15/2004 : 08:35:05 AM
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

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