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 for Programming
 LabTalk Forum
 Workbook Shortcuts in Folders

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
cdrozdowski111 Posted - 02/08/2013 : 8:55:22 PM
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?
2   L A T E S T    R E P L I E S    (Newest First)
cdrozdowski111 Posted - 02/20/2013 : 06:55:43 AM
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.
Penn Posted - 02/20/2013 : 05:01:22 AM
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

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