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
 LabTalk Forum
 LabTalk to do a Direct Convert to Matrix?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

RJM2

Canada
Posts

Posted - 06/22/2006 :  6:03:36 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: WindowsXP

Hello,

Just wondering if anyone knows a way to do a Direct Worksheet to Matrix conversion. I would like to write a script to do the following:

Edit:Convert to Matrix:Direct

with the options: Y varies across columns
X values in first column

And convert it!

I know that you can call run.section(Wks,Wks2Mat); , but how do I select the options from LabTalk for the the popup windows and then convert?

Thanks for any help,

Russ

Laurie

USA
404 Posts

Posted - 06/23/2006 :  08:59:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Russ,

The "Direct Conversion to Matrix" dialog is a DialogBuilder dialog (OriginPro feature) programmed in Origin C. You can look at the code in OMatDlgDMC.c.

If you want to use LabTalk, you can look at the commented out code in the [Wks2Mat] section of the WKS.ogs file. You'd want to use the mat.w2m() method. However, in LabTalk, you don't have control over the "X varies across columns" and "Y varies across columns" options.

Laurie

OriginLab Technical Support
Go to Top of Page

RJM2

Canada
Posts

Posted - 06/23/2006 :  7:48:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

Thanks for your reply. I've created a short script (of what I hope will do the job in Origin C. However, I'm unable to call it. After successfully compiling and linking the code, I get a "Command Error!" response after I call it. I've attached the code. Any ideas??

Thanks much,

Russ

/*------------------------------------------------------------------------------*
* File Name: *
* Creation: *
* Purpose: OriginC Source C file *
* Copyright (c) ABCD Corp. 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 *
* All Rights Reserved *
* *
* Modification Log: *
*------------------------------------------------------------------------------*/

////////////////////////////////////////////////////////////////////////////////////
// Including the system header file Origin.h should be sufficient for most Origin
// applications and is recommended. Origin.h includes many of the most common system
// header files and is automatically pre-compiled when Origin runs the first time.
// Programs including Origin.h subsequently compile much more quickly as long as
// the size and number of other included header files is minimized. All NAG header
// files are now included in Origin.h and no longer need be separately included.
//
// Right-click on the line below and select 'Open "Origin.h"' to open the Origin.h
// system header file.
#include <Origin.h> // Includes most Origin header files
//#include <Dialog.h> // Dialog class
////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////
// Include application header files
#include "App_Utils.h" // Application utilities like CreateWindow function
#include "Wks_Utils.h" // Wks_Utils function prototypes and non-localized constants
#include "OMat.h" // OMat.c prototypes and definitions
#include "ConvertWrkshtToMatrix.h" // OMatDlgDMC.c prototypes and definitions
#include "ODlg.h" // Resources in ODlg.DLL

////////////////////////////////////////////////////////////////////////////////////
// Start your functions here.


static int ConvertWrkshtToMatrix(BOOL bSelectAll) // bSelectAll=FALSE
{
string strMsg, strSelectedRange;
int iRet;

iRet = wuGetContiguousWksSelection(strSelectedRange); // Get current selection range

if( iRet ) // If no or bad selection...
{
if( bSelectAll && ( iRet == WKS_UTILS_NO_SEL_WARNING ) ) // If bSelectAll is TRUE and no selection...
iRet = wuGetContiguousWksSelection(strSelectedRange, TRUE);// Get entire worksheet/workbook as selection range

if( iRet ) // Check again, if no or bad selection...
{
strMsg = _L(DMC_WKS_SEL_ERROR_MSG); // Output error message and return
strMsg.Write(WRITE_MESSAGE_BOX);
return 0;
}
else
MessageBeep(MB_OK); // Else just beep to warn
}


// *** Store settings in tree ***
Tree trDMC;
trDMC = CreateDirectMatConvertTree();
trDMC.SelRange.strVal = strSelectedRange;
trDMC.xVariesAcrossCols.nVal = 0;
trDMC.xInRow1.nVal = 0;
trDMC.yInCol1.nVal = 0;
trDMC.xInCol1.nVal = 1;
trDMC.yInRow1.nVal = 0;

return ConvertWksToMatrixDirect(trDMC);
}
quote:

Hi Russ,

The "Direct Conversion to Matrix" dialog is a DialogBuilder dialog (OriginPro feature) programmed in Origin C. You can look at the code in OMatDlgDMC.c.

If you want to use LabTalk, you can look at the commented out code in the [Wks2Mat] section of the WKS.ogs file. You'd want to use the mat.w2m() method. However, in LabTalk, you don't have control over the "X varies across columns" and "Y varies across columns" options.

Laurie

OriginLab Technical Support



quote:

 
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/25/2006 :  10:16:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Russ,

If you want to use your function as a LabTalk command it cannot be static. Define it like this...

int ConvertWrkshtToMatrix(BOOL bSelectAll)
{
// code
}

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 06/25/2006 10:17:53 AM
Go to Top of Page

RJM2

Canada
Posts

Posted - 06/26/2006 :  2:29:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike,

Worked like a charm!

Russ
quote:

Hi Russ,

If you want to use your function as a LabTalk command it cannot be static. Define it like this...

int ConvertWrkshtToMatrix(BOOL bSelectAll)
{
// code
}

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 06/25/2006 10:17:53 AM

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