Check for Sub existance

Discussion in 'Questions (Windows Mobile)' started by Scubaticus, Nov 3, 2007.

  1. Scubaticus

    Scubaticus Active Member Licensed User

    Is there a way to find out if a Sub exists.

    I know I can use an errorlabel to catch undefined callSubs, but I'm looking for a clean way to find out the existence of a sub.

    One problem using the errorlabel cause the program to loop, but this is probably because the errorlabel itself is in the If stucture:
    So a separate question is, what is happening with my vars when an error jumps in?

    Last edited: Nov 3, 2007
  2. Erel

    Erel Administrator Staff Member Licensed User

    I assume that you know the names of all the subs.
    You can add these names to an ArrayList and use ArrayList.IndexOf to check if the sub exists.
  3. Scubaticus

    Scubaticus Active Member Licensed User

    Before the callSub I used a Select/Case......
    Now when I ad a sub, or remove it I also have to keep track of the array values.

    It would be nice if there was some kind of "if exist" (sub, control, etc.)

  4. Cableguy

    Cableguy Expert Licensed User

    Still I agree with Erel.....

    I do can see your point, but beeing a sub a must know thing in your app, it's easyer to create an array and update it...

    It would be nice to have a "special" array with all the subs names automatically updated when project was saved...
  5. Scubaticus

    Scubaticus Active Member Licensed User

    Well, yes and no. Of course, it's a good thing to know your subs. But I work with "objects" and one of it's properties is used as a special sub-call. But it does not need to exist.

    Life would become easier (just like the function_exists in PHP for example). I'm just missing the check of existence. The controls for example. Do you put all your controls in array? I don't, but trying to set a control, because you use a template for example, which does not exist causes an error to rise. And yes to catch those errors errorlabel could be used, but I think the errorlabel thing is not what it should be. I'm not interested if an error somewhere in my sub occurs, but do if it's on a specific statement. Now I have to define a whole new sub just to catch these kind of errors......

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice