Author |
Topic |
|
SvenP
29 Posts |
Posted - 09/17/2009 : 06:41:47 AM
|
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
|
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=;
|
|
|
SvenP
29 Posts |
Posted - 10/05/2009 : 09:22:06 AM
|
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 |
|
|
greg
USA
1378 Posts |
Posted - 10/12/2009 : 09:51:32 AM
|
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; }
|
|
|
|
Topic |
|
|
|