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
 Workbook Shortcuts in Folders
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cdrozdowski111

USA
247 Posts

Posted - 02/08/2013 :  8:55:22 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 9.0.0 SR1, Win7 64-bit, running in VMware Fusion 5.0.2

Is there any way to get the "doc -ef W" command to recognize workbook shortcuts in a given folder so that I can have access to the original workbook that the shortcut points to from with the doc loop?

Is there an alternate to the doc command to do what I wish?

Penn

China
644 Posts

Posted - 02/20/2013 :  05:01:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Maybe you can first use Origin C to get the workbooks which are shortcuts in the current folder, and then handle these workbooks in LabTalk. Here is the sample code.

1. Origin C code, which is used to get the all shortcut workbook names into a string.

void get_shortcut_books_in_current_folder(string& strShortcuts)
{
    Folder fd = Project.ActiveFolder();  // active folder
    if(!fd)
    	return;
    vector<string> vsAllBooks, vsBooksNotShortcut;
    
    // get all books
    int nAllBooks = get_folder_pages_name(fd, vsAllBooks, EXIST_WKS, false, -1, true); 
    
    // get non-shortcut books
    int nBooksNotShortcut = get_folder_pages_name(fd, vsBooksNotShortcut, EXIST_WKS, false, -1, false);
    
    if(nBooksNotShortcut > 0)  // if there are non-shortcut books, remove them
    {
    	for(int ii = 0; ii < vsBooksNotShortcut.GetSize(); ii++)
    	{
    		int nIdx = vsAllBooks.Find(vsBooksNotShortcut[ii]);
    		if(nIdx != -1)
    			vsAllBooks.RemoveAt(nIdx);
    	}
    }
    
    // put the shortcut book names into a string, separated by |, return by reference
	strShortcuts.SetTokens(vsAllBooks, '|');
}

2. With the shortcut workbook names string, we can handle the corresponding workbooks one by one. The sample LabTalk script is

string strShortcuts$;
get_shortcut_books_in_current_folder(strShortcuts$);  // get the shortcut workbooks
int iTokens = strShortcuts.GetNumTokens('|');  // number of workbooks
string strCurrent$ = %H;  // get the current window name
for(int ii = 1; ii <= iTokens; ii++)  // handle the workbooks one by one
{
	string strBook$ = strShortcuts.GetToken(ii, '|')$;  // get workbook name
	win -a %(strBook$);  // activate workbook
	
	// your handle script can be here
	strBook$ = ;
}
win -a %(strCurrent$);  // restore the current window


Penn
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 02/20/2013 :  06:55:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks,

Going on your example, I was able to write an Origin C function very quickly to get exactly what I need. I just needed a nudge in the right direction.

Maybe y'all can extend "doc -ef W" functionality to include an option for including shortcuts along with the other files.
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