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
 Unable to sort a worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

wilsonthongwk

Hong Kong
Posts

Posted - 06/06/2007 :  02:59:11 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Pro7.5 (SR0)
Operating System: WinXP

I use the following function to sort a worksheet. It is almost the same as the \Samples\Programming\Origin C Files\LabTalkAccessEx.c example.

void sortWks(string wksName, int sort_i)
{
using sort = LabTalk.sort;

Worksheet wks(wksName);
Dataset sortDS(wksName, sort_i);
Column sortCol = wks.Columns(sort_i);
string LTcom;

sort.wksname$ = wksName;
sort.c1 = 0;
sort.c2 = 100;
sort.r1 = 1;
sort.r2 = sortDS.GetSize();
LTcom = "A: ";
LTcom += sortCol.GetName();
sort.cname1$ = LTcom;
sort.wks();
}

The problem is the following. If I place a breakpoint before the "sort.wks();", it sorts an entire worksheet successfully. However if I don't place a breakpoint or place it after the "sort.wks();", it sorts only one column instread of the entire worksheet!!

I tried the following, but none can solve it.
- Don't use "using". Place the LabTalk codes inside the _LT_Obj block. => Doesn't work.
- Don't write a subfunction. Just write the LabTalk codes directly on where the function is called. -> Dosn't work.
- Don't use "using" nor _LT_Obj block. Code each link of LabTalk command in the LT_execute function. -> Doesn't work.

Any help are greatly appreciated. ^^

Mike Buess

USA
3037 Posts

Posted - 06/06/2007 :  06:37:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Not sure what's wrong but Origin C has Worksheet::Sort in O75. The following function does what yours is meant to do.

void sortwks(string wksName, int sort_i)
{
Worksheet wks(wksName);
wks.Sort(sort_i);
}

Mike Buess
Origin WebRing Member
Go to Top of Page

wilsonthongwk

Hong Kong
Posts

Posted - 06/06/2007 :  10:43:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Perfect!! Thanks a lot~ ^^

I think I should be keep looking those header files (such as wksheet.h) when writing Origin C, instead of looking the help. The wksheet.h explains the Worksheet::Sort very clearly. Thank you for your help.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/06/2007 :  10:52:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In most cases the descriptions for OC functions are taken from the corresponding .H file but help files are not always up to date. Since you have the release version (SR0) of O75 I strongly recommend that you update to the latest version (SR6). That will give you many bug fixes and additions as well as the latest help files. Run Help > Check for Updates and download/install anything that's offered. Repeat until no updates are found.

Mike Buess
Origin WebRing Member
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