Cancel
Showing results for 
Search instead for 
Did you mean: 

Find and Delete User-Defined Attribute

Genius
Genius

Is there a way to access the User-Defined Attribute table to search for a User-Defined Attribute without knowing the entire name using SimTalk?

 

This is what I am trying to do:

I want to search for and delete all User-Defined Attributes of an object with the name starting with "t_." 

 

so something like:

 

 

obj.setCursor(0,0)
while obj.find("t_"*)
     obj.deleteAttr(obj.CursorY)
end
2 REPLIES

Re: Find and Delete User-Defined Attribute

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

you find all in the help

 

numAttr

getAttrName(index)

deleteAttr(name)

e.g. (not tested)

 

var i:integer

for i:=obj.numAttr downto 1 loop

 if pos("t_",obj.getAttrName(i))=1 then --starts with t_

   obj.deleteAttr(obj.getAttrName(i))

 end

next

 

 

--> see the restrictions of deleteAttr !!

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Find and Delete User-Defined Attribute

Genius
Genius

Thank you Steffen,

 

That worked beautifully.

 

I couldn't think of how to check if "t_" was in the first postion... Makes sense that the method is called "pos()."

 

Thank you again.