Steven Morgan Posted October 23, 2023 Share Posted October 23, 2023 Seems easy enough but having some trouble. I have some Symbol inside of Symbol Folders in my current file that I want to build into Resource Lists. MasterFile.VWX (Current open document) Symbol folder 1 Symbol folder 2 Symbol folder 3 I have List1:=BuildResourceList(16,0,'Symbol Folder 1',NumItems); I have tried using a negative value for the folder index as well. Currently it just lists every single Symbol in my file and not the specified sub-folder. I see some Remarks that say BuildResourceList doesn't have the ability to find Symbols inside of Symbol Folders (only top level) but it looks like that was resolved in VWX 2020. Am I missing something here? Was hoping to avoid having to use BuildResourceListN2 with separate files for each folder, which I do have working. Quote Link to comment
Juliensv Posted October 23, 2023 Share Posted October 23, 2023 Hi Steven, I've never used BuildResourceList before, but another way you might go about this is to get all the symbols in the file in a list, then discriminate between them using GetParent, which should return the folder that symbol def is in. Quote Link to comment
MullinRJ Posted October 24, 2023 Share Posted October 24, 2023 (edited) Hi @stevenmorgan94, @Juliensv's method is a sound way to go, but as in all things Vectorscript, there are multiple ways to get to the same place. As luck would have it, I was playing with AddResourceToList() this past weekend, so here are two more ways to get to where you want. The first subroutine, GetSymsInFldr1, uses a WHILE loop to step through the contents of your Symbol Folder. The second subroutine, GetSymsInFldr2, uses ForEachObjectInList() to do the same thing. They are identical in function and nearly identical in size. Use the one that's easiest for you to follow, or try your hand at Julian's method. To run this example, change the value of the constant kSymFldrName to match a Symbol Folder name in your file. PROCEDURE xxx; { Two example subroutines showing how to build a Resource List of Symbol Names in user specified SymFolder. } { 24 Oct 2023 - Raymond J Mullin } CONST kSymFldrName = 'Your Symbol Folder Name'; VAR List16, ListSize :Longint; Function GetSymsInFldr1(FldrNam :String; var NumItems :Longint) :Longint; { Return a Resource List of all SymDefs in symbol folder FldrNam, and return the list size in NumItems. } Const kSymDefType = 16; Var H :Handle; ListID, I :Longint; Begin ListID := BuildResourceListN(kSymDefType, '', NumItems); { empty list of Symbol Defs } H := FInFolder(GetObject(FldrNam)); { first obj in Sym Folder } while (H<>nil) do begin if (GetTypeN(H) = kSymDefType) then I := AddResourceToList(ListID, H); H := NextObj(H); end; { while } NumItems := ResourceListSize(ListID); GetSymsInFldr1 := ListID; End; { GetSymsInFldr1 } Function GetSymsInFldr2(FldrNam :String; var NumItems :Longint) :Longint; { Return a Resource List of all SymDefs in symbol folder FldrNam, and return the list size in NumItems. } Const kSymDefType = 16; Var ListID, I :Longint; Function AddSym2List(H :Handle) :Boolean; { Return a Resource List of all SymDefs in symbol folder FldrNam. } Begin if (GetTypeN(H) = kSymDefType) then I := AddResourceToList(ListID, H); End; { AddSym2List } Begin { GetSymsInFldr2 } ListID := BuildResourceListN(kSymDefType, '', NumItems); { empty list of Symbol Defs } ForEachObjectInList(AddSym2List, 0, 0, FInFolder(GetObject(FldrNam))); { All objects, Shallow } NumItems := ResourceListSize(ListID); GetSymsInFldr2 := ListID; End; { GetSymsInFldr2 } BEGIN { Call first subroutine example and show the results. } List16 := GetSymsInFldr1(kSymFldrName, ListSize); AlrtDialog(concat('List#: ', List16, ' — List Size: ', ListSize)); { Call second subroutine example and show the results. } List16 := GetSymsInFldr2(kSymFldrName, ListSize); AlrtDialog(concat('List#: ', List16, ' — List Size: ', ListSize)); END; Run(xxx); HTH, Raymond Edited October 25, 2023 by MullinRJ Make "I" a Longint, save a line. (line 16) 1 Quote Link to comment
Steven Morgan Posted October 24, 2023 Author Share Posted October 24, 2023 This is brilliant @MullinRJ, thanks as usual. Didn't even think about going to AddResourceToList route. Cheers 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.