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
 Origin Forum
 adjust columns
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2 Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ungat

Belgium
Posts

Posted - 11/08/2005 :  08:58:37 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System:Win XP

Hello everybody,

I have a problem with adjust columns when I import data:

I have to import 3 data with 2 columns (x,y) each other in one datasheet(x,y1,y2,y3), the 3 data have the same column x but not the same column y; one column y begin at x=a, one at x=b and the other at x=c but I want they begin each other at x=a=2,375 and fill by zero the empty cells in other y columns:

eaxample:
y1 y2 y3
2,375=a 0 0 3,96694E-6
2,425 0 0 2,07178E-4
2,475 0 0 0,00364
2,525 0 0 0,02779
2,575 0 0 0,11693
2,625 0 0 0,32308
2,675 0 0 0,66072
2,725=b 7,77778E-6 0 1,09083
2,775 6,33333E-5 0 1,55105
2,825 5,31111E-4 0 1,98904
2,875 0,00273 0 2,37846
2,925 0,01016 0 2,71199
2,975 0,029 0 2,99516
3,025 0,0658 0 3,23987
3,075 0,12723 0 3,4571
3,125 0,21817 0 3,65574
3,175 0,3379 0 3,84354
3,225 0,48842 0 4,02623
3,275 0,66422 0 4,20811
3,325 0,86412 0 4,39238
3,375 1,08686 0 4,58125
3,425=c 1,33101 1,04938E-5 4,77575
3,475 1,5992 4,19753E-5 4,9776
3,525 1,89598 1,28025E-4 5,18755

I hope you have understood and you'll help me

thank you very much.

Mike Buess

USA
3037 Posts

Posted - 11/09/2005 :  10:27:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sounds like you want to combine three worksheets (Data1, Data2 and Data3 below) with overlapping X ranges into a single worksheet (Data4) in which missing values are set to zero. If that's correct then copy the following script to your script window and execute by selecting all lines and pressing Enter. (You may need to change the names of the starting worksheets in the first 3 lines before you execute.) If you'll need to use the script more than once you can run it from the Custom Routine button as described here...
http://www.originlab.com/www/support/resultstech.aspx?ID=655&language=English

# Script start here
%R=Data1; // name of 1st wks
%S=Data2; // name of 2nd wks
%T=Data3; // name of 3rd wks
xinc=%(%R,1,2)-%(%R,1,1); // common X increment
tmp=%(%R,1);
copy -a %(%S,1) tmp;
copy -a %(%T,1) tmp;
sum(tmp);
del tmp;
win -t D;
col(1)=data(sum.min,sum.max,xinc);
wks.addCol();
wks.addCol();
set %H -er wks.maxrows;
ii=list(%(%R,1,1),col(1));
copy -b 1 %(%R,2) col(2) -b ii -t %R!wks.maxrows;
ii=list(%(%S,1,1),col(1));
copy -b 1 %(%S,2) col(3) -b ii -t %S!wks.maxrows;
ii=list(%(%T,1,1),col(1));
copy -b 1 %(%T,2) col(4) -b ii -t %T!wks.maxrows;
loop (ii,2,4) {
wcol(ii) = wcol(ii)==0/0 ? 0 : wcol(ii);
};





Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/09/2005 :  1:57:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

Sounds like you want to combine three worksheets (Data1, Data2 and Data3 below) with overlapping X ranges into a single worksheet (Data4) in which missing values are set to zero. If that's correct then copy the following script to your script window and execute by selecting all lines and pressing Enter. (You may need to change the names of the starting worksheets in the first 3 lines before you execute.) If you'll need to use the script more than once you can run it from the Custom Routine button as described here...
http://www.originlab.com/www/support/resultstech.aspx?ID=655&language=English

# Script start here
%R=Data1; // name of 1st wks
%S=Data2; // name of 2nd wks
%T=Data3; // name of 3rd wks
xinc=%(%R,1,2)-%(%R,1,1); // common X increment
tmp=%(%R,1);
copy -a %(%S,1) tmp;
copy -a %(%T,1) tmp;
sum(tmp);
del tmp;
win -t D;
col(1)=data(sum.min,sum.max,xinc);
wks.addCol();
wks.addCol();
set %H -er wks.maxrows;
ii=list(%(%R,1,1),col(1));
copy -b 1 %(%R,2) col(2) -b ii -t %R!wks.maxrows;
ii=list(%(%S,1,1),col(1));
copy -b 1 %(%S,2) col(3) -b ii -t %S!wks.maxrows;
ii=list(%(%T,1,1),col(1));
copy -b 1 %(%T,2) col(4) -b ii -t %T!wks.maxrows;
loop (ii,2,4) {
wcol(ii) = wcol(ii)==0/0 ? 0 : wcol(ii);
};





