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
 Column Name reference issue

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
Lara Cowan Posted - 11/07/2014 : 2:41:09 PM
I have a coding question.

An engineer using Origin 9.1 could not get his data to plot while others using 9.0 could plot without issues.
I found that the issue was caused by an overly long column name.

Worksheet wksFilesSetup;
wksFilesSetup.Create();
bOK=wksFilesSetup.ImportASCII(dataDirectory+"\\Files.txt",false,ASCIMP_MODE_REPLACE_DATA,true);   
// Rename setup worksheet page
wksFilesSetup.GetPage().Rename("FileSetup");
string fileSetupName = wksFilesSetup.GetPage().GetName();

Dataset ddTimeColumnIndex(fileSetupName+"_FirstTimeColumnIndex");
StringArray timeColumnIndexArray;
bOK=ddTimeColumnIndex.GetStringArray(timeColumnIndexArray);


Both Origin 9.0 and Origin 9.1 truncate "FirstTimeColumnIndex" to "FirstTimeColumnInd" for the column short name.
Origin 9.0 has no issues getting the column data.
However, Origin 9.1 will not find the column and will set timeColumnIndexArray to Invalid Value.
This means that when timeColumnIndexArray is accessed, Origin will halt with an unkown error.

I changed the line to
Dataset ddTimeColumnIndex(fileSetupName+"_FirstTimeColumnInd");

and then the code worked just fine.

Is there a better way to reference the column or some way to indicate that I want to get the column by long name?
4   L A T E S T    R E P L I E S    (Newest First)
Lara Cowan Posted - 11/13/2014 : 09:18:01 AM
Thank you Castiel, that works perfectly.
Castiel Posted - 11/12/2014 : 9:42:07 PM
quote:
Originally posted by Lara Cowan

Thank you for the information Greg.

I can use the Dataset( Worksheet & wks, int nCol ) constructor for the setup worksheets, but I will have to find a better way to reference the data columns since I will not know their index, only their long name.



Datasheet::FindCol(LPCSTR lpcszColLabel, int nColBegin = 0, BOOL bCaseSensitive = false, BOOL bFullMatch = true, int nColEnd = -1, BOOL bAllowShortName = true)


©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦
Lara Cowan Posted - 11/12/2014 : 10:06:43 AM
Thank you for the information Greg.

I can use the Dataset( Worksheet & wks, int nCol ) constructor for the setup worksheets, but I will have to find a better way to reference the data columns since I will not know their index, only their long name.
greg Posted - 11/10/2014 : 12:24:58 PM
It is true that there are character limits for the length of a dataset name which is based on BookShortName_ColumnShortName@SheetIndex
so there are times when Origin automatically truncates a column short name to keep within the limits.
For example, given Book1 with two sheets, the short name of a column in Sheet1 cannot exceed 18 characters. For Sheet2 that limit is 16 characters to accomodate the additional "@2" in the dataset name. (The first sheet never requires an "@1".)

The GUI checks in Origin 9 and 9.1 are the same, so some other process has triggered the difference in the auto-renaming in 9 and 9.1. Note that your workbook rename could actually result in a dropped character if the import had already run into the name limits which is why line following is needed.

The class constructor for a Dataset also includes:
Dataset( Worksheet & wks, int nCol )
and
Dataset( LPCSTR lpcszWksName, int nCol )

which attach to a column based on column index (indexed from 0) and either a worksheet object (wksFilesSetup) or the 'Worksheet name' (e.g. "[Book1]Sheet1", 0 for the first column in Sheet1 of Book1).

Either way, column index is a better way of attaching to a column.

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