Topic
  • 2 replies
  • Latest Post - ‏2013-02-14T20:08:39Z by llandale
SystemAdmin
SystemAdmin
3180 Posts

Pinned topic Error when trying to delete object

‏2013-02-14T16:16:27Z |
Hello all,

I have a import script that parses a text file and places the text into a range of objects under a certain top level object. There is a situation that I may run into where I may 5 objects in a text file and 7 objects already in the document. To counteract this I am trying to delete all the objects in the top level object at the beginning of my import. However, I am getting this error:

"cannot delete Object: no access to source object"
This is the part of the code that I'm using to delete the objects:

{
temp = top."Object Heading"

if(temp == "My Heading")
{
for del in top do
{
delete del
}
}
}

I'm not all that familiar with DXL so I would any appreciate any help or advice on the matter.

Does anyone know how to fix this error? or perhaps another method to achieve the same result?

Thanks in advance for any help!

-Kory
Updated on 2013-02-14T20:08:39Z at 2013-02-14T20:08:39Z by llandale
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: Error when trying to delete object

    ‏2013-02-14T16:19:48Z  
    My apologies, here is a cleaner look at some of my code.

    for top in all current Module do
    {

    temp = top."Object Heading"

    if(temp == "Test Software Procedure")
    {

    for del in top do
    {

    del."Object Text" = ""
    delete del

    }

    }

    }
  • llandale
    llandale
    3035 Posts

    Re: Error when trying to delete object

    ‏2013-02-14T20:08:39Z  

    [1] You are modifying a loop variable inside the loop. I'm guessing Doors found an "Object" handle that doesn't really exist.
     

    Skip skpDels = create()
    int Sequence = 1000000    // try to delete objects bottom up
    for del in top do{put(skpDels, Sequence--, del)}
    for del in skpDels do
    {  softDelete(del)
    }
    flushDeletions
    delete(skpDels)
    

     


    the "for o in o do" loop runs like this:

     

     

    del = first Subordinate of top
    while (!null del)
    {  body of loop
       del = next sibling of del
    }
    



    When you delete "del" inside the loop, then it is no longer part of the loop (which only deals with undeleted objects). DOORS then gets lost as to which object is supposed to "follow" an object no longer in the loop.

    [2] "delete" I think now means "hardDelete" aka 'purge'

    [3] these deletes will fail if the object has incoming links, ??or I think outgoing links??

    [4] these deletes will fail if they have subordinate objects to which you have no access or have incoming links.

    -Louie



     

    Updated on 2014-01-09T00:31:26Z at 2014-01-09T00:31:26Z by iron-man