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
 Streamlining Code
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

AMHumphries

UK
Posts

Posted - 09/12/2006 :  05:29:59 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Pro 7.5 SR4
Operating System: Win XP

I am new to Origin and LabTalk and have written the following piece of code to automate the copying of a particular column in a standardised dataset to a worksheet for comparison. The code follows:

%A = fdlog.MultiOpen.Count;
if (%A => 1)
multiWks_A = Sheet1_D;
else if (%A => 2)
multiWks_B = Sheet2_D;
else if (%A => 3)
multiWks_C = Sheet3_D;
else if (%A => 4)
multiWks_D = Sheet4_D;
else if (%A => 5)
multiWks_E = Sheet5_D;
else if (%A => 6)
multiWks_F = Sheet6_D;
else if (%A => 7)
multiWks_G = Sheet7_D;
else if (%A => 8)
multiWks_H = Sheet8_D;
else if (%A => 9)
multiWks_I = Sheet9_D;
else if (%A == 10)
multiWks_J = Sheet10_D;
else
// Error message here



As far as I am concerned this code is very unwieldy and inelegant.

As a matter of learning I was wondering if the more LabTalk-knowledgable of you could suggest an alternative method of executing this code which would be much more efficient?

Regards,

Andrew Humphries



Edited by - AMHumphries on 09/12/2006 05:31:46 AM

Mike Buess

USA
3037 Posts

Posted - 09/12/2006 :  07:05:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Andrew,

This should work...

nn=fdlog.MultiOpen.Count;
if(nn==0 || nn>10) type "error message";
else %(multiWks,nn) = Sheet$(nn)_D;

Mike Buess
Origin WebRing Member
Go to Top of Page

AMHumphries

UK
Posts

Posted - 09/12/2006 :  07:15:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike, I'll give it a try.

What is the significance of the variable 'nn' or is it arbitrary?

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/12/2006 :  07:33:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Any numeric variable will do but some (for example, i and n) are used internally so they are generally avoided as user variables. Consequently, I often use double-letters (ii, jj, nn) as my variable names.

Mike Buess
Origin WebRing Member
Go to Top of Page

AMHumphries

UK
Posts

Posted - 09/12/2006 :  10:17:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks.

As a final question - what command would one use to simply terminate the script and prevent it from continuing to process?

End? Exit?

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/12/2006 :  10:54:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Use return...

nn=fdlog.MultiOpen.Count;
if(nn==0 || nn>10) {
type "error message";
return;
};
else %(multiWks,nn) = Sheet$(nn)_D;

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