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
 plots from several worksheets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Jarl

Sweden
5 Posts

Posted - 09/25/2001 :  08:48:41 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I have a problem to make a script for plotting from several worksheets. I have some
ascii files which I load with this script:

fdlog.usegroup(ASCII);
fdlog.multiopen();

loop(ii,1,FDlog.MultiOpen.Count)
{
Fdlog.Get(A, ii); //get the first selected filename
win -t data; //open a new worksheet
open -w %A; //import the first file into the worksheet
//run.section(,calculate);
//run.section(,createplot,%H);
}

Now I want to plot column 1 against column
n (n will be a input variable between 17 and 25) for all the worksheets.

thanx for any help /Jarl

CStorey

Canada
137 Posts

Posted - 09/25/2001 :  10:27:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jarl,

The first part of the script is good. Here's what I'd do:

[GraphIt]

win -t plot; /// Open a new graph window from custom template here;
%R=%H; /// Remember the Graph's Name
win -a Data1; /// Set current worksheet
%W=%H; /// Remember the Worksheet's Name

//Plot columns 17-25 for each worksheet

For(jkl=17; jkl<=25; jkl=jkl+1)
{
wks.col1.type=4; /// Set the 1st column to X-type. No other column to the right should be X type for this to work.
%U=%(%W,jkl);
run.section(, Plot, %R %U jkl jkl-17 200); /// Plot column as a line in layer1
// Alternately to plot with symbols
// run.section(, Plot, %R %U jkl jkl-17 201); /// Plot column with symbols in layer N
};
win -a %R;
Rescale;
legend;
Return;

//**********************************************************************************//
// Plotting Routine
// Inputs: %1=Plot name, %2=Wks column, %3=colour
// %4=destination layer, %5=symbol type
//**********************************************************************************//
[Plot]

#!type " -->Plotting (Gph=%1 + Column=%2 + C#=%3 + Line#=%4 + Type#=%5)";
win -o %1 {
layer -i%5 %2; //Add layer to graph
set %2 -c %3; //Colour of line + symbol (%5)
if(%4>=12) set %2 -d 2; //Doted lines after 12 colored ones,
if(%4>=24) set %2 -d 1; //then Dashed lines.
};
#!type " -->Plotting...Done!";
Return;
//**********************************************************************************//

Hope it helps. Let me know.


Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring
Go to Top of Page

Jarl

Sweden
5 Posts

Posted - 09/26/2001 :  02:56:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I added your script to my script, but I only got an empty graph ? Im probably using it in the wrong way.

[Main]
type -b $General.Userbutton;

fdlog.usegroup(ASCII);
fdlog.multiopen();

loop(ii,1,FDlog.MultiOpen.Count)
{
Fdlog.Get(A, ii); //get the first selected filename
win -t data; //open a new worksheet
open -w %A; //import the first file into the worksheet
}

run.section(,GraphIt);

//..... plotscript.......
}

/Jarl
Go to Top of Page

CStorey

Canada
137 Posts

Posted - 09/26/2001 :  11:39:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I had left a few loose ends in your script. Here's a tidier version.

[Main]
type.redirection=1; /// Redirect "type" commands to Script Window
system.debug=1; /// Display errors

win -t plot Jarl1; /// Open a new graph window from custom template here;
%R=%H; /// Remember the Graph's Name

FDLog.DlgName$="Select Files to plot.";
FDLog.ShowComment=0;
//FDLog.path$="";
FDLog.multiOpen.sort=0;
FDLog.usegroup(ASCII);

