Topic
  • 5 replies
  • Latest Post - ‏2015-12-04T20:30:47Z by dylandrush
grasswistle
grasswistle
13 Posts

Pinned topic How to tell if a view exists

‏2013-11-29T17:05:25Z |

Let's say I have a string s.  How can I tell whether a module has a view by the name of s defined?

Thanks,

Grasswistle

  • adevicq
    adevicq
    154 Posts

    Re: How to tell if a view exists

    ‏2013-11-29T17:30:42Z  

    Hi,

    You must try to load it. It is the only way I know...

    Regards,

    Alain

     

  • grasswistle
    grasswistle
    13 Posts

    Re: How to tell if a view exists

    ‏2013-11-29T17:35:07Z  
    • adevicq
    • ‏2013-11-29T17:30:42Z

    Hi,

    You must try to load it. It is the only way I know...

    Regards,

    Alain

     

    The problem is that if I try something like this,

    load view "Sfsdaasdf"

    there is no sign that the view doesn't exist.    Oh and "Sfsdaasdf", does not exist as a view... :)

    Thanks,

    Grasswistle

  • adevicq
    adevicq
    154 Posts

    Re: How to tell if a view exists

    ‏2013-11-29T17:39:08Z  

    The problem is that if I try something like this,

    load view "Sfsdaasdf"

    there is no sign that the view doesn't exist.    Oh and "Sfsdaasdf", does not exist as a view... :)

    Thanks,

    Grasswistle

    It returns a bool.

    If false, the view can't be loaded...

  • Mathias Mamsch
    Mathias Mamsch
    2135 Posts

    Re: How to tell if a view exists

    ‏2013-12-01T17:53:16Z  
    • adevicq
    • ‏2013-11-29T17:30:42Z

    Hi,

    You must try to load it. It is the only way I know...

    Regards,

    Alain

     

    And of course you can just iterate over the views inside a module and check if your view is there (without needing to load it):

    string sViewName; for sViewName in views modCurrent do { ... }

    (if I remember correctly, it might be that you need to pass a ModName_ or Item, check the DXL Manual).

    Regards, Mathias

    Updated on 2013-12-01T17:54:04Z at 2013-12-01T17:54:04Z by Mathias Mamsch
  • dylandrush
    dylandrush
    2 Posts

    Re: How to tell if a view exists

    ‏2015-12-04T20:30:47Z  

    This is an old thread, but eh.

     

    You could do something like the following:

     

    ModName_ modName = module(fullName(current Module))
    
    if (canRead(modName, view("Stsdaasdf"))) {
        print("This view does exist.\n")
    }
    else {
        print("This view doesn't exist...\n")   
    }