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
 Rename 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

surjpanj

Canada
18 Posts

Posted - 03/01/2016 :  03:31:49 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2015
Operating System: Win 7

Hi,

I want to write script for renaming worksheets in particular workbook. For example, I have 14 worksheets that I want to name as 0, 3, 6, 9,......

I tried following script but it doesn't work
ii=0;
doc -ef LW{
wks.name$ = ii*3;
ii++;}

Similar, I want to rename graphs, i.e., instead of Graph1, Graph2, Graph3,etc...I would like to have G0, G3, G9, etc...
Any ideas how to make this work?

Thanks,
Matt

jasonzhao

China
262 Posts

Posted - 03/01/2016 :  04:25:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

To renaming worksheets in current book, please run script below:

ii=0;
doc -ef LW{
wks.name$ = $(ii*3);
ii++;}


if you want to rename all graph window with G0,3.., you can use script below:

doc -e p
{
strn$=$(ii*3);
str$="G"+strn$;
win -r %H %(str$);
ii++;
}



Best regards!
Jason
OriginLab Technical Service
Go to Top of Page

surjpanj

Canada
18 Posts

Posted - 03/01/2016 :  04:47:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Great, it works!
I should have remembered to put in the $ sign.

Thanks,
Matt
Go to Top of Page

surjpanj

Canada
18 Posts

Posted - 03/01/2016 :  04:59:00 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hey Jason,

I have little problem with renaming graphs. The script renames all graphs in the project. I want to rename only graphs in one subdirectory.

Matt
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 03/01/2016 :  09:45:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Matt,

You can use Doc -ef command instead of Doc -e command to loop over limited within
the current folder:
http://www.originlab.com/doc/LabTalk/ref/Document-cmd#-ef.3B_Execute_the_given_script_for_all_objects_in_the_current_folder

To change the current folder to other location, you can use pe_cd x-function to navigate:
http://www.originlab.com/doc/X-Function/ref/pe_cd

Hope this helps.

--Hideo Fujii
OriginLab
Go to Top of Page

surjpanj

Canada
18 Posts

Posted - 03/23/2016 :  07:47:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jason and Hideo,

the script only renames short name of graphs. How can I make the same for the long name?

Thanks,
Matt
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 03/28/2016 :  10:04:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Matt,

To access the longname of the window, you can use the page.longname$ object property like:
ii=0;
doc -e P{
  ii++;
  %H!page.longname$=G$(ii*3);  //%H holds current window name
}
See the details at:
http://www.originlab.com/doc/LabTalk/ref/Page-obj

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 03/28/2016 10:11:16 AM
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