Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Check for Sub existance


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-03-2007, 10:18 PM
Knows the basics
 
Join Date: Jun 2007
Location: Netherlands (Arnhem)
Posts: 71
Default Check for Sub existance

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:
Quote:
Sub doCalSubs

ErrorLabel(InValidSub)

For ii = 1 To 2
CallSub ("Sub_" & ii)
InValidSub:
Next


End Sub

Sub Sub_1
End Sub
So a separate question is, what is happening with my vars when an error jumps in?


Scub.
__________________
PPC: IPAQ 2210, 2GB, CF GPS, CF Wireless

Last edited by Scubaticus : 11-03-2007 at 10:33 PM.
Reply With Quote
  #2 (permalink)  
Old 11-04-2007, 08:39 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

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.
Reply With Quote
  #3 (permalink)  
Old 11-04-2007, 09:32 PM
Knows the basics
 
Join Date: Jun 2007
Location: Netherlands (Arnhem)
Posts: 71
Default

Quote:
Originally Posted by Erel View Post
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.
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.)

Scub
__________________
PPC: IPAQ 2210, 2GB, CF GPS, CF Wireless
Reply With Quote
  #4 (permalink)  
Old 11-04-2007, 10:07 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

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...
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #5 (permalink)  
Old 11-04-2007, 10:54 PM
Knows the basics
 
Join Date: Jun 2007
Location: Netherlands (Arnhem)
Posts: 71
Default

Quote:
Originally Posted by Cableguy View Post
Still I agree with Erel.....
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......


Scub
__________________
PPC: IPAQ 2210, 2GB, CF GPS, CF Wireless
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Check for duplicates moster67 Questions & Help Needed 2 09-07-2008 07:58 AM
How can I check database is opened? fishworld2006 Questions & Help Needed 2 08-29-2008 10:18 AM
How to check if Form is active Mr_Gee Questions & Help Needed 5 05-07-2008 04:00 PM
Treeview and check-boxes BjornF Questions & Help Needed 2 06-26-2007 04:45 PM
How to check whether .Net CF 2.0 is installed correctly Erel Code Samples & Tips 3 05-18-2007 03:59 PM


All times are GMT. The time now is 06:31 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0