PDA

View Full Version : Determine if an object exists



T3STY
08-14-2009, 04:16 PM
Hi!
It's me again. I need an action that doesn't exist in AMS and I didn't saw anything can help me here.
In AMS there is File/Folder.DoesExist; But i need to determine if an object exists in my AMS application and there is nothing in AMS to do this.

Is there anyone can make an free action plugin for this ?
Thank you

p.s. The action I was thinking should be like this:
Object.DoesExist(String OBJ_Type,String OBJ_Name);

Centauri Soldier
08-14-2009, 04:35 PM
Here ya go...

This uses only the object name

function ObjectDoesExist(sSearchObject)
local bRet = false;

local tAllObjects = Page.EnumerateObjects();

if tAllObjects then

for nIndex, sObject in tAllObjects do

if sObject == sSearchObject then
bRet = true;
break;
end

end

end

return bRet
end


This uses the object type and name

function ObjectDoesExist(nObjectType, sSearchObject)
local bRet = false;

local tAllObjects = Page.EnumerateObjects();

if tAllObjects then

for nIndex, sObject in tAllObjects do

if Page.GetObjectType(sObject) == nObjectType and sObject == sSearchObject then
bRet = true;
break;
end

end

end

return bRet
end

Oh, and for future reference, object types are numbers not strings. You could actually use a number instead of OBJECT_PARAGRAPH. The numbers for each object type are listed in the _constants.xml file in your AMS Data folder and probably in the help file as well.

T3STY
08-15-2009, 07:51 AM
Thankyou Centauri Soldier! That is what I was looking for and I hope it will be useful also for other people.

p.s. personally, I use the second function :)
p.p.s. Do you think can this be another function to add to AMS in future versions ?

Bye!