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 for iwFilter to run Statistics and summary
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Skorab

Germany
4 Posts

Posted - 06/03/2022 :  11:50:24 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi there,

I want to import multiple ascii files via drag and drop and do some statics on them. Every file is imported as new a worksheet. The labtalk code for the iw filter is to calculate min and max values of some columns. The values then are displayed in a seperate worksheet as "summary". The scripts runs first for every imported file.

This is first time I am writing a labtalk code and its quite hard with the documentation So what my code does it creates a new worksheet and then long name and units are changed. But there are no values inside of worksheet overview. I am confused with the range objects. The error is that mathematics cannot be run on text ..

It would be really nice if you could help me out here.


range rcol2 = Col(2)
range rcol6 = Col(6)
range rcol9 = Col(9)

var_R2_min = stats.min rcol2;
var_R2_max = stats.max rcol2;
var_R4_min = stats.min rcol6;
var_R4_max = stats.max rcol6;
var_MR_max = stats.max rcol9;

newsheet name:=Overview cols:=6; 
range rOverview = Overview!
page.active$ = Overview;

if (col(6)[L]$ != maximaler MR Effekt)
	{col(1)[L]$ = Messung;
	col(2)[L]$ = minimaler R2 Widerstand;	
	col(2)[U]$ = Ohm;
	col(3)[L]$ = maximaler R2 Widerstand;
	col(3)[U]$ = Ohm;
	col(4)[L]$ = minimaler R4 Widerstand;
	col(4)[U]$ = Ohm;
	col(5)[U]$ = Ohm;
	col(5)[L]$ = maximaler R4 Widerstand;
	col(6)[L]$ = maximaler MR Effekt;
	col(6)[U]$ = %;}

range rcol2 = Col(2)
range rcol3 = Col(3)
range rcol4 = Col(4)
range rcol4 = Col(5)
range rcol4 = Col(6)

wks.col(2) = var_R2_min;
wks.col(3) = var_R2_max;
wks.col(4) = var_R4_min;
wks.col(5) = var_R4_max;
wks.col(6) = var_MR_max;



Best regards,

Clemens

YimingChen

1593 Posts

Posted - 06/03/2022 :  12:17:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The script to get stats of a column should be something like:

range rcol2 = Col(2);
stats rcol2;
var_R2_min = stats.min;
var_R2_min =;


James
Go to Top of Page

Skorab

Germany
4 Posts

Posted - 06/07/2022 :  03:22:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi James,


thank you very much for your answer.

I think you are right, I need to be more precise in calling x function of stats. So I wrote 2 functions to calculate the min and max value of the column range:


{
function double statsmin(range ra)
stats ra;
return stats.min;
}


{
stats ra;
return stats.max;
}

range rcol2 = Col(B);
range rcol6 = Col(F);
range rcol9 = Col(I);

var_R2_min = statsmin(rcol2);
var_R2_max = statsmax(rcol2);
var_R4_min = statsmin(rcol6);
var_R4_max = statsmax(rcol6);
var_MR_max = statsmax(rcol9);

newsheet name:=Overview cols:=6; 
range rOverview = Overview!
page.active$ = Overview;

if (col(6)[L]$ != maximaler MR Effekt)
	{col(1)[L]$ = Messung;
	col(2)[L]$ = minimaler R2 Widerstand;	
	col(2)[U]$ = Ohm;
	col(3)[L]$ = maximaler R2 Widerstand;
	col(3)[U]$ = Ohm;
	col(4)[L]$ = minimaler R4 Widerstand;
	col(4)[U]$ = Ohm;
	col(5)[U]$ = Ohm;
	col(5)[L]$ = maximaler R4 Widerstand;
	col(6)[L]$ = maximaler MR Effekt;
	col(6)[U]$ = %;}

var_R2_min = Col(B);
var_R2_max = Col(C);
var_R4_min = Col(D);
var_R4_max = Col(E);
var_MR_max = Col(F);


Now I get a new error code: assignment type mismatch, check declared type of LHS and result from RHS
I dont know what that means. I am still very confused and I am looking forward for your help
Go to Top of Page

YimingChen

1593 Posts

Posted - 06/07/2022 :  09:16:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Please double-check the code of function definition, it should be:


function double statsmin(range ra)
{
stats ra;
return stats.min;
}

function double statsmax(range ra)
{
stats ra;
return stats.max;
}
Go to Top of Page

Skorab

Germany
4 Posts

Posted - 06/07/2022 :  10:26:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Now I got rid of this if condition. I just make a new sheet named Overview before the import. Then I just importing with my filter and script. With the new code there is no error message but now my sheet "Overview" gets overriden with the imported files. But in the filter settings I told to create a new sheet for every imported file ...

Why is it so hard to make a simple calculation for every imported file and copy it into a another one??



function double statsmin(range ra)
{
stats ra;
return stats.min;
}

function double statsmax(range ra)
{
stats ra;
return stats.max;
}

range rcol2 = Col(B);
range rcol6 = Col(F);
range rcol9 = Col(I);

var_R2_min = statsmin(rcol2);
var_R2_max = statsmax(rcol2);
var_R4_min = statsmin(rcol6);
var_R4_max = statsmax(rcol6);
var_MR_max = statsmax(rcol9);

range rOverview = Overview!

var_R2_min = rOverview.Col(B);
var_R2_max = rOverview.Col(C);
var_R4_min = rOverview.Col(D);
var_R4_max = rOverview.Col(E);
var_MR_max = rOverview.Col(F);

Edited by - Skorab on 06/07/2022 10:27:45 AM
Go to Top of Page

YimingChen

1593 Posts

Posted - 06/07/2022 :  4:20:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you want to set values of a column to a value, you should use the script:

range rb = Overview!col(B);
rb = var_R2_min;


Go to Top of Page

Skorab

Germany
4 Posts

Posted - 06/08/2022 :  12:45:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

thank you very much for your replies. But it didnt work. So I do a workaround: I just make descriptive statistics just for max and min for every workbook and then I just copy and paste into a overview workbook. Topic can be cloesd.
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