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