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
 All Forums
 Origin Forum
 Origin Forum
 Rename graphs after/during batch Analysis

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Matthias Mueller Posted - 11/18/2014 : 08:31:57 AM
Origin Ver. and Service Release (Select Help-->About Origin): 9.1
Operating System: Windows 7

Hi there,

I used an analysis template for a batch analysis (as described in the user guide 9.1). In my case the batch process does the following:

1) import X files
2) linear regression on the imported data
3) plot the data and the regression line

Each plot contains the imported data and an already existing data set in the analysis template, which is shown in all X plots.
The batch analysis produces X workbooks, each containing: the data, the linear fit results, the graph (in a worksheet).

Now here's my question: How can I change the (long or short) names of the graphs' workbook or worksheet? (not manually). I'd like to export all graphs and each file should have the same name as the workbook/name of the imported file. During my batch analysis the worksheet, which contains the graph, just gets the name "Graph1".

Is there a way to define the name in my batch analysis template (using e.g. "%(1@W, @W,SYSTEM.IMPORT.FILENAME$)", which I use to show the filename on the graph)?



Thanks for your help!

Matthias

EDIT: Please see the 2nd picture below: If I open a graph window, it is named "Graph2", but I want it to be named "T633" or "T_633", like the workbook, which contains the graph.



6   L A T E S T    R E P L I E S    (Newest First)
cdrozdowski111 Posted - 11/24/2014 : 06:42:29 AM
Matthias,

If you want to delve deeper into LabTalk scripting, I have found that the PDF version of the LabTalk User Guide (link below) to be quite helpful. While the same (and in fact more) information is found online, the PDF version presents the material in a more linear form like a book, good for gradual learning.

http://cloud.originlab.com/pdfs/Origin91_Documentation/English/LabTalk_Scripting_Guide_E.pdf
Matthias Mueller Posted - 11/24/2014 : 04:03:33 AM
@Jason Zhao

Hey Jason,
thanks for your reply! This scripts helps to rename the worksheets, but it does not rename the graph window of the embedded graph.

@cdrozdowski111

Hi,
thanks very much for your help. As far as I can judge it till now, this script does, what I was looking for. It renames the graph windows, and I don't have to rename them manually when I export the graphs.


Both your replies are a good starting point for me in Origin-scripting. Thanks!

Kind regards,

Matthias
cdrozdowski111 Posted - 11/21/2014 : 3:28:34 PM
Matthias,

By my understanding you wanted to rename not just the worksheet with the graph but the actual graph window so that when you export the graph, it will be the same name as the workbook long name and not just "Graph1", "Graph2", etc. Here is a method to do this (and more) automatically.

Open your Analysis Template. On your graph, select one of your Text Labels (e.g. the one you mention in your initial post) and right click to open the Programming Control dialog.

In the dialog:
1) Set the Substitution Level to 1.
2) Set Script, Run After to "Data Change"
3) Add below script

%J = %H;
%K = %(1@W, @PN);

The script sets the %J string register to the short name of the graph window (e.g. Graph1) and sets the %K string register to the short name of the workbook that contains the data for plot 1 of the graph. We will use those later.

Save your Analysis Template.

Now, open the Batch Process dialog. If you already have a Theme for your batch processing then good. If not, you'll need to create one and use it in the future.

At the bottom of the dialog, there is a text edit control labelled "Script after Each Process". Enter the following script in the control and save your dialog theme. It is documented in the comments.

// Make sure %J string register points to the graph window and %K points to the workbook
if ((exist(%J, 3) != 3) || (exist(%K, 2) != 2))
{
    // If not, dump error mesage to Message Log and stop script
    int nOld = type.redirection;
    type.redirection = 1024;
    type "Failed to change graph name in Analysis Template!";
    type.redirection = nOld;
    return;
}

// Get ranges for the graph, the workbook, and the worksheet containing the embedded graph
// based on the string registers.
// Embedded graph worksheet is 4 (see below). You might need to change that.
range rngGraph = [%J];
range rngBook = [%K];
range rngSheet = [%K]4;

// Set graph long name to workbook long name
rngGraph.longname$ = rngBook.longname$;

// Set worksheet long name to workbook long name. Note I prefixed it with  "Graph: "
rngSheet.longname$ = "Graph: %(rngBook.longname$)"; 

// Set column comments for embedded graph to workbook long name. Note I prefixed it with  "Graph: "
rngSheet.col1.comment$ = "Graph: %(rngBook.longname$)";

// Clear string registers
%J="";
%K="";


Now save your theme and give it a try!

You might want to do some additional testing of it with your data including importing multiple files at the same time. I don't have your data so my testing was based on simple data.
jasonzhao Posted - 11/21/2014 : 04:01:07 AM
Hello,

Please try this script which change the name of graph sheet follows the bookname. paste script in script window, select all, and click ENTER.


doc -e w       // loop through all book
{
page.active=4;  // active graph sheet(i.e. sheet4)

wks.name$ = %H;   // change name follows the book name
%H=;
}


Best regards,
Jason Zhao
OriginLab Tech Service
Matthias Mueller Posted - 11/20/2014 : 03:26:39 AM
Hi Jason,

thanks, I just sent my data.

Kind regards

Matthias
jasonzhao Posted - 11/20/2014 : 02:43:43 AM
Hello,

Would you like to send your analysis template and sample data to <tech@originlab.com>
so we can have a try.

Best regards,
Jason Zhao
OriginLab Tech Service

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000