If(FDLog.MultiOpen()!=0/0)
{
Loop(ii,1,FDLog.MultiOpen.Count)
{
win -t data wks$(ii); /// open a new worksheet
FDLog.Get(A, ii); //Get next fileName
open -w %A; /// import the first file into the worksheet
%W=%H; /// Remember the Worksheet's Name
#!type "$(ii)) %A, %W"; /// Show active Window Name
%W!wks.col1.type=4; /// Set the 1st column to X-type. No other column to the right should be X type for this to work.

////// Plot columns 17-25 for each worksheet /////

For(jkl=17; jkl<=25; jkl=jkl+1)
{
%U=%(%W,jkl); /// Identify column to plot
run.section(, Plot, %R %U jkl jkl-16 200); /// Plot column as a line in layer1
// Alternately to plot with symbols
// run.section(, Plot, %R %U jkl jkl-17 201); /// Plot column with symbols in layer N
};
};
};

win -a %R; Rescale; /// Rescale the plot.
Legend; /// Add a legend
Return;

//**********************************************************************************//
// Plotting Routine
// Inputs: %1=Plot name, %2=Wks column, %3=colour
// %4=destination layer, %5=symbol type
//**********************************************************************************//
[Plot]

#!type " -->Plotting (Gph=%1 + Column=%2 + C#=%3 + Line#=%4 + Type#=%5)";
win -o %1 {
layer -i%5 %2; //Add layer to graph
set %2 -c %3; //Colour of line + symbol (%5)
if(%4>=12) set %2 -d 2; //Doted lines after 12 colored ones,
if(%4>=24) set %2 -d 1; //then Dashed lines.
};
#!type " -->Plotting...Done!";
Return;
//**********************************************************************************//


Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring
Go to Top of Page

Jarl

Sweden
5 Posts

Posted - 09/27/2001 :  05:51:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanx for the support ! that worked very well !

Actually Id like to have 8 graph windows,
In each graph window one column plotted from each worksheet. So If I open two files Id have 2 plots in each of the 8 graph windows.
Ok Ill try to figure out that one myself.

But one thing I wonder about is when I add a button which is connected to a script it is highligted. But once I restart the program it is not highligted. The button is still there but I cant figure out how to "activate it" to run the script.

/Jarl
Go to Top of Page

CStorey

Canada
137 Posts

Posted - 09/27/2001 :  10:32:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Not sure what you mean about the button. Can you elaborate? Where is the button - toolbar, worksheet, graph? When you restart Origin? Need more info.

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring
Go to Top of Page

Jarl

Sweden
5 Posts

Posted - 09/28/2001 :  09:26:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
ok Its the button on the toolbar, I connected the script to a button by going to
view->toolbars->buttongroups->userdefined buttons and draged out my defined button. Now I can use it to run the script without any problems. But when I close all worksheets I cant use it, neither when I restart the whole program. The button is seen but not activated.
Go to Top of Page

CStorey

Canada
137 Posts

Posted - 09/28/2001 :  11:22:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jarl,

Buttons on the toolbar must be associated with some sort of object - wks, graph, layout, excel, etc... So in your case if you associate it with a wks, you will need to open a blank for the button to work. I've already suggested that Origin look at making buttons permanently associated with a script and they've agreed.
Good luck with your script and if you get stuck let me know.

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring
Go to Top of Page

Jarl

Sweden
5 Posts

Posted - 10/01/2001 :  07:14:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have been trying to get my script plot in multiple graph windows. I put the lines
win -t plot Jarl1
%R=%H
In the loop for each opened file. But that didnt work very well. Id like some hint how to open several graph windows, where 1st column is plotted agains the columns 17-25.
In first graph window column 1 versus 17 from all the files. 2nd graph window column 1 versus 18 and so on.

After I have defined a button, I close all the windos and then I cant use the button. I open a worksheet and now I can use it again like you said. But when I restart the program I cant use it even if I have a worksheet opened, so I have to redefine the button every time I start the program. Is that the way it should be ?

thanks for all the support ! /Jarl

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/01/2001 :  08:22:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
As far as the button goes you might try using the Custom Routine button on Origin's Standard toolbar. It is available for nearly all Origin child windows. Put your scripts in the [Main] section of Custom.ogs.

Mike Buess
Origin WebRing Member
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