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
 LabTalk Forum
 Streamlining Code

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
AMHumphries Posted - 09/12/2006 : 05:29:59 AM
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
5   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 09/12/2006 : 10:54:49 AM
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
AMHumphries Posted - 09/12/2006 : 10:17:27 AM
Thanks.

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

End? Exit?

Mike Buess Posted - 09/12/2006 : 07:33:28 AM
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
AMHumphries Posted - 09/12/2006 : 07:15:30 AM
Thanks Mike, I'll give it a try.

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

Mike Buess Posted - 09/12/2006 : 07:05:09 AM
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

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