Wizard12 0 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 Share this post Link to post
Julian Carr 122 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 Share this post Link to post
Pat Stanford 1,540 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 Share this post Link to post
MullinRJ 211 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 Share this post Link to post
Wizard12 0 Posted March 30, 2020 Thanks everyone. I will test these examples. You guys are great! Quote Share this post Link to post
Wizard12 0 Posted March 30, 2020 Thanks everyone. I will test these examples. You guys are great! Quote Share this post Link to post