关闭所有期刊,但有一个例外我正在寻找一行脚本代码,允许我关闭除一个窗口之外的所有打开的日志。
实际上,提取正确的名称列表不起作用。然后无法将其与应该保持打开的日记名称相匹配。 见下文脚本***。
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