Sam Jones Posted March 26, 2020 Share Posted March 26, 2020 Using VS can I create a resource folder inside another resource folder. Can I move a folder into another folder. SetParent() does not seem to work. Quote Link to comment
JBenghiat Posted March 26, 2020 Share Posted March 26, 2020 I would think SetParent() should work. You can also try InsertSymbolInFolder() Quote Link to comment
Pat Stanford Posted March 26, 2020 Share Posted March 26, 2020 How are you getting the Handle to your created resource folder? Are you sure the Handle you are passing to SetParent() is correct. Quote Link to comment
Sam Jones Posted March 26, 2020 Author Share Posted March 26, 2020 The script below fails when the parent exists and when the parent cable does not exist. It also fails using InsertSymbolInFolder(). Putting a BeginFolder inside a BeginFolder also fails. PROCEDURE PutFolderInFolder; VAR FolderName : STRING; FolderHdl : HANDLE; Folder2Hdl : HANDLE; ok : BOOLEAN; BEGIN FolderHdl := GetObject('AP Cable Folder'); IF FolderHdl = NIL THEN BEGIN NameObject('AP Cable Folder'); BeginFolder; EndFolder; FolderHdl := LNewObj; END; NameObject('Inside AP Cable Folder'); BeginFolder; EndFolder; Folder2Hdl := GetObject('Inside AP Cable Folder'); ok := SetParent(Folder2Hdl, FolderHdl); IF (NOT ok) THEN AlrtDialog('ok set parent is false'); {InsertSymbolInFolder(FolderHdl, Folder2Hdl);} END; RUN(PutFolderInFolder); Quote Link to comment
Sam Jones Posted March 26, 2020 Author Share Posted March 26, 2020 PS: Using Folder2Hdl := LNewObj instead of GetObject does not help. Quote Link to comment
JBenghiat Posted March 26, 2020 Share Posted March 26, 2020 SetParent() does work for placing resources in folders, but as you observe it fails for symbols. I suspect this is due to somewhat simplistic error checking; you can't place a record in a symbol folder, only a record folder, etc. I'm guessing you are restricted from placing a folder in a folder via script. I would file this as a bug, and if it's WAD have it moved to an enhancement request. Quote Link to comment
Sam Jones Posted March 26, 2020 Author Share Posted March 26, 2020 I'll end up just creating multiple folders with a similar prefix. Quote Link to comment
Pat Stanford Posted March 26, 2020 Share Posted March 26, 2020 I would expect nested BeginFolders to fail. The first folder would not yet exist when the nested one was trying to be created. LNewObj only works (as far as I know) on SOME objects that are actually visible in the drawing. I would not expect it to work on resources. Check out CreateFolderN in the function reference. Quote PROCEDURE PutFolderInFolder; VAR FolderName : STRING; FolderHdl : HANDLE; Folder2Hdl : HANDLE; ok : BOOLEAN; BEGIN FolderHdl := GetObject('AP Cable Folder'); IF FolderHdl = NIL THEN BEGIN NameObject('AP Cable Folder'); BeginFolderN(16); NameObject('Inside AP Cable Folder'); BeginFolderN(16); EndFolder; EndFolder; End; AlrtDialog(Concat(FolderHdl,' ',Folder2Hdl)); ok := SetParent(Folder2Hdl, FolderHdl); IF (NOT ok) THEN AlrtDialog('ok set parent is false'); {InsertSymbolInFolder(FolderHdl, Folder2Hdl);} END; RUN(PutFolderInFolder); Quote Link to comment
Sam Jones Posted March 26, 2020 Author Share Posted March 26, 2020 CreateFolderN creates symbol folders in the operating system not in the Resource Manager. Quote Link to comment
Pat Stanford Posted March 26, 2020 Share Posted March 26, 2020 Did you run the modification to the sample code I posted? I got folders in the Resource manager. Quote Link to comment
Sam Jones Posted March 27, 2020 Author Share Posted March 27, 2020 I didn't/don't see any code you posted. Quote Link to comment
Pat Stanford Posted March 27, 2020 Share Posted March 27, 2020 It was in the quote in my post above. I had my window set to narrow and could not see the Code block icon and assumed that they had updated the forum and removed it. Reposted here. This is a minor modification to your code that puts nested folders in for me. The 16 in the BeginFolderN specifies Symbol folders, but I think you can use most of the type codes for Definitions in the VS Appendix Object Type table that are listed as Definition. PROCEDURE PutFolderInFolder; VAR FolderName : STRING; FolderHdl : HANDLE; Folder2Hdl : HANDLE; ok : BOOLEAN; BEGIN FolderHdl := GetObject('AP Cable Folder'); IF FolderHdl = NIL THEN BEGIN NameObject('AP Cable Folder'); BeginFolderN(16); NameObject('Inside AP Cable Folder'); BeginFolderN(16); EndFolder; EndFolder; End; AlrtDialog(Concat(FolderHdl,' ',Folder2Hdl)); ok := SetParent(Folder2Hdl, FolderHdl); IF (NOT ok) THEN AlrtDialog('ok set parent is false'); {InsertSymbolInFolder(FolderHdl, Folder2Hdl);} END; RUN(PutFolderInFolder); Quote Link to comment
Sam Jones Posted March 27, 2020 Author Share Posted March 27, 2020 Success !! I did not understand the explanation of the BeginFolderN() command. I do now. Thanks. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.