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
 set -er in OC?

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
Mike Buess Posted - 03/06/2003 : 08:20:21 AM
I need to increase the number of rows in my dataset (worksheet) without assigning values to its elements. Origin C resizing methods I've tried so far (SetSize and SetUpperBound) set the cell values to 0/0. I need a method that acts like this LabTalk command...

set dataset -er nrows;

Suggestions?

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 03/06/2003 08:21:55 AM
8   L A T E S T    R E P L I E S    (Newest First)
Gary Lane Posted - 03/07/2003 : 11:27:01 AM
Hi,

Try

Dataset ds("Data1_A");
ds.SetSize(50);
ds.SetUpperBound(-1);
vector vv = {1,2,3,4,5,6,7,8,9};
ds.Append(vv,REDRAW_REFRESH);

ds.SetUpperBound(-1); will display no rows while SetUpperBound(0) says display value in first row (0 based offset). I will make sure this is better documented for future.

BTW: It looks like Worksheet class and Column class SetNumRows() will make it into SR4.

Thanks for your persistence.

-Gary

Edited by - Gary Lane on 03/07/2003 12:15:27 PM
Mike Buess Posted - 03/07/2003 : 10:30:02 AM
Just to tie up loose ends...

The fast and slow methods did not produce the exact same results. dd.SetUpperBound(0) leaves NaN in the first row of dd, so its final data are off by one row. That's easily taken care of with dd.TrimLeft().

long blockLength = 2048;
long blockCount = 1024;
Dataset dd;
dd.Create( blockLength*blockCount+1 );
dd.SetUpperBound( 0 );
- append blockCount blocks of size blockLength to dd -
dd.TrimLeft();
- do something with dd -

Mike Buess
Origin WebRing Member
Gary Lane Posted - 03/07/2003 : 08:15:56 AM
Wow!

Mike Buess Posted - 03/06/2003 : 8:02:01 PM
Hi Gary,

Your suggestion worked perfectly.

long blockLength = 2048;
long blockCount = 1024;
Dataset dd;
dd.Create( blockLength*blockCount );
dd.SetUpperBound( 0 );
- append blockCount blocks of size blockLength to dd -
- do something with dd -
Execution time: 2.6s

Compared to this...

long blockLength = 2048;
long blockCount = 1024;
Dataset dd;
dd.Create( 0 );
- append blockCount blocks of size blockLength to dd -
- do same thing with dd -
Execution time: 31.4s

End results are identical. Many thanks!

Mike Buess
Origin WebRing Member
Mike Buess Posted - 03/06/2003 : 3:45:22 PM
Thanks, Gary... sounds good. I'll try it this evening.

Mike Buess
Origin WebRing Member
Gary Lane Posted - 03/06/2003 : 3:15:04 PM
Hi Mike,

Currently I think LT_execute("set %H -er nrows") is the only way to do this but as I said we are hoping to add SetNumRows to Column class and maybe even Worksheet class which should do this for you. We are working on this now and hopefully it will be done for SR4 due out relatively soon.

I have one other idea. Try Dataset::SetSize followed by Dataset::SetUpperBound like below:

Dataset ds("Data1_A");
ds.SetSize(50); // Total rows 0 to 49
ds.SetUpperBound(24); // O based offset

Rows 25 to 49 will exist in the worksheet but no values (either 0 or 0/0) are displayed in those rows of the worksheet.

Gary





Mike Buess Posted - 03/06/2003 : 1:25:59 PM
Hi Gary,

I think SetNumRows would be what I want, but it doesn't seem to exist. (I see you already answered that.) I need to increase the number of rows in a dataset or worksheet without inserting any values (numbers or 0/0).

I'm using Append to import a data file in blocks and have discovered that the operation is nearly 10x faster if the dataset I'm appending to does not have to grow with each append. (That is, if all of the necessary rows already exist but are empty.) So far the only way I've been able to do that is to create a worksheet, set the number of rows with LT_execute("set %H -er nrows") and append to one of its columns. I'd like to use a temporary dataset with nrows empty rows instead, but I can't seem to do that in Origin C. There are several ways to create a dataset with the correct size, but they all fill it with numbers (0) or nulls (0/0). Then the operation takes even longer and the dataset ends up twice as large as it needs to be.

So how can I create an empty dataset of a given size in Origin C?

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 03/06/2003 1:29:25 PM
Gary Lane Posted - 03/06/2003 : 12:32:49 PM
Hi Mike,

Worksheet class inherits GetNumRows from Datasheet class but there is no SetNumRows. I think we will be adding Get/SetNumRows to column class and I will ask for SetNumRows for Datasheet/Worksheet as well. So I guess for now you will need to use LT_execute.

Gary

Edited by - Gary Lane on 03/06/2003 12:49:18 PM

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