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
 Script running leads to Crash wenn i>10k??
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hawu001

5 Posts

Posted - 10/09/2018 :  4:04:39 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): b9.5.1.195
Operating System:Win10

Hi fellas,

I'm relatively new in this field and I was actually excited by using the LabTalk-Script, cuz it could really save a lot of time sometimes.

But there's just a new problem: every time I run the code, it ends up with a crash of the programme.

Description of my task at first:

I have 4 columns of Data: let's say A, B, C, D. Col(C) is for the measured data, and Col(B) is the "time interval" of the measured Data, which is very small (like 0, 0.2, 0.4, 0.6,..., 10000) and therefore has a lot of rows. The Col(A) is another "time interval" which is in comparision with Col(B) very wide(like 0, 100, 200, 300,..., 10000) and therefore has less rows.

What I need is to select the value of Col(C) (measured data) after the wider time interval and paste it into Col(D).I.e. when the value of Col(B) is found in Col(A), the value in the same row of Col(C) should be copied and pasted into Col(D).

The script is pasted as following:
==========================================================
for( i=1,j=1 ; i<=40 && j <=80 ; j++ )
{
range rr=Col(D)[$(i)];
aa=Col(A)[$(i)];
bb=Col(B)[$(j)];
cc=Col(C)[$(j)];
if($(bb)==$(aa))
{rr=$(cc);
rr[1]=;
i++;
}
else
{continue;
}
}
==========================================================
When i and j are less than 80, it seems actually good. The goal can be reached. But since I have really a lot of rows of data (more than 300k), the code will be collapsed at about 10k...

My question is, if anyone has the same experience? Can I make the LabTalk-Script somehow more efficient?

My Laptop has i7 CPU, 8G memory, HDD. But obviously I wouldn't buy a new one only for solving this problem.

Thanks a lot in advance to the community!

Best regards
Howie


LabTalk ist eine Quälerei. --- J. S. Bach

yuki_wu

896 Posts

Posted - 10/09/2018 :  10:55:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Howie,

Using wxt X-Function (menu: Worksheet: Worksheet Query) will be faster:
wxt test:="col(A)==col(B)" ow:=<new>;

https://www.originlab.com/doc/X-Function/ref/wxt
https://www.originlab.com/doc/Origin-Help/Wks-Query

Hope it helps.

Regards,
Yuki
OriginLab
Go to Top of Page

hawu001

5 Posts

Posted - 10/10/2018 :  06:53:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Yuki,

thanks for your hints, but in the if sentence, I have to compare two columns with different length (40 and 80, as shown in the graph).

That's also why I used i and j.

Would wxt still work?


quote:
Originally posted by yuki_wu

Hi Howie,

Using wxt X-Function (menu: Worksheet: Worksheet Query) will be faster:
wxt test:="col(A)==col(B)" ow:=<new>;

https://www.originlab.com/doc/X-Function/ref/wxt
https://www.originlab.com/doc/Origin-Help/Wks-Query

Hope it helps.

Regards,
Yuki
OriginLab




LabTalk ist eine Quälerei. --- J. S. Bach
Go to Top of Page

hawu001

5 Posts

Posted - 10/10/2018 :  06:56:38 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply




quote:
Originally posted by yuki_wu

Hi Howie,

Using wxt X-Function (menu: Worksheet: Worksheet Query) will be faster:
wxt test:="col(A)==col(B)" ow:=<new>;

https://www.originlab.com/doc/X-Function/ref/wxt
https://www.originlab.com/doc/Origin-Help/Wks-Query

Hope it helps.

Regards,
Yuki
OriginLab


LabTalk ist eine Quälerei. --- J. S. Bach
Go to Top of Page

hawu001

5 Posts

Posted - 10/10/2018 :  06:59:00 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

quote:
Originally posted by yuki_wu

Hi Howie,

Using wxt X-Function (menu: Worksheet: Worksheet Query) will be faster:
wxt test:="col(A)==col(B)" ow:=<new>;

https://www.originlab.com/doc/X-Function/ref/wxt
https://www.originlab.com/doc/Origin-Help/Wks-Query

Hope it helps.

Regards,
Yuki
OriginLab



This is what I actually want to get:


LabTalk ist eine Quälerei. --- J. S. Bach
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 10/10/2018 :  9:21:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Just put column formula into col(D) as


table(B,C,A)





Most things can be done with column formula and then you just save the book as template, and write only the smallest amount of code.

CP

CP
Go to Top of Page

hawu001

5 Posts

Posted - 10/30/2018 :  06:41:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi CP,

thank you a lot!! It's really much easier and more effectiver!

Best Regards,
Howie

quote:
Originally posted by cpyang

Just put column formula into col(D) as


table(B,C,A)





Most things can be done with column formula and then you just save the book as template, and write only the smallest amount of code.

CP

CP




LabTalk ist eine Quälerei. --- J. S. Bach
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