關閉所有期刊,但有一個例外我正在尋找一行腳本代碼,允許我關閉除一個窗口之外的所有打開的日誌。
實際上,提取正確的名稱列表不起作用。然後無法將其與應該保持打開的日記名稱相匹配。 見下文腳本***。
CloseAllJournalsExcept = Function( {},
JournalName = "StaysOpen";
For( i = N Items( Window() ), i > 0, i--,
If( Window( i ) << GetName != JournalName, //***
Window( i ) << close window()
)
);
);
謝謝。
回复:關閉所有期刊,但有一個例外
使用的findAll(期刊) 製作期刊清單,並使用 LOC() 幫助從列表中刪除守護者。然後發送關閉窗口命令到列表。下面,鎖定的圖標被附加到每個日誌以告訴JMP“這個日誌被鎖定,下次創建另一個日誌,而不是添加到這個日誌”。否則就很難製作一堆期刊。期刊也有標記使用setDirty(0) 因此關閉它們時沒有提示。你可能不希望那個你保持開放的那個。
myJrns = {};
For( i = 1, i <= 5, i += 1,
w = New Window( Char( i ), V List Box( Text Box( Char( i ) ) ) );
j = w << journalwindow;
w << closewindow;
j[Text Box( 1 )] << sibAppend( Icon Box( "Locked" ) ); // locked: just to make a new window each time
Insert Into( myJrns, j );
);
myJrns << setDirty( 0 ); // these were just created, make it easy to close them
// get a list of all open journals
alljournals = Find All( Journals );
// close all but the 2nd one just created...
// myJrns[...] is the list of journals just created
// myJrns[2] is the 2nd one that we decide to keep
// the allJournals list might be in a different order, so
// use loc() to find the matching index in allJournals
keeper = Loc( alljournals, myJrns[2] ); // returns a matrix
keeper = keeper[1]; // was a matrix of one element, now a scalar
// modify the allJournals list so we can close all of its items
Remove From( allJournals, keeper ); // remove the keeper from the list
allJournals << closewindow; // closes all the journals that remain in the list