Mike Buess
Origin WebRing Member



Thank you very much Mike Buess, that's exact you have understood what I want but your script doesn't work. It gives me this result:



thank you again
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/09/2005 :  2:10:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much Mike Buess, that's exact you have understood what I want but your script doesn't work. It gives me this result:

2,375 1,86667E-6 1,06193E-6 2,24999E-6
2,425 1,70667E-5 2,12385E-6 1,54125E-4
2,475 8,45333E-5 1,23891E-5 0,00273
2,525 3,17333E-4 5,6813E-5 0,02149
2,575 9,19644E-4 1,6159E-4 0,09229
2,625 0,00235 4,2477E-4 0,25856
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/09/2005 :  3:06:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Looks like it has to do with the fact that your separator, or decimal point, is comma rather than period. I get the same results as you when I change my separator to comma (Tools > Options > Numeric Format > Separators = 1 000,0). You can test it out by setting your separator to 1 000.0 but that is not an acceptable permanent solution, of course.

Apparently the list() function fails for comma separators. I'll come up with a workaround shortly.

...It's the %(wksName,col#,row#) syntax that has problems with comma separators. List() function works fine. Try this...

%R=Data1; // name of 1st wks
%S=Data2; // name of 2nd wks
%T=Data3; // name of 3rd wks
xinc=%R!cell(2,1)-%R!cell(1,1); // common X increment
tmp=%(%R,1);
copy -a %(%S,1) tmp;
copy -a %(%T,1) tmp;
sum(tmp);
del tmp;
win -t D;
col(1)=data(sum.min,sum.max,xinc);
wks.addCol();
wks.addCol();
set %H -er wks.maxrows;
ii=list(%R!cell(1,1),col(1));
copy -b 1 %(%R,2) col(2) -b ii -t %R!wks.maxrows;
ii=list(%S!cell(1,1),col(1));
copy -b 1 %(%S,2) col(3) -b ii -t %S!wks.maxrows;
ii=list(%T!cell(1,1),col(1));
copy -b 1 %(%T,2) col(4) -b ii -t %T!wks.maxrows;
loop (ii,2,4) {
wcol(ii) = wcol(ii)==0/0 ? 0 : wcol(ii);
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/09/2005 3:26:08 PM
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/10/2005 :  11:28:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Mike Buess, thank you very much, now that's work;

but could you please change this script so that it prompt me the three worksheets (Data1, Data2 and Data3) to import (open) because it take time to open and use then your sript.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/10/2005 :  12:57:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Replace the first three lines of current script with this...

if(%R=="") %R=Data1;
if(%S=="") %S=Data2;
if(%T=="") %T=Data3;
getn (First wks) %%R
(Second wks) %%S
(Third wks) %%T
(Enter worksheet names);
if( !exist(%R,2) || !exist(%S,2) || !exist(%T,2) )
{
type -b One or more worksheets do not exist;
return;
};

An OriginC solution is better for the more general problem of combining an arbitrary number (two or more) of worksheets...

1. Open CodeBuilder and select File > New.
2. Select C File on the list at left.
3. Check the Add to Workspace and Fill with Default Contents options.
4. Enter a filename and path, then click OK.
5. Scroll to the bottom of your new file, enter a new line and paste the functions below to the file.
6. Select Tools > Rebuild All to compile.
7. Close CodeBuilder and execute the wks_combine() function from the script window. It takes a comma-separated list of two or more worksheet names for its argument...

wks_combine "Data1,Data2,Data3";

Note that the list must be quoted.
// Origin C functions start here
void wks_combine(string sList)
{
StringArray sa;
sList.GetTokens(sa,',');
if( sa.GetSize()<2 )
return;
Dataset dx,tmp;
Worksheet wks;
double dInc;
for(int i=0; i<sa.GetSize(); i++)
{
wks.Attach(sa[i]);
if( !wks ) return;
dx.Attach(wks,0);
if( i )
tmp.Append(dx);
else
{
dInc = dx[1] - dx[0];
tmp.Create(dx.GetSize());
tmp = dx;
}
}
Worksheet wksNew;
wksNew.Create("Origin");
dx.Attach(wksNew,0);
dx.Data(min(tmp), max(tmp), dInc);
wksNew.SetSize(dx.GetSize(), sa.GetSize() + 1);
for(i=1; i<=sa.GetSize(); i++)
{
if( wks_copy(wksNew,i,sa[i-1]) )
break;
}
}

int wks_copy(Worksheet wDest, int iCol, string sSrc)
{
Dataset dxSrc(sSrc,0);
Dataset dySrc(sSrc,1);
if( !dxSrc || !dySrc )
return 1;
Dataset dxDest(wDest,0);
Dataset dyDest(wDest,iCol);
dyDest.SetSize(dxDest.GetSize());
dyDest = 0;
Data_copy(&dyDest,&dySrc,0,dySrc.GetSize() - 1,Data_list(dxSrc[0],&dxDest));
return 0;
}


Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/10/2005 :  1:20:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok thank you very much Mike Buess
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/13/2005 :  2:29:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

[/quote]

Hello, excuse me for disturbing you again, but there is an error in compiling the file; the error message is folloving:

compiling...
essai1.c
D:\Origin\essai1.c(53) :Error, Member function Worksheet::SetSize not defined or does not have matching prototype.
D:\Origin\essai1.c(26) :Error, error(s) found in compiling method
D:\Origin\essai1.c(53) :Error, general compile error
D:\Origin\essai1.c(26) :Error, error(s) found in compiling function wks_combine

Compiling errors found, linking cannot start!

the file is folloving:

/*------------------------------------------------------------------------------*
* File Name:essai1 *
* Creation: 13.11.2005 *
* Purpose: OriginC Source C file *
* Copyright (c) ABCD Corp. 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 *
* All Rights Reserved *
* *
* Modification Log: *
*------------------------------------------------------------------------------*/

////////////////////////////////////////////////////////////////////////////////////
// Including the system header file Origin.h should be sufficient for most Origin
// applications and is recommended. Origin.h includes many of the most common system
// header files and is automatically pre-compiled when Origin runs the first time.
// Programs including Origin.h subsequently compile much more quickly as long as
// the size and number of other included header files is minimized. All NAG header
// files are now included in Origin.h and no longer need be separately included.
//
// Right-click on the line below and select 'Open "Origin.h"' to open the Origin.h
// system header file.
#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// Start your functions here.
// Origin C functions start here
void wks_combine(string sList)
{
StringArray sa;
sList.GetTokens(sa,',');
if( sa.GetSize()<2 )
return;
Dataset dx,tmp;
Worksheet wks;
double dInc;
for(int i=0; i<sa.GetSize(); i++)
{
wks.Attach(sa[i]);
if( !wks ) return;
dx.Attach(wks,0);
if( i )
tmp.Append(dx);
else
{
dInc = dx[1] - dx[0];
tmp.Create(dx.GetSize());
tmp = dx;
}
}
Worksheet wksNew;
wksNew.Create("Origin");
dx.Attach(wksNew,0);
dx.Data(min(tmp), max(tmp), dInc);
wksNew.SetSize(dx.GetSize(), sa.GetSize() + 1);
for(i=1; i<=sa.GetSize(); i++)
{
if( wks_copy(wksNew,i,sa[i-1]) )
break;
}
}
int wks_copy(Worksheet wDest, int iCol, string sSrc)
{
Dataset dxSrc(sSrc,0);
Dataset dySrc(sSrc,1);
if( !dxSrc || !dySrc )
return 1;
Dataset dxDest(wDest,0);
Dataset dyDest(wDest,iCol);
dyDest.SetSize(dxDest.GetSize());
dyDest = 0;
Data_copy(&dyDest,&dySrc,0,dySrc.GetSize() - 1,Data_list(dxSrc[0],&dxDest));
return 0;
}

==================================================================

I have an other problem, how do you rename an imported worksheet and how do you rename the columns of this worksheet ? I would like rename the worksheet and its columns with a window script.

Thank you again.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/13/2005 :  2:47:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I suspect that you need to apply the SR5 patch to get rid of the compiler error...
http://www.originlab.com/index.aspx?s=9&lm=76

This will rename the active window to newName...
win -r %H newName;

Either of the following commands will rename column i to newName...
wo -n i newName;
wks.col$(i).name$=newName;

Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/13/2005 :  3:03:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok thank you very much, I have a last question: how do you rename Column Label ?

quote:

Hi,

I suspect that you need to apply the SR5 patch to get rid of the compiler error...
http://www.originlab.com/index.aspx?s=9&lm=76

This will rename the active window to newName...
win -r %H newName;

Either of the following commands will rename column i to newName...
wo -n i newName;
wks.col$(i).name$=newName;

Mike Buess
Origin WebRing Member

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/13/2005 :  3:09:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This changes the label for column i to newLabel...

wks.col$(i).label$=newLabel;

Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/13/2005 :  3:53:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Excuse me I said it is the last question, but I have another one;

how do you import 3 or more data files at one time ?
Now for import 3 data I use this sript window:
--------------------------------------------------------------------
run.section(Standard,NewWks);
getfile *.*;
open -w %b%a;
%v=%h;
ncols=%v!wks.ncols;
%v!wks.col1.name$=Abs;
for(i=1;i<=ncols-1;i+=1)
{
create %v_b$(i) 300;
edit %v_b$(i);
copy col($(i+1)) %v_b$(i);
};
copy col(1) %v_a;
for(i=1;i<=ncols;i+=1)
{
delete col(1);
};
run.section(Standard,NewWks);
getfile *.*;
open -w %b%a;
%v=%h;
ncols=%v!wks.ncols;
%v!wks.col1.name$=Abs;
for(i=1;i<=ncols-1;i+=1)
{
create %v_b$(i) 300;
edit %v_b$(i);
copy col($(i+1)) %v_b$(i);
};
copy col(1) %v_a;
for(i=1;i<=ncols;i+=1)
{
delete col(1);
};
run.section(Standard,NewWks);
getfile *.*;
open -w %b%a;
%v=%h;
ncols=%v!wks.ncols;
%v!wks.col1.name$=Abs;
for(i=1;i<=ncols-1;i+=1)
{
create %v_b$(i) 300;
edit %v_b$(i);
copy col($(i+1)) %v_b$(i);
};
copy col(1) %v_a;
for(i=1;i<=ncols;i+=1)
{
delete col(1);
};
--------------------------------------------------------------------

But it takes more time to import one per one; I would like to select the 3 files and import them at one time.

Thank you very much.
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/14/2005 :  11:12:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Excuse me Mike Buess, it's me again;

how do you rename files you imported with this script:

%B=D:\Directory\; // directory
%F=AA BB CC; // file list (space separated)
for(ii=1;ii>0;ii++) {
%A=%[%F,#ii]; // get next file name
if(%A=="") break;
win -t D;
open -w %B%A;
};


I would rename AA,BB and CC and their columns after importation

Thank you.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/14/2005 :  11:34:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It's unclear to me whether you want to name the worksheets with the file name or change the names to something else. Following script renames the wks window after the file name and names and labels 3 columns. If you want to change the wks name to something else use win -r %H newName in place of the win -r %H %A command. Note that all of this is much more easily handled by using a custom worksheet template with the proper ASCII Options.

%B=D:\Directory\; // directory
%F=AA BB CC; // file list (space separated)
for(ii=1;ii>0;ii++) {
%A=%[%F,#ii]; // get next file name
if(%A=="") break;
win -t D;
open -w %B%A;
win -r %H %A; // rename wks window to file name (%A)
wks.col1.name$=Column 1 name; // supply your own names
wks.col2.name$=Column 2 name;
wks.col3.name$=Column 3 name;
// more columns?
wks.col1.label$=Column 1 label; // supply your own labels
wks.col2.label$=Column 2 label;
wks.col3.label$=Column 3 label;
// more columns?
wks.labels(); // show column labels
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/14/2005 12:02:27 PM
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/14/2005 :  12:31:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok, thank you very much;

how do you plot the column C of a wks ?

I have a worksheet named Data1 with 10 columns: A(X),B(Y),C(Y),....
and I would like to plot column C with script window you given me.

Thank you again.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/14/2005 :  12:41:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Add these lines after wks.labels()...

wo -s 3 0 3 0; // select column 3
wo -p 200; // plot as line (201=scatter, 202=line+symbol, etc)

Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/14/2005 :  12:49:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
ok, excuse me for disturbing you;

how do you plot in the same graph Column C of Data1, column C of data2 and Column C of Data3 ?

what does it mean "wo -s 3 0 3 0" ? what is 0 for ?
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/14/2005 :  1:10:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
worksheet -s c1 r1 c2 r2 selects the range of cells in the worksheet beginning with col c1, row r1 and ending with col c2, row r2. r1 = 0 and r2 = 0 means select entire columns. Similarly, wo -s 0 0 0 0 selects the entire worksheet.

Plotting all imported data in the same graph window requires a different approach...

%B=D:\Directory\; // directory
%F=AA BB CC; // file list (space separated)
win -t P; // create a graph window
%P=%H; // save its name as %P
for(ii=1;ii>0;ii++) {
%A=%[%F,#ii]; // get next file name
if(%A=="") break;
win -t D;
open -w %B%A;
win -r %H %A; // rename wks window to file name (%A)
wks.col1.name$=Column 1 name; // supply your own names
wks.col2.name$=Column 2 name;
wks.col3.name$=Column 3 name;
// more columns?
wks.col1.label$=Column 1 label; // supply your own labels
wks.col2.label$=Column 2 label;
wks.col3.label$=Column 3 label;
// more columns?
wks.labels(); // show column labels
%W=%H; // save wks name as %W
win -a %P; // activate graph window
layer -i200 %(%W,3); // plot %W col 3 as line (201=scatter, 202=line+symbol)
};
layer -a; // rescale to show all data
legend; // recreate legend

Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/14/2005 :  4:23:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok, thank you very much Mike Buess;

but I don't want plot the 3 imported files; I would plot columns of other worksheets which were obtained from the 3 imported files.
In general case, how do you plot in the same graph column B of Data1, column C of Data2,..., column Z of DataN ?
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/14/2005 :  4:38:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The general syntax for plotting a dataset in the active graph layer is layer -i# dataset, where # is the graph type number (200=line, 201=scatter, etc.) and dataset is %(wksName,colNumber) or wksName_colName...

win -t P; // create graph window
layer -i200 Data1_B; // plot Data1, col B as line
layer -i200 Data2_C; // plot Data2, col C
layer -i200 DataN_Z; // plot DataN, col Z

Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/14/2005 :  4:50:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok thank you very much!
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/14/2005 :  5:01:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Excuse me again,

it's ok, but how do you group data in Layer Contents ?
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/14/2005 :  5:23:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
layer -g;

Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/15/2005 :  08:31:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

1) I have 10 worksheets Data1, Data2,...,Data10
and I would like to create a newData called "Moy" which will obtained so:

Moy_A(X) = Data1_A = Data2_A =...= Data10_A

Moy_B(Y) = (Data1_B + Data2_B +...+ Data10_B)/10

2) How do you rename a graph ?

Thank you again.
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/15/2005 :  08:34:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Excuse me, I have forgotten to ask you how do you reduce all worksheets in Origin Project with a script window ?

Thank you.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/15/2005 :  10:19:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
1)
win -a Data1; // activate Data1
win -d; // duplicate
doc -e W {%W=%H};
win -r %W Moy; // change name to Moy
loop (ii,2,10) {Moy_B += Data$(ii)_B};
Moy_B /= 10;
win -a Moy;

2) Same as worksheet: win -r %H newName.

quote:
how do you reduce all worksheets in Origin Project with a script window ?

Assuming "reduce" means to add col B from all worksheets as in 1)...

