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
 Assigning worksheet values

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
gintunas Posted - 06/19/2009 : 09:29:25 AM
Hello,

I am new in Origin C. I try to assign some numerical values to a created worksheet.

Could somebody indicate why my little code (below) halts with
"general operation failure
general operation failure
general operation failure
general operation failure
Command Error!"

The code is

void InitializeWorksheet(string WorksheetName)
{
Worksheet wks(WorksheetName);

if(!wks)
{
out_str("There is no worksheet with the name "+WorksheetName);
return;
}

printf("Columns %d Rows %d \n",wks.GetNumCols(),wks.GetNumRows());


for(int nCol = 0; nCol < wks.GetNumCols()-1; nCol++)
{
Dataset Temp;
int Size=wks.GetNumRows();
Temp.SetSize(Size);
Temp.Attach(wks, nCol);

for(int nRow = 0; nRow < wks.GetNumRows()-1; nRow++)
{
printf("We are on the row %d\n",nRow);
Temp[nRow]=nRow;
}

}
2   L A T E S T    R E P L I E S    (Newest First)
gintunas Posted - 06/22/2009 : 06:17:53 AM
Thanks, it works perfectly now!
Iris_Bai Posted - 06/22/2009 : 03:46:27 AM
Hi,

Runtime error here because when call Temp.SetSize(Size); Temp is an invalid object, should let Dataset attach to one column before SetSize. So change code to:

Temp.Attach(wks, nCol);
Temp.SetSize(Size);


BTW, I saw in for statement "int nCol=0; nCol < wks.GetNumCols()-1", this condition will NOT loop to the last column. If you want to loop to the last column, need change to nCol <= wks.GetNumCols() -1 or nCol < wks.GetNumCols()


Iris

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