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
 Index() Function Question

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
cdrozdowski111 Posted - 03/18/2013 : 7:22:51 PM
OriginPro 9.0.0 SR1, Win7 64-bit, running in VMware Fusion 5.0.2

I am doing something wrong with the LT Index() function. Given a worksheet as shown in the attached pic, why would the following lines of code all return -1?


double nIdx1 = index(11781.20, Col(1)); type -a $(nIdx1); // Returns -1
double nIdx1 = index(11781.00, Col(1), 1); type -a $(nIdx1); // Returns -1
double nIdx1 = index(11781.00, Col(1), 2); type -a $(nIdx1); // Returns -1


2   L A T E S T    R E P L I E S    (Newest First)
cdrozdowski111 Posted - 03/19/2013 : 04:56:53 AM
I tried xindex and it worked. But the docs indicate that the X column must be in ascending order, so I didn't want to rely on it in case the behavior changed down the road to match the docs.

http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:Xindex_%28function%29

So, what I am doing is to reverse all of the columns in the worksheet, use the index() function, do my operations, and then reverse the columns again.


range rng = [Book1]1;
colreverse rng:=[Book1]1!(1, $(rng.ncols));
double nIdx1 = index(11781.20, Col(1));

... Do operations

colreverse rng:=[Book1]1!(1, $(rng.ncols));
Penn Posted - 03/18/2013 : 11:26:54 PM
Hi,

This is a bug for the monotonic decreasing data. You can try the xindex function to see whether it can work fine for your need. Such as:

// the second parameter is Col(2), but not Col(1) here
double nIdx1 = xindex(11781.20, Col(2)); type -a $(nIdx1); // Returns -1
double nIdx1 = xindex(11781.00, Col(2), 1); type -a $(nIdx1); // Returns -1
double nIdx1 = xindex(11781.00, Col(2), 2); type -a $(nIdx1); // Returns -1


Penn

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