%A=%H;
win -d;
doc -e W {%W=%H};
win -r %W Moy;
nn=1;
doc -e W {
if(%H!="Moy" && "%A!="%H") {
Moy_B += %H_B;
n++;
};
};
Moy_B /= nn;
win -a Moy;

Mike Buess
Origin WebRing Member
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/15/2005 :  12:56:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Excuse me, in fact, my worksheets don't called Data1,Data2,...,Data10
it's AB, CE, MN,... it is not regular names;

I would like to create a newData with 2 columns: A(X) and B(Y)

with newData_A = AB_A = CE_A ...
newData_B = (AB_J + CE_J +...+ ZX_J)/n

By Reduce worksheets I mean lower worksheets size to minimum (icon) and arrange icons.

Thank you.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/15/2005 :  1:17:15 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
%Z=AB CE MN; // list wks names separated by spaces
%R=newData; // name for new wks
win -a %[%Z,#1]; // activate 1st wks
win -d; // duplicate
doc -e W {%W=%H};
win -r %W %R; // change its name
nn=1;
for(ii=2;ii>0;ii++) {
%A=%[%Z,#ii];
if(%A=="") break;
%R_B += %A_J;
nn++;
};
%R_B /= nn; // normalize by wks count
win -a %R; // activate new wks


This will minimize all worksheets and arrange icons...

doc -e W {win -i};
menu -e 57649;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/15/2005 1:18:25 PM
Go to Top of Page

ungat

Belgium
Posts

Posted - 11/15/2005 :  2:07:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
[quote]
%Z=AB CE MN; // list wks names separated by spaces
%R=newData; // name for new wks
win -a %[%Z,#1]; // activate 1st wks
win -d; // duplicate
doc -e W {%W=%H};
win -r %W %R; // change its name
nn=1;
for(ii=2;ii>0;ii++) {
%A=%[%Z,#ii];
if(%A=="") break;
%R_B += %A_J;
nn++;
};
%R_B /= nn; // normalize by wks count
win -a %R; // activate new wks

Excuse me again;

in fact I want newData_B = (AB_AB + CE_CE +...+ ZX_ZX)/n

the columns which must be added have the same name that the corresponding whorksheets.

Thank you very much.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/15/2005 :  2:22:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Change the command %R_B += %A_J to %R_B += %A_%A.

Mike Buess
Origin WebRing Member
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic   Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000