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.


error label and for next loop


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-22-2007, 06:50 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 error label and for next loop

Hi,

I have an Error Label inside a for next loop, and when an error is trapped the error label is called but the for next loop is not exited and becomes an endless loop...

Code:
Sub MySub

errorlabel (error)

for x = 0 to 49
D Something
next x

error:
msgbox("file was not created!!",,cMsgBoxOK,cMsgBoxExclamation)

End Sub
How can I exit the loop when the error is trapped?
I've tryed Exit and Return with no success!!
__________________
Paulo Gomes
Porto, Portugal

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

DLL Version Listing
Reply With Quote
  #2 (permalink)  
Old 05-22-2007, 07:25 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 649
Default

I tested your code and tried even a "do while" loop.
Its a strange behaviour!
Sometimes it seems to work fine, sometimes the application seems to hang, even on the desktop just executing a "do nothing loop" with only 40 repeats.
Reply With Quote
  #3 (permalink)  
Old 05-22-2007, 07:48 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I think that perhaps you need to have a variable inside the For Next loop that is examined each time around the loop. If the error is caught then the variable can be set and this in turn causes the loop to be broken, personally I would use the Break command to exit the loop.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #4 (permalink)  
Old 05-22-2007, 08:59 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

Can you upload a simple program that shows the problem?
Reply With Quote
  #5 (permalink)  
Old 05-23-2007, 08:47 AM
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

Thanks for your help,It seems the problem is solved...in my sub I had an open conection to a file and when the error was trapped the file wasn't closed causing the endless loop...Now it works fine
__________________
Paulo Gomes
Porto, Portugal

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

DLL Version Listing
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
Problem with Serial. ("before loop" error) jesb4ppc Questions & Help Needed 3 02-15-2008 06:41 PM
Do...Loop While Put Claude Questions & Help Needed 1 07-24-2007 09:02 PM
Error Label Cableguy Questions & Help Needed 5 06-28-2007 06:07 PM
Endless loop Cableguy Questions & Help Needed 8 06-28-2007 05:36 PM
How to achieve loop with textboxinput? Stellaferox Questions & Help Needed 22 05-08-2007 08:25 PM


All times are GMT. The time now is 02:32 PM.


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