Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Endless loop

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2007, 03:29 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default Endless loop

Why does this becomes an endless loop?

Code:
ErrorLabel(DefaultValues)
    HiScoreTable.TableSort(
"Score DESC")
    FileOpen(c1,
"Pairs.ini",cWrite)
    FileWrite(c1,
"ImageSet:"&ImageSet)
    FileWrite(c1,
"Level:"&Level)
    FileWrite(c1,
"")
    FileWrite(c1,
"High-Scores:")
    FileWrite(c1,
"")
    FileWrite(c1,HiScoreTable.Cell(
"Player",0)&"-"&HiScoreTable.Cell("Score",0))
    FileWrite(c1,HiScoreTable.Cell(
"Player",1)&"-"&HiScoreTable.Cell("Score",1))
    FileWrite(c1,HiScoreTable.Cell(
"Player",2)&"-"&HiScoreTable.Cell("Score",2))
    FileWrite(c1,HiScoreTable.Cell(
"Player",3)&"-"&HiScoreTable.Cell("Score",3))
    FileWrite(c1,HiScoreTable.Cell(
"Player",4)&"-"&HiScoreTable.Cell("Score",4))
    FileClose(c1)
    DefaultValues:
    FileOpen(c1,
"Pairs.ini",cWrite)
    FileWrite(c1,
"ImageSet: Basic.ist")
    FileWrite(c1,
"Level:Easy")
    FileWrite(c1,
"")
    FileWrite(c1,
"High-Scores:")
    FileWrite(c1,
"")
    FileWrite(c1,
"Player1-0")
    FileWrite(c1,
"Player2-0")
    FileWrite(c1,
"Player3-0")
    FileWrite(c1,
"Player4-0")
    FileWrite(c1,
"Player5-0")
    FileClose(c1)
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #2 (permalink)  
Old 06-28-2007, 03:40 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Ioannina, Greece
Posts: 356
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Hi cableguy,

In b4ppc help for ErrorLabel:
"...Sets a label that the program will jump to in case an error will occur in the current sub..."

If the error occurs afterDefaultValues: your program continues with the next line "FileOpen(c1,"Pairs.ini",cWrite)" and propably faces an error again and goes again to DefaultValues:



I hope I helped

__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #3 (permalink)  
Old 06-28-2007, 03:45 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Yes, I understand that but then what can be wrong?


This is part of a sub, but is the last part of it so, I'm sure that the code is correct in its sintax....
I added the error label after a tryout error wich render the ini file blank because it errored at the table sort as it was all cells empty, so i coded a fail-safe default value ini file creation, and that is what is failling now...

PS. I tryied reducing the defaulvalues to the simples form :

FileOpen(c1,"Pairs.ini",cWrite)
FileClose(c1)

And STILL FAILS
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!

Last edited by Cableguy : 06-28-2007 at 03:51 PM. Reason: More details added
Reply With Quote
  #4 (permalink)  
Old 06-28-2007, 03:57 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Ioannina, Greece
Posts: 356
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Remove errorlabel to see the error.
By the way did you check if pairs.ini can't be opened for write because is open by another app or something similar?
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #5 (permalink)  
Old 06-28-2007, 04:02 PM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

Dear Cableguy,

and if you just use the FileOpen(c1,"Pairs.ini",cWrite) command?

(i.e. is it the open or the close command that is causing the problem?)
Reply With Quote
  #6 (permalink)  
Old 06-28-2007, 04:03 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

The first error to apear is the table sort since the ini file is blank the table doesnt get any values entered...
But now it gets stranger even withou the errorlabel it loops....
I have no other app using the file....
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #7 (permalink)  
Old 06-28-2007, 04:10 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I have some good news and some bad news...
The good news:

I now know why it is erroing out and DZT was Right!! the file is being used by another....Process?

The bad news:

WHAT PROCESS???
I made sure to close the conection each time i access the file...

EDIT: I changed the name of the file under the defaultvalues and now the rror descriptions talks about the c1 key being already added to the diccionary. This makes me think that the conection to c1 is still open altough i'm sure , and have double checked, I did close everytime I opened the conection...can this be a BUG????

Edit2: defenetly a conection issue, I changed to c2 and it worked, with another filename...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!

Last edited by Cableguy : 06-28-2007 at 04:23 PM.
Reply With Quote
  #8 (permalink)  
Old 06-28-2007, 04:19 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Ioannina, Greece
Posts: 356
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Just a guess!
On of thousands times you run the compiled app, it failed to terminate before closing the file and stayed as an orphan process, locking your file.

But... only your computer's processor knows the truth.

EDIT (about cableguy last EDIT): No it is not a bug. Just an error occured between FileOpen and FileClose and FileClose didn't executed. So the file left opened.
__________________
Dimitris Zacharakis
http://www.terracom.gr

Last edited by dzt : 06-28-2007 at 04:37 PM. Reason: No bug
Reply With Quote
  #9 (permalink)  
Old 06-28-2007, 04:36 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Dzt you RULE...

It's fixed now...

A tip when using external files:

It IS a good practice to CLOSE the conection you are about to use BEFORE openig it...

Just add

FileClose(c1) 'the conection number you'll be using
FileOpen(c1,.........)
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Click event during a for loop pmu5757 Questions (Windows Mobile) 5 04-12-2008 03:44 PM
Do...Loop While Put Claude Questions (Windows Mobile) 1 07-24-2007 08:02 PM
error label and for next loop Cableguy Questions (Windows Mobile) 4 05-23-2007 07:47 AM
How to create endless loop with keypress Stellaferox Questions (Windows Mobile) 10 05-17-2007 08:09 PM
How to achieve loop with textboxinput? Stellaferox Questions (Windows Mobile) 22 05-08-2007 07:25 PM


All times are GMT. The time now is 10:22 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0