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
 Direct Conversion of Worksheet to Matrix

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
superman1 Posted - 11/06/2002 : 09:20:57 AM
Hello All,

What code do I use to convert a worksheet directly to a matrix?

thanks
Andrew
5   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 11/07/2002 : 08:58:01 AM
Hi Andrew,

Change the line
matpg.Create();
to
matpg.Create("Matrix.OTP");
which creates the matrix using the default Origin matrix template. Then it works fine.

Easwar
OriginLab.
superman1 Posted - 11/07/2002 : 05:21:39 AM
Hi Easwar,

Here is my code:


void portrait()
{

string ElecName = InputBox("Please enter the electrode to be ploted \n case sensitive");

Worksheet wks(ElecName);
string m=("m");
string MatName = lstrcat (ElecName, m);

MatrixPage matpg;
matpg.Create();
matpg.Rename(MatName);
Matrix mat;
mat.Attach(MatName);
mat.CopyFromWks(wks);


}

What I am trying to do is have a user enter the name of an existing orgin worksheet, then create a matrix with an m appended to the end of the name, and then directly convert the worksheet to the matrix.

Its not working!!

Any ideas? Thanks for all the help.
Andrew

easwar Posted - 11/06/2002 : 1:46:08 PM
Hi Andrew,

What you found in the documentation is much better than what I suggested. And it works fine.

Maybe you can debug the code and see why it is not working for you? The code assumes that worksheet Data1 and matrix Matrix1 already exist in your project. The if statement checks for validity of those objects and does the conversion only if they both exist. Maybe that is where you have the problem?

Easwar
OriginLab.



Edited by - easwar on 11/06/2002 1:49:08 PM
superman1 Posted - 11/06/2002 : 11:47:22 AM
Thanks Easwar, I will try your code.

Why did you not use the following?

void copyfromwks()
{
// Assumes Data1 worksheet and Matrix1 matrix exist in Origin
Worksheet wks("Data1");
Matrix mat1("Matrix1");
BOOL bRet = false;
if(mat1 && wks)
bRet = mat1.CopyFromWks(wks); //Copies the whole wks to m1

}

It is the example code from the Programming Guide. It did not work for me.

Andrew

easwar Posted - 11/06/2002 : 10:16:09 AM
Hi Andrew,

If you want to do this from LabTalk, you can use code like below, where active window is assumed to be the worksheet to begin with:

mat.wksname$ = %H;
win -T M;
mat.matname$ = %H;
mat.w2m();

If you want to do this from Origin C, you can use code like below, where you will call this function passing the name of the worksheet to be converted.

 
void wks2mat(string strWksName)
{
Worksheet wks(strWksName); // Declare Worksheet
MatrixPage matPg; // Declare Matrix Page
matPg.Create("Matrix.OTP"); // Create Matrix Page using standard template
string strMatName = matPg.GetName(); // Get name of Matrix Page that was created
using mat = LabTalk.Mat; // Set up access to LabTalk mat object from Origin C
mat.wksname$ = strWksName; // Set name of worksheet in mat object
mat.matname$ = strMatName; // Set name of result matrix in mat object
mat.w2m(); // Use wkstomat conversion method of mat object
}


Easwar
OriginLab.

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