Wizard12 Posted March 30, 2020 Share Posted March 30, 2020 Hi, I was wondering if anyone has come across a script that will Build a Resource List of the Symbol types in a document. I have tried to find examples to understand how to setup an array but have not been successful. I need this list do a comparison WHILE a symbol is being generated to see if the name already exists, once it does exist it will place the existing symbol instead of executing a creation procedure. Any scripting help would be appreciated. TIA, Eric Quote Link to comment
Julian Carr Posted March 30, 2020 Share Posted March 30, 2020 Untested, but something like this should work... Procedure CheckSymbolExists; VAR gsSymNameCurrent : STRING; Function DoIt(h1 : HANDLE) : BOOLEAN; VAR sSymNameExist : STRING; BEGIN IF (h1 <> Nil) & (GetType(h1) = 16) THEN BEGIN sSymNameExist := GetSDName(h1); IF sSymNameExist = gsSymNameCurrent THEN SysBeep; END; END; BEGIN gsSymNameCurrent := StrDialog('Symbol name to search for:', ''); ForEachObjectInList(DoIt, 0, 2, FSymDef); END; Run(CheckSymbolExists); 1 Quote Link to comment
Pat Stanford Posted March 30, 2020 Share Posted March 30, 2020 Also untested, but something like this should get you a Resource List. Procedure MakeRL; var H1: Handle; List1: LongInt; NumItems: LongInt; Begin List1:=BuildResourceList(16, 0, '', NumItems); End; Run(MakeRL); To find if a specific symbol exists you would need to loop through the list. Using the same variables as above (both parts will need to be part of your overall script), it might be something like: var. L1: LongInt; S1: String; Exists: Boolean; Exists:=False; For L1:= 1 to NumItems Do Begin S1:=GetNameFromResourceList(List1, L1); If S1='My Symbol Name' then Exists:=True; End; Remember that the resource list will give you all the symbol definitions in the file, not just symbols that are actually inserted in the document. 1 Quote Link to comment
MullinRJ Posted March 30, 2020 Share Posted March 30, 2020 @Wizard12 , This may be overly simplistic, but you can check the existence of a name without building a list with: NameExists := GetObject('Your test name here') <> nil; or if you want to also test if it is a Symbol, then: H := GetObject('Your test name here'); if (H <> nil) then begin if (GetTypeN(H) = 16) then begin { name exists and it's a Symbol } end else begin { name exists and it's NOT a Symbol } end end else begin { Name does not exist } end; HTH, Raymond 2 Quote Link to comment
Wizard12 Posted March 30, 2020 Author Share Posted March 30, 2020 Thanks everyone. I will test these examples. You guys are great! Quote Link to comment
Wizard12 Posted March 30, 2020 Author Share Posted March 30, 2020 Thanks everyone. I will test these examples. You guys are great! 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.