檢查 JMP Live 空間中是否存在資料夾你好,
在 JMP18 中使用 JSL,我可以使用「建立資料夾」功能在我的個人空間和 JMP Live 上的其他空間中建立新資料夾。當我在個人空間中建立資料夾時,我可以使用 JSL 的「尋找資料夾」功能先列出所有現有資料夾,然後檢查我的新資料夾是否已存在。然後我可以透過 JSL 確保資料夾名稱唯一。
JMP Live 的預設行為是透過在資料夾名稱中新增「 (n) 」來建立唯一的資料夾名稱,其中「 n 」是同名資料夾的數量。但我想避免這種情況。
在其他 JMP Live 空間(不是我的個人空間)中,我觀察到相同的行為:相同的資料夾名稱會自動附加「 (n) 」。但是,「尋找資料夾」功能沒有空間鍵作為參數,因此我無法檢查非我個人空間的空間上已存在的資料夾。
我發現唯一接受空格鍵作為參數的函數是“創建資料夾”函數。我在這裡查看了相關的JSL幫助頁面,但沒有描述這種情況。
在 JMP Live 空間中提取現有資料夾的建議方法是什麼?或者我在這裡錯過了顯而易見的事情?
謝謝!
保羅
自動化和腳本編寫回覆:檢查 JMP Live 空間中是否存在資料夾我不熟悉 JMP Live,但您是否嘗試過增加查詢的頁面大小(或使用 Next() 呼叫)?腳本索引可能包含您在 JMP 說明頁面中找不到的一些範例

回覆:檢查 JMP Live 空間中是否存在資料夾謝謝賈莫,
不,我還沒有嘗試過這個。這是我的程式碼,非常適合檢查個人空間中的現有資料夾。
沒有包含確保唯一資料夾名稱的程式碼(為了簡單起見),但可以輕鬆建立。
正如我在帖子中所述: “查找資料夾”功能似乎沒有空格鍵,預設情況下在我的個人 JMP Live 空間中運行查詢。
我猜FindFolders中的 PageSize 參數可用於翻閱一長串資料夾(如果它們存在)。
// open the connection to JMP Live
liveConnection = New JMP Live( Connection( ) );
// get the user name from JMP Live
user = liveConnection << Get Username;
// get the existing folders already in my Space
getFolders = liveConnection << Find Folders( Publisher( user ) );
folderlist = getFolders << As Scriptable();
// Define the folder name you want to check or create
folderName = "new_folder_name";
// Define the space key of the Space you wish to create the folder in
spaceKey = "~"; // set key to "~" for your personal space or use the space key
// Initialize a variable to store the folder ID
folderID = .;
// Check if the folder exists. If it exists, folderID will contain the ID
// if the folder does not exist, folderID will contain a missing value
For( i = 1, i <= folderlist << Get Number Of Items, i += 1,
If( folderlist[i] << Get Title == folderName,
folderID = folderlist[i] << Get ID;
Show( folderID );
Break();
)
);
// If the folder does not exist, create it. folderID will contain the folder ID.
If( Is Missing( folderID ),
newFolder = liveConnection << Create Folder(
Space( spaceKey ), // Use "~" for personal space or specify the space key
Title( folderName ),
Description( "Automatically created folder." )
);
folderID = newFolder << As Scriptable;
folderID = folderID << Get ID;
);
回覆:檢查 JMP Live 空間中是否存在資料夾還有一點評論,如果我運行“查找資料夾”功能並手動檢查返回的列表,我可以看到我的個人空間中的每個資料夾都有一個列表條目。沒有其他條目(雖然我可以訪問帶有資料夾的其他空間)。
保羅
回覆:檢查 JMP Live 空間中是否存在資料夾您是否嘗試從“查找資料夾”中刪除此部分
Publisher( user )
回覆:檢查 JMP Live 空間中是否存在資料夾嗨,賈莫,
謝謝你的建議。原來是勝利者!
此程式碼(將搜尋功能作為參數新增至查找資料夾功能):
// open the connection to JMP Live
liveConnection = OpenJMPLiveConnection( );
foldername = "foldername";
// get the existing folders already in my Space
getFolders = liveConnection << Find Folders( Search( foldername ) );
folderlist = getFolders << As Scriptable();
Show(folderlist);
如果資料夾存在於我的個人空間之外,則傳回該資料夾的名稱、描述、ID 和 URL。
保羅