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
 Question about script.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

SvenP

29 Posts

Posted - 09/17/2009 :  06:41:47 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 7.5 and Service Release 6
Operating System: WinXP

Hello.

Here

http://wiki.originlab.com/~originla/wiki/index.php?title=LabTalk:Flow_of_Control#If.2C_If-Else

at the If-section is an example script. "The next script finds the first point in column A that is greater than 100."
But how is that working. As I understand. Origin is looking in Col(A)[1] if the value is greater than 100. If not ii becomes 2 and the script stops.

I need a script which gives me the point of a column where a specific value is stored.
For example: "data1_data(-2,2,0.01);" Where is for instance -1.95?

I tried with for and if and also with loop an if, but it is not working.

p=0;
loop (l,1,401)
{
if (data1_a[l]=-1.95) p=l;
};
p=;

Thanks

greg

USA
1378 Posts

Posted - 09/17/2009 :  4:14:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for pointing out the bad script. Please check again for the updated version.

http://wiki.originlab.com/~originla/wiki/index.php?title=LabTalk:Flow_of_Control#If.2C_If-Else

Note that there is a problem with your script :
if (data1_a[l]=-1.95) p=l;
which should read :
if (data1_a[l]==-1.95) p=l;

Also, to take advantage of the break command to short circuit the loop, you should use :

loop (l,1,401)
{
if (data1_a[l] == -1.95) break;
}
l=;
Go to Top of Page

SvenP

29 Posts

Posted - 10/05/2009 :  09:22:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for your reply.

Now I have another simple question.
How can I access in a for-loop to columns named e.g. A1...A10.
For example that one is of course not working.

for (n=1;n<=10,n++){
data_a"n"[1]=1;
};

In this example in the first row of column A1 to A10 should be a 1.

Thanks
Go to Top of Page

greg

USA
1378 Posts

Posted - 10/12/2009 :  09:51:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use the colnum function in conjunction with the wcol function to get a column index from its name as in:

for(n = 1 ; n <= 10 ; n++)
{
wcol(colnum(A$(n)))[1] = n;
}
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