Topic
3 replies Latest Post - ‏2014-04-07T20:16:46Z by llandale
vlke
vlke
2 Posts
ACCEPTED ANSWER

Pinned topic Getting object in module by absno only possible if visible?

‏2014-04-07T09:14:26Z |

I need to access an object in a formal module for which I have a doors URL. I'm successfully using decodeURL to get the necessary information including the correct absno for the object.

Next, I'm trying to access the object like this:

int n // object absno from decodeURL

Module m // module containing object

Object o = object(n, m)

This fails, i.e. returns null if the current view is restricted to e.g. level 1 but the object is on some lower level, or if the current view is filtered. The documentation on the object perm doesn't mention that restriction on visible objects.

Is this a bug or is there any other way to get an invisible object by its absno? This is used in a script which needs to iterate over a complete module, so I don't want to make each object visible by using gotoObject or forcing the user to turn off all filtering.

  • llandale
    llandale
    2943 Posts
    ACCEPTED ANSWER

    Re: Getting object in module by absno only possible if visible?

    ‏2014-04-07T17:31:43Z  in response to vlke

    Not documented but yes, it is restricted to the display view.  You may need to put the objects in a Skip:

    • Skip skpObjects = create() // KEY 'int' AbsNo; DATA: 'Object'
    • for o in entire m do
    • {  put(skpObjects, (int o."Absolute Number"), o)
    • }
    • ...
    • if (!find(skpObjects, iAbsNo, o)) then no such object

    If you figure to search only once then you don't need the Skip; but if you figure to search for a few modules the Skip is a lot more effecient than looping through the Module each time

    -Louie

     

    • vlke
      vlke
      2 Posts
      ACCEPTED ANSWER

      Re: Getting object in module by absno only possible if visible?

      ‏2014-04-07T19:09:28Z  in response to llandale

      A real pity that such essential info is missing from the docs :-(

      Thanks, Louie, for the skip list idea.

      In the hopes of it not happening too often, I first resorted to a linear search in the module whenever getting the object directly failed. I'll now create the skip list lazily on first failed access instead because that implies some filter being active and more hidden objects are likely to be encountered.

      Lars.

      • llandale
        llandale
        2943 Posts
        ACCEPTED ANSWER

        Re: Getting object in module by absno only possible if visible?

        ‏2014-04-07T20:16:46Z  in response to vlke

        Yes, I dislike being subject to the whims of the current view.